@coderich/util 1.0.5 → 1.0.7

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 +2 -3
  2. 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": "1.0.5",
4
+ "version": "1.0.7",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -16,8 +16,7 @@
16
16
  },
17
17
  "dependencies": {
18
18
  "bson": "6.8.0",
19
- "dot-prop": "6.0.1",
20
- "lodash.isequal": "4.5.0"
19
+ "lodash": "4.17.21"
21
20
  },
22
21
  "devDependencies": {
23
22
  "@coderich/dev": "0.2.1"
package/src/index.js CHANGED
@@ -1,9 +1,8 @@
1
1
  const FS = require('fs');
2
2
  const Path = require('path');
3
3
  const ChildProcess = require('child_process');
4
- const isEqual = require('lodash.isequal');
4
+ const { set, isEqual } = require('lodash');
5
5
  const { ObjectId } = require('bson');
6
- const { set } = require('dot-prop');
7
6
 
8
7
  exports.set = set;
9
8
  exports.isEqual = isEqual;
@@ -31,7 +30,7 @@ exports.findAndReplace = (arr, fn, ...items) => {
31
30
  exports.isPlainObject = (obj) => {
32
31
  if (obj == null || Array.isArray(obj)) return false;
33
32
  const proto = Object.getPrototypeOf(obj);
34
- return proto === Object.prototype || proto?.toString?.call?.(obj) === '[object Object]';
33
+ return (proto == null || proto === Object.prototype || proto?.toString?.call?.(obj) === '[object Object]');
35
34
  };
36
35
 
37
36
  exports.filterRe = (arr, fn) => {
@@ -57,7 +56,8 @@ exports.flatten = (mixed, options = {}) => {
57
56
  return exports.map(mixed, el => (function flatten(data, obj = {}, path = [], depth = 0) {
58
57
  if (depth <= maxDepth && typeFn(data) && Object.keys(data).length) {
59
58
  return Object.entries(data).reduce((o, [key, value]) => {
60
- const $key = options.strict ? key.replaceAll('.', '\\.') : key;
59
+ const $key = options.strict && key.split('.').length > 1 ? `['${key}']` : key; // Use for lodash
60
+ // const $key = options.strict ? key.replaceAll('.', '\\.') : key; // Use for dot-prop
61
61
  return flatten(value, o, path.concat($key), depth + 1);
62
62
  }, obj);
63
63
  }