@coderich/util 1.2.0 → 1.2.2
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.
- package/package.json +4 -3
- 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.
|
|
4
|
+
"version": "1.2.2",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
"lodash": "4.17.21"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
|
-
"@coderich/dev": "0.
|
|
22
|
+
"@coderich/dev": "0.3.3",
|
|
23
|
+
"flat": "5.0.2"
|
|
23
24
|
}
|
|
24
|
-
}
|
|
25
|
+
}
|
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);
|