@domql/utils 2.5.76 → 2.5.80

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.
@@ -20,7 +20,6 @@ var object_exports = {};
20
20
  __export(object_exports, {
21
21
  clone: () => clone,
22
22
  deepClone: () => deepClone,
23
- deepCloneEntrance: () => deepCloneEntrance,
24
23
  deepCloneExclude: () => deepCloneExclude,
25
24
  deepCloneWithExtend: () => deepCloneWithExtend,
26
25
  deepContains: () => deepContains,
@@ -136,6 +135,12 @@ const mergeArrayExclude = (arr, excl = []) => {
136
135
  const deepClone = (obj, excludeFrom = [], cleanUndefined = false) => {
137
136
  const o = (0, import_types.isArray)(obj) ? [] : {};
138
137
  for (const prop in obj) {
138
+ if (!Object.prototype.hasOwnProperty.call(obj, prop))
139
+ continue;
140
+ if (prop === "node" || prop === "parent" || prop === "root" || prop === "__element") {
141
+ console.warn("recursive clonning is called", obj);
142
+ continue;
143
+ }
139
144
  if (prop === "__proto__")
140
145
  continue;
141
146
  if (excludeFrom.includes(prop) || prop.startsWith("__"))
@@ -153,21 +158,17 @@ const deepClone = (obj, excludeFrom = [], cleanUndefined = false) => {
153
158
  }
154
159
  return o;
155
160
  };
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
161
  const deepCloneWithExtend = (obj, excludeFrom = ["node"], options = {}) => {
166
162
  const o = (0, import_types.isArray)(obj) ? [] : {};
167
163
  for (const prop in obj) {
168
- const hasOwnProperty2 = Object.prototype.hasOwnProperty.call(obj, prop);
164
+ if (!Object.prototype.hasOwnProperty.call(obj, prop))
165
+ continue;
166
+ if (prop === "node" || prop === "parent" || prop === "root" || prop === "__element") {
167
+ console.warn("recursive clonning is called", obj);
168
+ continue;
169
+ }
169
170
  const objProp = obj[prop];
170
- if (!hasOwnProperty2 || excludeFrom.includes(prop) || prop.startsWith("__") || options.cleanUndefined && (0, import_types.isUndefined)(objProp) || options.cleanNull && (0, import_types.isNull)(objProp))
171
+ if (excludeFrom.includes(prop) || prop.startsWith("__") || options.cleanUndefined && (0, import_types.isUndefined)(objProp) || options.cleanNull && (0, import_types.isNull)(objProp))
171
172
  continue;
172
173
  if ((0, import_types.isObjectLike)(objProp)) {
173
174
  o[prop] = deepCloneWithExtend(objProp, excludeFrom, options);
package/object.js CHANGED
@@ -98,6 +98,11 @@ export const mergeArrayExclude = (arr, excl = []) => {
98
98
  export const deepClone = (obj, excludeFrom = [], cleanUndefined = false) => {
99
99
  const o = isArray(obj) ? [] : {}
100
100
  for (const prop in obj) {
101
+ if (!Object.prototype.hasOwnProperty.call(obj, prop)) continue
102
+ if (prop === 'node' || prop === 'parent' || prop === 'root' || prop === '__element') {
103
+ console.warn('recursive clonning is called', obj)
104
+ continue
105
+ }
101
106
  if (prop === '__proto__') continue
102
107
  if (excludeFrom.includes(prop) || prop.startsWith('__')) continue
103
108
  let objProp = obj[prop]
@@ -106,39 +111,35 @@ export const deepClone = (obj, excludeFrom = [], cleanUndefined = false) => {
106
111
  objProp = mergeArray(objProp)
107
112
  }
108
113
  if (isObjectLike(objProp)) {
114
+ // queueMicrotask(() => {
109
115
  o[prop] = deepClone(objProp, excludeFrom, cleanUndefined)
116
+ // })
110
117
  } else o[prop] = objProp
111
118
  }
112
119
  return o
113
120
  }
121
+
114
122
  /**
115
123
  * Deep cloning of object
116
124
  */
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
125
  export const deepCloneWithExtend = (obj, excludeFrom = ['node'], options = {}) => {
131
126
  const o = isArray(obj) ? [] : {}
132
127
  for (const prop in obj) {
133
- const hasOwnProperty = Object.prototype.hasOwnProperty.call(obj, prop)
128
+ if (!Object.prototype.hasOwnProperty.call(obj, prop)) continue
129
+ if (prop === 'node' || prop === 'parent' || prop === 'root' || prop === '__element') {
130
+ console.warn('recursive clonning is called', obj)
131
+ continue
132
+ }
134
133
  const objProp = obj[prop]
135
134
  if (
136
- !hasOwnProperty || excludeFrom.includes(prop) || prop.startsWith('__') ||
135
+ excludeFrom.includes(prop) || prop.startsWith('__') ||
137
136
  (options.cleanUndefined && isUndefined(objProp)) ||
138
137
  (options.cleanNull && isNull(objProp))
139
138
  ) continue
140
139
  if (isObjectLike(objProp)) {
140
+ // queueMicrotask(() => {
141
141
  o[prop] = deepCloneWithExtend(objProp, excludeFrom, options)
142
+ // })
142
143
  } else o[prop] = objProp
143
144
  }
144
145
  return o
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@domql/utils",
3
- "version": "2.5.76",
3
+ "version": "2.5.80",
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": "767e48d9adb22095984c0feb21fd92f045cdfe4a",
26
+ "gitHead": "48b6b1ab378914613e11e696ae931cece3f784bb",
27
27
  "devDependencies": {
28
28
  "@babel/core": "^7.12.0"
29
29
  }