@domql/utils 2.5.86 → 2.5.87

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.
@@ -209,10 +209,7 @@ const objectToString = (obj, indent = 0) => {
209
209
  str += `${spaces} ${objectToString(element, indent + 2)},
210
210
  `;
211
211
  } else if ((0, import_types.isString)(element)) {
212
- if (element.includes("\n"))
213
- str += spaces + " `" + element + "`,\n";
214
- else
215
- str += `${spaces} '${element}',
212
+ str += `${spaces} '${element}',
216
213
  `;
217
214
  } else {
218
215
  str += `${spaces} ${element},
@@ -265,7 +262,7 @@ const deepDestringify = (obj, destringified = {}) => {
265
262
  continue;
266
263
  const objProp = obj[prop];
267
264
  if ((0, import_types.isString)(objProp)) {
268
- if (objProp.includes("=>") || objProp.includes("function") || objProp.startsWith("(")) {
265
+ if ((objProp.includes("=>") || objProp.startsWith("function") || objProp.startsWith("(")) && !objProp.startsWith("{") && !objProp.startsWith("[")) {
269
266
  try {
270
267
  const evalProp = import_globals.window.eval(`(${objProp})`);
271
268
  destringified[prop] = evalProp;
package/object.js CHANGED
@@ -190,8 +190,8 @@ export const objectToString = (obj, indent = 0) => {
190
190
  if (isObject(element) && element !== null) {
191
191
  str += `${spaces} ${objectToString(element, indent + 2)},\n`
192
192
  } else if (isString(element)) {
193
- if (element.includes('\n')) str += spaces + ' ' + '`' + element + '`,\n'
194
- else str += `${spaces} '${element}',\n`
193
+ // if (element.includes('\n')) str += spaces + ' ' + '`' + element + '`,\n'
194
+ str += `${spaces} '${element}',\n`
195
195
  } else {
196
196
  str += `${spaces} ${element},\n`
197
197
  }
@@ -249,9 +249,9 @@ export const deepDestringify = (obj, destringified = {}) => {
249
249
  if (!hasOwnProperty) continue
250
250
  const objProp = obj[prop]
251
251
  if (isString(objProp)) {
252
- if (objProp.includes('=>') || objProp.includes('function') || objProp.startsWith('(')) {
252
+ if ((objProp.includes('=>') || objProp.startsWith('function') || objProp.startsWith('(')) && !objProp.startsWith('{') && !objProp.startsWith('[')) {
253
253
  try {
254
- const evalProp = window.eval(`(${objProp})`) // use parentheses to convert string to function expression
254
+ const evalProp = window.eval(`(${objProp})`)
255
255
  destringified[prop] = evalProp
256
256
  } catch (e) { if (e) destringified[prop] = objProp }
257
257
  } else {
@@ -276,7 +276,7 @@ export const deepDestringify = (obj, destringified = {}) => {
276
276
  }
277
277
  })
278
278
  } else if (isObject(objProp)) {
279
- destringified[prop] = deepDestringify(objProp, destringified[prop]) // recursively call deepDestringify for nested objects
279
+ destringified[prop] = deepDestringify(objProp, destringified[prop])
280
280
  } else {
281
281
  destringified[prop] = objProp
282
282
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@domql/utils",
3
- "version": "2.5.86",
3
+ "version": "2.5.87",
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": "6a593e77a9cdf6889175bf674ef60f90385b58df",
26
+ "gitHead": "59c3f0d7933a32ce68732e2eb448901d63fc0e82",
27
27
  "devDependencies": {
28
28
  "@babel/core": "^7.12.0"
29
29
  }