@domql/utils 2.5.64 → 2.5.71
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/dist/cjs/object.js +14 -7
- package/object.js +22 -6
- package/package.json +2 -2
package/dist/cjs/object.js
CHANGED
|
@@ -20,6 +20,7 @@ var object_exports = {};
|
|
|
20
20
|
__export(object_exports, {
|
|
21
21
|
clone: () => clone,
|
|
22
22
|
deepClone: () => deepClone,
|
|
23
|
+
deepCloneEntrance: () => deepCloneEntrance,
|
|
23
24
|
deepCloneExclude: () => deepCloneExclude,
|
|
24
25
|
deepCloneWithExtend: () => deepCloneWithExtend,
|
|
25
26
|
deepContains: () => deepContains,
|
|
@@ -152,18 +153,24 @@ const deepClone = (obj, excludeFrom = [], cleanUndefined = false) => {
|
|
|
152
153
|
}
|
|
153
154
|
return o;
|
|
154
155
|
};
|
|
155
|
-
const
|
|
156
|
+
const deepCloneEntrance = (...params) => {
|
|
157
|
+
let extended;
|
|
158
|
+
try {
|
|
159
|
+
extended = deepCloneWithExtend(...params);
|
|
160
|
+
} catch {
|
|
161
|
+
console.log("HERE", extended);
|
|
162
|
+
}
|
|
163
|
+
return extended;
|
|
164
|
+
};
|
|
165
|
+
const deepCloneWithExtend = (obj, excludeFrom = ["node"], options = {}) => {
|
|
156
166
|
const o = (0, import_types.isArray)(obj) ? [] : {};
|
|
157
167
|
for (const prop in obj) {
|
|
158
|
-
|
|
159
|
-
continue;
|
|
160
|
-
if (excludeFrom.includes(prop) || prop.startsWith("__"))
|
|
161
|
-
continue;
|
|
168
|
+
const hasOwnProperty2 = Object.prototype.hasOwnProperty.call(obj, prop);
|
|
162
169
|
const objProp = obj[prop];
|
|
163
|
-
if (cleanUndefined && (0, import_types.isUndefined)(objProp))
|
|
170
|
+
if (!hasOwnProperty2 || excludeFrom.includes(prop) || prop.startsWith("__") || options.cleanUndefined && (0, import_types.isUndefined)(objProp) || options.cleanNull && (0, import_types.isNull)(objProp))
|
|
164
171
|
continue;
|
|
165
172
|
if ((0, import_types.isObjectLike)(objProp)) {
|
|
166
|
-
o[prop] = deepCloneWithExtend(objProp, excludeFrom,
|
|
173
|
+
o[prop] = deepCloneWithExtend(objProp, excludeFrom, options);
|
|
167
174
|
} else
|
|
168
175
|
o[prop] = objProp;
|
|
169
176
|
}
|
package/object.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
import { window } from './globals.js'
|
|
4
|
-
import { isFunction, isObjectLike, isObject, isArray, isString, is, isUndefined, isDate } from './types.js'
|
|
4
|
+
import { isFunction, isObjectLike, isObject, isArray, isString, is, isUndefined, isDate, isNull } from './types.js'
|
|
5
5
|
import { mergeAndCloneIfArray, mergeArray } from './array.js'
|
|
6
6
|
import { stringIncludesAny } from './string.js'
|
|
7
7
|
|
|
@@ -114,15 +114,31 @@ export const deepClone = (obj, excludeFrom = [], cleanUndefined = false) => {
|
|
|
114
114
|
/**
|
|
115
115
|
* Deep cloning of object
|
|
116
116
|
*/
|
|
117
|
-
export const
|
|
117
|
+
export const deepCloneEntrance = (...params) => {
|
|
118
|
+
// console.groupCollapsed('deepCloneEntrance')
|
|
119
|
+
// console.warn(params)
|
|
120
|
+
let extended
|
|
121
|
+
try {
|
|
122
|
+
extended = deepCloneWithExtend(...params)
|
|
123
|
+
} catch {
|
|
124
|
+
console.log('HERE', extended)
|
|
125
|
+
}
|
|
126
|
+
// console.groupEnd('deepCloneEntrance')
|
|
127
|
+
return extended
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export const deepCloneWithExtend = (obj, excludeFrom = ['node'], options = {}) => {
|
|
118
131
|
const o = isArray(obj) ? [] : {}
|
|
119
132
|
for (const prop in obj) {
|
|
120
|
-
|
|
121
|
-
if (excludeFrom.includes(prop) || prop.startsWith('__')) continue
|
|
133
|
+
const hasOwnProperty = Object.prototype.hasOwnProperty.call(obj, prop)
|
|
122
134
|
const objProp = obj[prop]
|
|
123
|
-
if (
|
|
135
|
+
if (
|
|
136
|
+
!hasOwnProperty || excludeFrom.includes(prop) || prop.startsWith('__') ||
|
|
137
|
+
(options.cleanUndefined && isUndefined(objProp)) ||
|
|
138
|
+
(options.cleanNull && isNull(objProp))
|
|
139
|
+
) continue
|
|
124
140
|
if (isObjectLike(objProp)) {
|
|
125
|
-
o[prop] = deepCloneWithExtend(objProp, excludeFrom,
|
|
141
|
+
o[prop] = deepCloneWithExtend(objProp, excludeFrom, options)
|
|
126
142
|
} else o[prop] = objProp
|
|
127
143
|
}
|
|
128
144
|
return o
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@domql/utils",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.71",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "index.js",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"build": "yarn build:cjs",
|
|
24
24
|
"prepublish": "rimraf -I dist && yarn build && yarn copy:package:cjs"
|
|
25
25
|
},
|
|
26
|
-
"gitHead": "
|
|
26
|
+
"gitHead": "2750ffc91678c3b2e02f21c82fe58bc593414adb",
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@babel/core": "^7.12.0"
|
|
29
29
|
}
|