Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@domql/utils

Package Overview
Dependencies
Maintainers
0
Versions
195
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@domql/utils - npm Package Compare versions

Comparing version 2.5.142 to 2.5.143

16

dist/cjs/object.js

@@ -166,3 +166,9 @@ "use strict";

};
const deepCloneWithExtend = (obj, excludeFrom = ["node"], options = {}) => {
const deepCloneWithExtend = (obj, excludeFrom = ["node"], options = {}, visited = /* @__PURE__ */ new WeakSet()) => {
if ((0, import_types.isObjectLike)(obj)) {
if (visited.has(obj)) {
return obj;
}
visited.add(obj);
}
const o = options.window ? (0, import_types.isArray)(obj) ? new options.window.Array([]) : new options.window.Object({}) : (0, import_types.isArray)(obj) ? [] : {};

@@ -173,10 +179,12 @@ for (const prop in obj) {

const objProp = obj[prop];
if (excludeFrom.includes(prop) || prop.startsWith("__") || options.cleanUndefined && (0, import_types.isUndefined)(objProp) || options.cleanNull && (0, import_types.isNull)(objProp))
if (excludeFrom.includes(prop) || prop.startsWith("__") || options.cleanUndefined && (0, import_types.isUndefined)(objProp) || options.cleanNull && (0, import_types.isNull)(objProp)) {
continue;
}
if ((0, import_types.isObjectLike)(objProp)) {
o[prop] = deepCloneWithExtend(objProp, excludeFrom, options);
o[prop] = deepCloneWithExtend(objProp, excludeFrom, options, visited);
} else if ((0, import_types.isFunction)(objProp) && options.window) {
o[prop] = (options.window || import_globals.window).eval("(" + objProp.toString() + ")");
} else
} else {
o[prop] = objProp;
}
}

@@ -183,0 +191,0 @@ return o;

@@ -172,26 +172,42 @@ 'use strict'

*/
export const deepCloneWithExtend = (obj, excludeFrom = ['node'], options = {}) => {
export const deepCloneWithExtend = (obj, excludeFrom = ['node'], options = {}, visited = new WeakSet()) => {
// Check if the value is object-like before trying to track it in visited
if (isObjectLike(obj)) {
if (visited.has(obj)) {
return obj // Return the object if it was already cloned
}
visited.add(obj) // Add to visited set only if it's an object
}
const o = options.window
? isArray(obj) ? new options.window.Array([]) : new options.window.Object({})
: isArray(obj) ? [] : {}
? isArray(obj)
? new options.window.Array([])
: new options.window.Object({})
: isArray(obj)
? []
: {}
for (const prop in obj) {
if (!Object.prototype.hasOwnProperty.call(obj, prop)) continue
// if (prop === 'node' || prop === 'parent' || prop === 'root' || prop === '__element') {
// console.warn('recursive clonning is called', obj)
// continue
// }
const objProp = obj[prop]
if (
excludeFrom.includes(prop) || prop.startsWith('__') ||
excludeFrom.includes(prop) ||
prop.startsWith('__') ||
(options.cleanUndefined && isUndefined(objProp)) ||
(options.cleanNull && isNull(objProp))
) continue
) {
continue
}
if (isObjectLike(objProp)) {
// queueMicrotask(() => {
o[prop] = deepCloneWithExtend(objProp, excludeFrom, options)
// })
o[prop] = deepCloneWithExtend(objProp, excludeFrom, options, visited)
} else if (isFunction(objProp) && options.window) {
o[prop] = (options.window || window).eval('(' + objProp.toString() + ')')
} else o[prop] = objProp
} else {
o[prop] = objProp
}
}
return o

@@ -198,0 +214,0 @@ }

{
"name": "@domql/utils",
"version": "2.5.142",
"version": "2.5.143",
"license": "MIT",

@@ -28,3 +28,3 @@ "type": "module",

},
"gitHead": "65537c9b9a818948e1835b75a5c8a3e79bffdecd",
"gitHead": "46440d5034244c18657bf272df1bdc3e8ff666c5",
"devDependencies": {

@@ -31,0 +31,0 @@ "@babel/core": "^7.12.0"

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc