@coderich/util 0.1.17 → 1.0.0
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 +5 -5
- package/src/index.js +4 -4
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coderich/util",
|
|
3
3
|
"main": "src/index.js",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "1.0.0",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -11,15 +11,15 @@
|
|
|
11
11
|
],
|
|
12
12
|
"scripts": {
|
|
13
13
|
"test": "jest --config=jest.config.js",
|
|
14
|
-
"lint": "eslint
|
|
14
|
+
"lint": "eslint ./",
|
|
15
15
|
"dev": "coderich-dev"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"bson-objectid": "2.0.4",
|
|
19
|
-
"
|
|
20
|
-
"lodash.
|
|
19
|
+
"dot-prop": "8.0.2",
|
|
20
|
+
"lodash.isequal": "4.5.0"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@coderich/dev": "0.
|
|
23
|
+
"@coderich/dev": "0.2.0"
|
|
24
24
|
}
|
|
25
25
|
}
|
package/src/index.js
CHANGED
|
@@ -2,10 +2,10 @@ const FS = require('fs');
|
|
|
2
2
|
const Path = require('path');
|
|
3
3
|
const ChildProcess = require('child_process');
|
|
4
4
|
const ObjectId = require('bson-objectid');
|
|
5
|
-
const set = require('lodash.set');
|
|
6
5
|
const isEqual = require('lodash.isequal');
|
|
6
|
+
const { setProperty } = require('dot-prop');
|
|
7
7
|
|
|
8
|
-
exports.set =
|
|
8
|
+
exports.set = setProperty;
|
|
9
9
|
exports.isEqual = isEqual;
|
|
10
10
|
exports.ObjectId = ObjectId;
|
|
11
11
|
|
|
@@ -57,7 +57,7 @@ exports.flatten = (mixed, options = {}) => {
|
|
|
57
57
|
return exports.map(mixed, el => (function flatten(data, obj = {}, path = [], depth = 0) {
|
|
58
58
|
if (depth <= maxDepth && typeFn(data) && Object.keys(data).length) {
|
|
59
59
|
return Object.entries(data).reduce((o, [key, value]) => {
|
|
60
|
-
const $key = options.strict
|
|
60
|
+
const $key = options.strict ? key.replaceAll('.', '\\.') : key;
|
|
61
61
|
return flatten(value, o, path.concat($key), depth + 1);
|
|
62
62
|
}, obj);
|
|
63
63
|
}
|
|
@@ -76,7 +76,7 @@ exports.unflatten = (data, options = {}) => {
|
|
|
76
76
|
|
|
77
77
|
return exports.map(data, (el) => {
|
|
78
78
|
return typeFn(data) ? Object.entries(el).reduce((prev, [key, value]) => {
|
|
79
|
-
return set(prev, key, value);
|
|
79
|
+
return exports.set(prev, key, value);
|
|
80
80
|
}, {}) : el;
|
|
81
81
|
});
|
|
82
82
|
};
|