@coderich/util 1.2.0 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.js +7 -0
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@coderich/util",
3
3
  "main": "src/index.js",
4
- "version": "1.2.0",
4
+ "version": "1.2.1",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
package/src/index.js CHANGED
@@ -167,6 +167,13 @@ exports.pathmap = (paths, mixed, fn = v => v) => {
167
167
  return mixed;
168
168
  };
169
169
 
170
+ exports.traverse = (mixed, fn, info) => {
171
+ exports.map(mixed, (data) => {
172
+ const response = fn(data, info);
173
+ if (response) exports.traverse(response.value, fn, response.info);
174
+ });
175
+ };
176
+
170
177
  exports.mapPromise = (mixed, fn) => {
171
178
  const map = exports.map(mixed, fn);
172
179
  return Array.isArray(map) ? Promise.all(map) : Promise.resolve(map);