@domql/utils 2.3.74 → 2.3.77
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 +9 -6
- package/object.js +10 -8
- package/package.json +2 -2
package/dist/cjs/object.js
CHANGED
|
@@ -171,17 +171,16 @@ const deepDestringify = (obj, stringified = {}) => {
|
|
|
171
171
|
if (e)
|
|
172
172
|
stringified[prop] = objProp;
|
|
173
173
|
}
|
|
174
|
+
} else {
|
|
175
|
+
stringified[prop] = objProp;
|
|
174
176
|
}
|
|
175
|
-
} else {
|
|
176
|
-
stringified[prop] = objProp;
|
|
177
|
-
}
|
|
178
|
-
if ((0, import_types.isArray)(objProp)) {
|
|
177
|
+
} else if ((0, import_types.isArray)(objProp)) {
|
|
179
178
|
stringified[prop] = [];
|
|
180
179
|
objProp.forEach((arrProp) => {
|
|
181
180
|
if ((0, import_types.isString)(arrProp)) {
|
|
182
181
|
if (arrProp.includes("=>") || arrProp.includes("function") || arrProp.startsWith("(")) {
|
|
183
182
|
try {
|
|
184
|
-
const evalProp = import_globals.window.eval(arrProp);
|
|
183
|
+
const evalProp = import_globals.window.eval(`(${arrProp})`);
|
|
185
184
|
stringified[prop].push(evalProp);
|
|
186
185
|
} catch (e) {
|
|
187
186
|
if (e)
|
|
@@ -190,12 +189,16 @@ const deepDestringify = (obj, stringified = {}) => {
|
|
|
190
189
|
} else {
|
|
191
190
|
stringified[prop].push(arrProp);
|
|
192
191
|
}
|
|
193
|
-
} else {
|
|
192
|
+
} else if ((0, import_types.isObject)(arrProp)) {
|
|
194
193
|
stringified[prop].push(deepDestringify(arrProp));
|
|
194
|
+
} else {
|
|
195
|
+
stringified[prop].push(arrProp);
|
|
195
196
|
}
|
|
196
197
|
});
|
|
197
198
|
} else if ((0, import_types.isObject)(objProp)) {
|
|
198
199
|
stringified[prop] = deepDestringify(objProp, stringified[prop]);
|
|
200
|
+
} else {
|
|
201
|
+
stringified[prop] = objProp;
|
|
199
202
|
}
|
|
200
203
|
}
|
|
201
204
|
return stringified;
|
package/object.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
import { window } from '@domql/globals'
|
|
4
|
-
import { isFunction, isObjectLike, isObject, isArray, isString } from './types.js'
|
|
4
|
+
import { isFunction, isObjectLike, isObject, isArray, isString, is } from './types.js'
|
|
5
5
|
|
|
6
6
|
export const exec = (param, element, state, context) => {
|
|
7
7
|
if (isFunction(param)) {
|
|
@@ -150,29 +150,31 @@ export const deepDestringify = (obj, stringified = {}) => {
|
|
|
150
150
|
const evalProp = window.eval(`(${objProp})`) // use parentheses to convert string to function expression
|
|
151
151
|
stringified[prop] = evalProp
|
|
152
152
|
} catch (e) { if (e) stringified[prop] = objProp }
|
|
153
|
+
} else {
|
|
154
|
+
stringified[prop] = objProp
|
|
153
155
|
}
|
|
154
|
-
} else {
|
|
155
|
-
stringified[prop] = objProp
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
if (isArray(objProp)) {
|
|
156
|
+
} else if (isArray(objProp)) {
|
|
159
157
|
stringified[prop] = []
|
|
160
158
|
objProp.forEach((arrProp) => {
|
|
161
159
|
if (isString(arrProp)) {
|
|
162
160
|
if (arrProp.includes('=>') || arrProp.includes('function') || arrProp.startsWith('(')) {
|
|
163
161
|
try {
|
|
164
|
-
const evalProp = window.eval(arrProp) //
|
|
162
|
+
const evalProp = window.eval(`(${arrProp})`) // use parentheses to convert string to function expression
|
|
165
163
|
stringified[prop].push(evalProp)
|
|
166
164
|
} catch (e) { if (e) stringified[prop].push(arrProp) }
|
|
167
165
|
} else {
|
|
168
166
|
stringified[prop].push(arrProp)
|
|
169
167
|
}
|
|
170
|
-
} else {
|
|
168
|
+
} else if (isObject(arrProp)) {
|
|
171
169
|
stringified[prop].push(deepDestringify(arrProp))
|
|
170
|
+
} else {
|
|
171
|
+
stringified[prop].push(arrProp)
|
|
172
172
|
}
|
|
173
173
|
})
|
|
174
174
|
} else if (isObject(objProp)) {
|
|
175
175
|
stringified[prop] = deepDestringify(objProp, stringified[prop]) // recursively call deepDestringify for nested objects
|
|
176
|
+
} else {
|
|
177
|
+
stringified[prop] = objProp
|
|
176
178
|
}
|
|
177
179
|
}
|
|
178
180
|
return stringified
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@domql/utils",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.77",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "index.js",
|
|
@@ -22,5 +22,5 @@
|
|
|
22
22
|
"@domql/globals": "latest",
|
|
23
23
|
"@domql/tags": "latest"
|
|
24
24
|
},
|
|
25
|
-
"gitHead": "
|
|
25
|
+
"gitHead": "eb59a416c2b22ef1cea1b6da0064805f8843a8de"
|
|
26
26
|
}
|