@domql/utils
Advanced tools
Comparing version 2.3.21 to 2.3.23
'use strict' | ||
import { isFunction, isObjectLike, isObject, isArray } from './types' | ||
import { isFunction, isObjectLike, isObject, isArray, isString } from './types' | ||
@@ -67,3 +67,3 @@ export const exec = (param, element, state) => { | ||
if (isArray(objProp)) { | ||
o[prop] = objProp.map(deepClone) | ||
o[prop] = objProp.map(v => isObject(v) ? deepClone(v) : v) | ||
} else if (isObject(objProp)) { | ||
@@ -77,2 +77,35 @@ o[prop] = deepClone(objProp) | ||
/** | ||
* Stringify object | ||
*/ | ||
export const deepStringify = (obj, stringified = {}) => { | ||
console.log(obj) | ||
for (const prop in obj) { | ||
const objProp = obj[prop] | ||
if (isFunction(objProp)) { | ||
stringified[prop] = objProp.toString() | ||
} else stringified[prop] = objProp | ||
if (isObject(objProp)) deepStringify(stringified[prop], stringified[prop]) | ||
} | ||
return stringified | ||
} | ||
/** | ||
* Detringify object | ||
*/ | ||
export const deepDestringify = (obj, stringified = {}) => { | ||
for (const prop in obj) { | ||
const objProp = obj[prop] | ||
if (isString(objProp)) { | ||
if (objProp.slice(0, 1) === '(') { | ||
try { | ||
stringified[prop] = eval(objProp) // eslint-disable-line | ||
} catch (e) { if (e) stringified[prop] = objProp } | ||
} | ||
} else stringified[prop] = objProp | ||
if (isObject(objProp)) deepDestringify(stringified[prop], stringified[prop]) | ||
} | ||
return stringified | ||
} | ||
/** | ||
* Overwrites object properties with another | ||
@@ -79,0 +112,0 @@ */ |
{ | ||
"name": "@domql/utils", | ||
"version": "2.3.21", | ||
"version": "2.3.23", | ||
"main": "index.js", | ||
@@ -10,3 +10,3 @@ "license": "MIT", | ||
}, | ||
"gitHead": "591bd439470038afee450aa314c56a257107b1a0" | ||
"gitHead": "3757666fe613ef00cbdf7d020da4b27c8bf3fb54" | ||
} |
AI-detected possible typosquat
Supply chain riskAI has identified this package as a potential typosquat of a more popular package. This suggests that the package may be intentionally mimicking another package's name, description, or other metadata.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
9912
320
2