@domql/utils 2.5.187 → 3.0.0

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.
Files changed (64) hide show
  1. package/array.js +26 -13
  2. package/cache.js +4 -0
  3. package/component.js +10 -227
  4. package/cookie.js +27 -24
  5. package/dist/cjs/array.js +30 -16
  6. package/dist/cjs/cache.js +26 -0
  7. package/dist/cjs/component.js +16 -226
  8. package/dist/cjs/cookie.js +19 -24
  9. package/dist/cjs/element.js +137 -0
  10. package/dist/cjs/events.js +37 -0
  11. package/dist/cjs/extends.js +351 -0
  12. package/dist/cjs/function.js +2 -4
  13. package/dist/cjs/if.js +30 -0
  14. package/dist/cjs/index.js +25 -15
  15. package/dist/cjs/key.js +6 -1
  16. package/dist/cjs/keys.js +178 -0
  17. package/dist/cjs/log.js +1 -2
  18. package/dist/cjs/methods.js +305 -0
  19. package/dist/cjs/object.js +89 -237
  20. package/dist/cjs/props.js +220 -0
  21. package/dist/cjs/scope.js +28 -0
  22. package/dist/cjs/state.js +175 -0
  23. package/dist/cjs/string.js +27 -16
  24. package/dist/cjs/types.js +2 -4
  25. package/dist/cjs/update.js +42 -0
  26. package/dist/esm/array.js +30 -16
  27. package/dist/esm/cache.js +6 -0
  28. package/dist/esm/component.js +17 -245
  29. package/dist/esm/cookie.js +19 -24
  30. package/dist/esm/element.js +135 -0
  31. package/dist/esm/events.js +17 -0
  32. package/dist/esm/extends.js +349 -0
  33. package/dist/esm/function.js +2 -4
  34. package/dist/esm/if.js +10 -0
  35. package/dist/esm/index.js +10 -0
  36. package/dist/esm/key.js +6 -1
  37. package/dist/esm/keys.js +158 -0
  38. package/dist/esm/log.js +1 -2
  39. package/dist/esm/methods.js +285 -0
  40. package/dist/esm/object.js +90 -239
  41. package/dist/esm/props.js +216 -0
  42. package/dist/esm/scope.js +8 -0
  43. package/dist/esm/state.js +185 -0
  44. package/dist/esm/string.js +27 -16
  45. package/dist/esm/types.js +2 -4
  46. package/dist/esm/update.js +22 -0
  47. package/element.js +149 -0
  48. package/env.js +5 -2
  49. package/events.js +17 -0
  50. package/extends.js +425 -0
  51. package/if.js +14 -0
  52. package/index.js +10 -0
  53. package/key.js +6 -0
  54. package/keys.js +157 -0
  55. package/log.js +4 -1
  56. package/methods.js +315 -0
  57. package/node.js +21 -13
  58. package/object.js +121 -235
  59. package/package.json +3 -3
  60. package/props.js +249 -0
  61. package/scope.js +8 -0
  62. package/state.js +208 -0
  63. package/string.js +66 -30
  64. package/update.js +27 -0
package/object.js CHANGED
@@ -9,12 +9,12 @@ import {
9
9
  isString,
10
10
  is,
11
11
  isUndefined,
12
- isDate,
13
12
  isNull
14
13
  } from './types.js'
15
- import { mergeAndCloneIfArray, mergeArray } from './array.js'
14
+ import { unstackArrayOfObjects } from './array.js'
16
15
  import { stringIncludesAny } from './string.js'
17
16
  import { isDOMNode } from './node.js'
17
+ import { METHODS_EXL } from './keys.js'
18
18
 
19
19
  const ENV = process.env.NODE_ENV
20
20
 
@@ -30,6 +30,18 @@ export const exec = (param, element, state, context) => {
30
30
  return param
31
31
  }
32
32
 
33
+ export const execPromise = async (param, element, state, context) => {
34
+ if (isFunction(param)) {
35
+ return await param.call(
36
+ element,
37
+ element,
38
+ state || element.state,
39
+ context || element.context
40
+ )
41
+ }
42
+ return param
43
+ }
44
+
33
45
  export const map = (obj, extention, element) => {
34
46
  for (const e in extention) {
35
47
  obj[e] = exec(extention[e], element)
@@ -39,7 +51,9 @@ export const map = (obj, extention, element) => {
39
51
  export const merge = (element, obj, excludeFrom = []) => {
40
52
  for (const e in obj) {
41
53
  const hasOwnProperty = Object.prototype.hasOwnProperty.call(obj, e)
42
- if (!hasOwnProperty || excludeFrom.includes(e) || e.startsWith('__')) continue
54
+ if (!hasOwnProperty || excludeFrom.includes(e) || e.startsWith('__')) {
55
+ continue
56
+ }
43
57
  const elementProp = element[e]
44
58
  const objProp = obj[e]
45
59
  if (elementProp === undefined) {
@@ -49,10 +63,12 @@ export const merge = (element, obj, excludeFrom = []) => {
49
63
  return element
50
64
  }
51
65
 
52
- export const deepMerge = (element, extend, excludeFrom = []) => {
66
+ export const deepMerge = (element, extend, excludeFrom = METHODS_EXL) => {
53
67
  for (const e in extend) {
54
68
  const hasOwnProperty = Object.prototype.hasOwnProperty.call(extend, e)
55
- if (!hasOwnProperty || excludeFrom.includes(e) || e.startsWith('__')) continue
69
+ if (!hasOwnProperty || excludeFrom.includes(e) || e.startsWith('__')) {
70
+ continue
71
+ }
56
72
  const elementProp = element[e]
57
73
  const extendProp = extend[e]
58
74
  if (isObjectLike(elementProp) && isObjectLike(extendProp)) {
@@ -68,16 +84,18 @@ export const clone = (obj, excludeFrom = []) => {
68
84
  const o = {}
69
85
  for (const prop in obj) {
70
86
  const hasOwnProperty = Object.prototype.hasOwnProperty.call(obj, prop)
71
- if (!hasOwnProperty || excludeFrom.includes(prop) || prop.startsWith('__')) continue
87
+ if (
88
+ !hasOwnProperty ||
89
+ excludeFrom.includes(prop) ||
90
+ prop.startsWith('__')
91
+ ) {
92
+ continue
93
+ }
72
94
  o[prop] = obj[prop]
73
95
  }
74
96
  return o
75
97
  }
76
98
 
77
- // Merge array, but exclude keys listed in 'excl'z
78
- export const mergeArrayExclude = (arr, exclude = []) => {
79
- return arr.reduce((acc, curr) => deepMerge(acc, deepClone(curr, { exclude })), {})
80
- }
81
99
  /**
82
100
  * Enhanced deep clone function that combines features from multiple implementations
83
101
  * @param {any} obj - Object to clone
@@ -87,7 +105,7 @@ export const mergeArrayExclude = (arr, exclude = []) => {
87
105
  * @param {boolean} options.cleanNull - Remove null values
88
106
  * @param {Window} options.window - Window object for cross-frame cloning
89
107
  * @param {WeakMap} options.visited - WeakMap for tracking circular references
90
- * @param {boolean} options.handleExtend - Whether to handle 'extend' arrays specially
108
+ * @param {boolean} options.handleExtends - Whether to handle 'extends' arrays specially
91
109
  * @returns {any} Cloned object
92
110
  */
93
111
  export const deepClone = (obj, options = {}) => {
@@ -97,7 +115,7 @@ export const deepClone = (obj, options = {}) => {
97
115
  cleanNull = false,
98
116
  window: targetWindow,
99
117
  visited = new WeakMap(),
100
- handleExtend = false
118
+ handleExtends = false
101
119
  } = options
102
120
 
103
121
  // Handle non-object types and special cases
@@ -116,8 +134,8 @@ export const deepClone = (obj, options = {}) => {
116
134
  ? new targetWindow.Array()
117
135
  : new targetWindow.Object()
118
136
  : isArray(obj)
119
- ? []
120
- : {}
137
+ ? []
138
+ : {}
121
139
 
122
140
  // Store the clone to handle circular references
123
141
  visited.set(obj, clone)
@@ -127,12 +145,19 @@ export const deepClone = (obj, options = {}) => {
127
145
  if (!Object.prototype.hasOwnProperty.call(obj, key)) continue
128
146
 
129
147
  // Skip excluded properties
130
- if (exclude.includes(key) || key.startsWith('__') || key === '__proto__') continue
148
+ if (exclude.includes(key) || key.startsWith('__') || key === '__proto__') {
149
+ continue
150
+ }
131
151
 
132
152
  const value = obj[key]
133
153
 
134
154
  // Skip based on cleanup options
135
- if ((cleanUndefined && isUndefined(value)) || (cleanNull && isNull(value))) continue
155
+ if (
156
+ (cleanUndefined && isUndefined(value)) ||
157
+ (cleanNull && isNull(value))
158
+ ) {
159
+ continue
160
+ }
136
161
 
137
162
  // Handle special cases
138
163
  if (isDOMNode(value)) {
@@ -140,9 +165,9 @@ export const deepClone = (obj, options = {}) => {
140
165
  continue
141
166
  }
142
167
 
143
- // Handle 'extend' array if enabled
144
- if (handleExtend && key === 'extend' && isArray(value)) {
145
- clone[key] = mergeArray(value, exclude)
168
+ // Handle 'extends' array if enabled
169
+ if (handleExtends && key === 'extends' && isArray(value)) {
170
+ clone[key] = unstackArrayOfObjects(value, exclude)
146
171
  continue
147
172
  }
148
173
 
@@ -171,7 +196,10 @@ export const deepClone = (obj, options = {}) => {
171
196
  */
172
197
  export const deepStringify = (obj, stringified = {}) => {
173
198
  if (obj.node || obj.__ref || obj.parent || obj.__element || obj.parse) {
174
- (obj.__element || obj.parent?.__element).warn('Trying to clone element or state at', obj)
199
+ ;(obj.__element || obj.parent?.__element).warn(
200
+ 'Trying to clone element or state at',
201
+ obj
202
+ )
175
203
  obj = obj.parse?.()
176
204
  }
177
205
 
@@ -201,42 +229,6 @@ export const deepStringify = (obj, stringified = {}) => {
201
229
  return stringified
202
230
  }
203
231
 
204
- const MAX_DEPTH = 100 // Adjust this value as needed
205
- export const deepStringifyWithMaxDepth = (obj, stringified = {}, depth = 0, path = '') => {
206
- if (depth > MAX_DEPTH) {
207
- console.warn(`Maximum depth exceeded at path: ${path}. Possible circular reference.`)
208
- return '[MAX_DEPTH_EXCEEDED]'
209
- }
210
-
211
- for (const prop in obj) {
212
- const currentPath = path ? `${path}.${prop}` : prop
213
- const objProp = obj[prop]
214
-
215
- if (isFunction(objProp)) {
216
- stringified[prop] = objProp.toString()
217
- } else if (isObject(objProp)) {
218
- stringified[prop] = {}
219
- deepStringifyWithMaxDepth(objProp, stringified[prop], depth + 1, currentPath)
220
- } else if (isArray(objProp)) {
221
- stringified[prop] = []
222
- objProp.forEach((v, i) => {
223
- const itemPath = `${currentPath}[${i}]`
224
- if (isObject(v)) {
225
- stringified[prop][i] = {}
226
- deepStringifyWithMaxDepth(v, stringified[prop][i], depth + 1, itemPath)
227
- } else if (isFunction(v)) {
228
- stringified[prop][i] = v.toString()
229
- } else {
230
- stringified[prop][i] = v
231
- }
232
- })
233
- } else {
234
- stringified[prop] = objProp
235
- }
236
- }
237
- return stringified
238
- }
239
-
240
232
  export const objectToString = (obj = {}, indent = 0) => {
241
233
  // Handle empty object case
242
234
  if (obj === null || typeof obj !== 'object') {
@@ -252,7 +244,22 @@ export const objectToString = (obj = {}, indent = 0) => {
252
244
  let str = '{\n'
253
245
 
254
246
  for (const [key, value] of Object.entries(obj)) {
255
- const keyNotAllowdChars = stringIncludesAny(key, ['&', '*', '-', ':', '%', '{', '}', '>', '<', '@', '.', '/', '!', ' '])
247
+ const keyNotAllowdChars = stringIncludesAny(key, [
248
+ '&',
249
+ '*',
250
+ '-',
251
+ ':',
252
+ '%',
253
+ '{',
254
+ '}',
255
+ '>',
256
+ '<',
257
+ '@',
258
+ '.',
259
+ '/',
260
+ '!',
261
+ ' '
262
+ ])
256
263
  const stringedKey = keyNotAllowdChars ? `'${key}'` : key
257
264
  str += `${spaces} ${stringedKey}: `
258
265
 
@@ -271,7 +278,9 @@ export const objectToString = (obj = {}, indent = 0) => {
271
278
  } else if (isObjectLike(value)) {
272
279
  str += objectToString(value, indent + 1)
273
280
  } else if (isString(value)) {
274
- str += stringIncludesAny(value, ['\n', '\'']) ? `\`${value}\`` : `'${value}'`
281
+ str += stringIncludesAny(value, ['\n', "'"])
282
+ ? `\`${value}\``
283
+ : `'${value}'`
275
284
  } else {
276
285
  str += value
277
286
  }
@@ -283,35 +292,7 @@ export const objectToString = (obj = {}, indent = 0) => {
283
292
  return str
284
293
  }
285
294
 
286
- /**
287
- * Stringify object
288
- */
289
- export const detachFunctionsFromObject = (obj, detached = {}) => {
290
- for (const prop in obj) {
291
- const objProp = obj[prop]
292
- if (isFunction(objProp)) continue
293
- else if (isObject(objProp)) {
294
- detached[prop] = {}
295
- deepStringify(objProp, detached[prop])
296
- } else if (isArray(objProp)) {
297
- detached[prop] = []
298
- objProp.forEach((v, i) => {
299
- if (isFunction(v)) return
300
- if (isObject(v)) {
301
- detached[prop][i] = {}
302
- detachFunctionsFromObject(v, detached[prop][i])
303
- } else {
304
- detached[prop][i] = v
305
- }
306
- })
307
- } else {
308
- detached[prop] = objProp
309
- }
310
- }
311
- return detached
312
- }
313
-
314
- export const hasFunction = (str) => {
295
+ export const hasFunction = str => {
315
296
  if (!str) return false
316
297
 
317
298
  const trimmed = str.trim().replace(/\n\s*/g, ' ').trim()
@@ -357,7 +338,7 @@ export const deepDestringify = (obj, destringified = {}) => {
357
338
  }
358
339
  } else if (isArray(objProp)) {
359
340
  destringified[prop] = []
360
- objProp.forEach((arrProp) => {
341
+ objProp.forEach(arrProp => {
361
342
  if (isString(arrProp)) {
362
343
  if (hasFunction(arrProp)) {
363
344
  try {
@@ -387,123 +368,34 @@ export const deepDestringify = (obj, destringified = {}) => {
387
368
  export const stringToObject = (str, opts = { verbose: true }) => {
388
369
  try {
389
370
  return str ? window.eval('(' + str + ')') : {} // eslint-disable-line
390
- } catch (e) { if (opts.verbose) console.warn(e) }
391
- }
392
-
393
- export const diffObjects = (original, objToDiff, cache) => {
394
- for (const e in objToDiff) {
395
- if (e === 'ref') continue
396
-
397
- const originalProp = original[e]
398
- const objToDiffProp = objToDiff[e]
399
-
400
- if (isObject(originalProp) && isObject(objToDiffProp)) {
401
- cache[e] = {}
402
- diff(originalProp, objToDiffProp, cache[e])
403
- } else if (objToDiffProp !== undefined) {
404
- cache[e] = objToDiffProp
405
- }
406
- }
407
- return cache
408
- }
409
-
410
- export const diffArrays = (original, objToDiff, cache) => {
411
- if (original.length !== objToDiff.length) {
412
- cache = objToDiff
413
- } else {
414
- const diffArr = []
415
- for (let i = 0; i < original.length; i++) {
416
- const diffObj = diff(original[i], objToDiff[i])
417
- if (Object.keys(diffObj).length > 0) {
418
- diffArr.push(diffObj)
419
- }
420
- }
421
- if (diffArr.length > 0) {
422
- cache = diffArr
423
- }
424
- }
425
- return cache
426
- }
427
-
428
- export const diff = (original, objToDiff, cache = {}) => {
429
- if (isArray(original) && isArray(objToDiff)) {
430
- cache = []
431
- diffArrays(original, objToDiff, cache)
432
- } else {
433
- diffObjects(original, objToDiff, cache)
371
+ } catch (e) {
372
+ if (opts.verbose) console.warn(e)
434
373
  }
435
-
436
- return cache
437
374
  }
438
375
 
439
- export const hasOwnProperty = (o, ...args) => Object.prototype.hasOwnProperty.call(o, ...args)
376
+ export const hasOwnProperty = (o, ...args) =>
377
+ Object.prototype.hasOwnProperty.call(o, ...args)
440
378
 
441
379
  export const isEmpty = o => Object.keys(o).length === 0
442
380
 
443
- export const isEmptyObject = (o) => isObject(o) && isEmpty(o)
381
+ export const isEmptyObject = o => isObject(o) && isEmpty(o)
444
382
 
445
383
  export const makeObjectWithoutPrototype = () => Object.create(null)
446
384
 
447
- // by mattphillips
448
- // https://github.com/mattphillips/deep-object-diff/blob/main/src/diff.js
449
- export const deepDiff = (lhs, rhs) => {
450
- if (lhs === rhs) return {}
451
-
452
- if (!isObjectLike(lhs) || !isObjectLike(rhs)) return rhs
453
-
454
- const deletedValues = Object.keys(lhs).reduce((acc, key) => {
455
- if (!hasOwnProperty(rhs, key)) {
456
- acc[key] = undefined
457
- }
458
-
459
- return acc
460
- }, makeObjectWithoutPrototype())
461
-
462
- if (isDate(lhs) || isDate(rhs)) {
463
- if (lhs.valueOf() === rhs.valueOf()) return {}
464
- return rhs
465
- }
466
-
467
- return Object.keys(rhs).reduce((acc, key) => {
468
- if (!hasOwnProperty(lhs, key)) {
469
- acc[key] = rhs[key]
470
- return acc
471
- }
472
-
473
- const difference = diff(lhs[key], rhs[key])
474
-
475
- if (isEmptyObject(difference) && !isDate(difference) && (isEmptyObject(lhs[key]) || !isEmptyObject(rhs[key]))) {
476
- return acc
477
- }
478
-
479
- acc[key] = difference
480
- return acc
481
- }, deletedValues)
482
- }
483
-
484
385
  /**
485
386
  * Overwrites object properties with another
486
387
  */
487
388
  export const overwrite = (element, params, opts = {}) => {
488
- const { __ref: ref } = element
489
389
  const excl = opts.exclude || []
490
390
  const allowUnderscore = opts.preventUnderscore
491
- const preventCaching = opts.preventCaching
492
391
 
493
392
  for (const e in params) {
494
393
  if (excl.includes(e) || (!allowUnderscore && e.startsWith('__'))) continue
495
394
 
496
- const elementProp = element[e]
497
395
  const paramsProp = params[e]
498
396
 
499
397
  if (paramsProp !== undefined) {
500
398
  element[e] = paramsProp
501
- if (ref && !preventCaching) {
502
- ref.__cache[e] = elementProp
503
- }
504
- if (isObject(opts.diff)) {
505
- diff[e] = elementProp
506
- }
507
399
  }
508
400
  }
509
401
 
@@ -521,11 +413,21 @@ export const overwriteShallow = (obj, params, excludeFrom = []) => {
521
413
  /**
522
414
  * Overwrites DEEPLY object properties with another
523
415
  */
524
- export const overwriteDeep = (obj, params, opts = {}, visited = new WeakMap()) => {
416
+ export const overwriteDeep = (
417
+ obj,
418
+ params,
419
+ opts = {},
420
+ visited = new WeakMap()
421
+ ) => {
525
422
  const excl = opts.exclude || []
526
423
  const forcedExclude = opts.preventForce ? [] : ['node', 'window']
527
424
 
528
- if (!isObjectLike(obj) || !isObjectLike(params) || isDOMNode(obj) || isDOMNode(params)) {
425
+ if (
426
+ !isObjectLike(obj) ||
427
+ !isObjectLike(params) ||
428
+ isDOMNode(obj) ||
429
+ isDOMNode(params)
430
+ ) {
529
431
  return params
530
432
  }
531
433
 
@@ -551,29 +453,6 @@ export const overwriteDeep = (obj, params, opts = {}, visited = new WeakMap()) =
551
453
  return obj
552
454
  }
553
455
 
554
- /**
555
- * Overwrites object properties with another
556
- */
557
- export const mergeIfExisted = (a, b) => {
558
- if (isObjectLike(a) && isObjectLike(b)) return deepMerge(a, b)
559
- return a || b
560
- }
561
-
562
- /**
563
- * Overwrites object properties with another
564
- */
565
- export const flattenRecursive = (param, prop, stack = []) => {
566
- const objectized = mergeAndCloneIfArray(param)
567
- stack.push(objectized)
568
-
569
- const extendOfExtend = objectized[prop]
570
- if (extendOfExtend) flattenRecursive(extendOfExtend, prop, stack)
571
-
572
- delete objectized[prop]
573
-
574
- return stack
575
- }
576
-
577
456
  /**
578
457
  * Recursively compares two values to determine if they are deeply equal.
579
458
  *
@@ -610,7 +489,12 @@ export const flattenRecursive = (param, prop, stack = []) => {
610
489
  */
611
490
  export const isEqualDeep = (param, element, visited = new Set()) => {
612
491
  // Check if both values are non-null objects
613
- if (typeof param !== 'object' || typeof element !== 'object' || param === null || element === null) {
492
+ if (
493
+ typeof param !== 'object' ||
494
+ typeof element !== 'object' ||
495
+ param === null ||
496
+ element === null
497
+ ) {
614
498
  return param === element // Compare non-object values directly
615
499
  }
616
500
 
@@ -650,42 +534,39 @@ export const isEqualDeep = (param, element, visited = new Set()) => {
650
534
 
651
535
  export const deepContains = (obj1, obj2, ignoredKeys = ['node', '__ref']) => {
652
536
  if (obj1 === obj2) return true
653
- if (!isObjectLike(obj1) || !isObjectLike(obj2)) return false
537
+ if (!isObjectLike(obj1) || !isObjectLike(obj2)) return obj1 === obj2
654
538
  if (isDOMNode(obj1) || isDOMNode(obj2)) return obj1 === obj2
655
539
 
656
- const stack = [[obj1, obj2]]
657
540
  const visited = new WeakSet()
658
541
 
659
- while (stack.length > 0) {
660
- const [current1, current2] = stack.pop()
661
-
662
- if (visited.has(current1)) continue
663
- visited.add(current1)
542
+ function checkContains (target, source) {
543
+ if (visited.has(source)) return true
544
+ visited.add(source)
664
545
 
665
- const keys1 = Object.keys(current1).filter(key => !ignoredKeys.includes(key))
666
- const keys2 = Object.keys(current2).filter(key => !ignoredKeys.includes(key))
546
+ // Check each property in source
547
+ for (const key in source) {
548
+ if (!Object.prototype.hasOwnProperty.call(source, key)) continue
549
+ if (ignoredKeys.includes(key)) continue
667
550
 
668
- if (keys1.length !== keys2.length) return false
551
+ // If key doesn't exist in target, return false
552
+ if (!Object.prototype.hasOwnProperty.call(target, key)) return false
669
553
 
670
- for (const key of keys1) {
671
- if (!Object.prototype.hasOwnProperty.call(current2, key)) return false
554
+ const sourceValue = source[key]
555
+ const targetValue = target[key]
672
556
 
673
- const value1 = current1[key]
674
- const value2 = current2[key]
675
-
676
- if (isDOMNode(value1) || isDOMNode(value2)) {
677
- if (value1 !== value2) return false
678
- } else if (isObjectLike(value1) && isObjectLike(value2)) {
679
- if (value1 !== value2) {
680
- stack.push([value1, value2])
681
- }
682
- } else if (value1 !== value2) {
557
+ if (isDOMNode(sourceValue) || isDOMNode(targetValue)) {
558
+ if (sourceValue !== targetValue) return false
559
+ } else if (isObjectLike(sourceValue) && isObjectLike(targetValue)) {
560
+ if (!checkContains(targetValue, sourceValue)) return false
561
+ } else if (sourceValue !== targetValue) {
683
562
  return false
684
563
  }
685
564
  }
565
+
566
+ return true
686
567
  }
687
568
 
688
- return true
569
+ return checkContains(obj1, obj2)
689
570
  }
690
571
 
691
572
  export const removeFromObject = (obj, props) => {
@@ -695,12 +576,14 @@ export const removeFromObject = (obj, props) => {
695
576
  } else if (isArray(props)) {
696
577
  props.forEach(prop => delete obj[prop])
697
578
  } else {
698
- throw new Error('Invalid input: props must be a string or an array of strings')
579
+ throw new Error(
580
+ 'Invalid input: props must be a string or an array of strings'
581
+ )
699
582
  }
700
583
  return obj
701
584
  }
702
585
 
703
- export const createObjectWithoutPrototype = (obj) => {
586
+ export const createObjectWithoutPrototype = obj => {
704
587
  if (obj === null || typeof obj !== 'object') {
705
588
  return obj // Return the value if obj is not an object
706
589
  }
@@ -816,7 +699,10 @@ export const detectInfiniteLoop = arr => {
816
699
  // If the pattern repeats more than `maxRepeats`, throw a warning
817
700
  if (repeatCount >= maxRepeats * 2) {
818
701
  if (ENV === 'test' || ENV === 'development') {
819
- console.warn('Warning: Potential infinite loop detected due to repeated sequence:', pattern)
702
+ console.warn(
703
+ 'Warning: Potential infinite loop detected due to repeated sequence:',
704
+ pattern
705
+ )
820
706
  }
821
707
  return true
822
708
  }
@@ -824,7 +710,7 @@ export const detectInfiniteLoop = arr => {
824
710
  }
825
711
  }
826
712
 
827
- export const isCyclic = (obj) => {
713
+ export const isCyclic = obj => {
828
714
  const seenObjects = []
829
715
 
830
716
  function detect (obj) {
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@domql/utils",
3
- "version": "2.5.187",
3
+ "version": "3.0.0",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "module": "index.js",
7
7
  "main": "index.js",
8
8
  "exports": {
9
9
  ".": {
10
- "default": "./dist/esm/index.js",
10
+ "default": "./index.js",
11
11
  "import": "./dist/esm/index.js",
12
12
  "require": "./dist/cjs/index.js"
13
13
  }
@@ -24,7 +24,7 @@
24
24
  "build": "rimraf -I dist; npm run build:cjs; npm run build:esm",
25
25
  "prepublish": "npm run build; npm run copy:package:cjs"
26
26
  },
27
- "gitHead": "c150bfbbdd51b19d25c93f10334d54175cea9d1d",
27
+ "gitHead": "bcbdc271a602b958de6a60ab387ea7715a935dc1",
28
28
  "devDependencies": {
29
29
  "@babel/core": "^7.12.0"
30
30
  }