@domql/utils 2.5.112 → 2.5.114

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.
@@ -468,29 +468,35 @@ const isEqualDeep = (param, element, visited = /* @__PURE__ */ new Set()) => {
468
468
  return true;
469
469
  };
470
470
  const deepContains = (obj1, obj2) => {
471
- if (typeof obj1 !== typeof obj2) {
472
- return false;
473
- }
474
- if ((0, import_types.isObjectLike)(obj1)) {
475
- if (Array.isArray(obj1) && Array.isArray(obj2)) {
476
- if (obj1.length !== obj2.length) {
477
- return false;
478
- }
479
- for (let i = 0; i < obj1.length; i++) {
480
- if (!deepContains(obj1[i], obj2[i])) {
471
+ const stack = [{ obj1, obj2 }];
472
+ while (stack.length) {
473
+ const { obj1: obj12, obj2: obj22 } = stack.pop();
474
+ if (typeof obj12 !== typeof obj22) {
475
+ return false;
476
+ }
477
+ if ((0, import_types.isObjectLike)(obj12)) {
478
+ if (Array.isArray(obj12) && Array.isArray(obj22)) {
479
+ if (obj12.length !== obj22.length) {
481
480
  return false;
482
481
  }
483
- }
484
- } else if ((0, import_types.isObjectLike)(obj1) && obj2 !== null) {
485
- for (const key in obj1) {
486
- const hasOwnProperty2 = Object.prototype.hasOwnProperty.call(obj2, key);
487
- if (!hasOwnProperty2 || !deepContains(obj1[key], obj2[key])) {
488
- return false;
482
+ for (let i = 0; i < obj12.length; i++) {
483
+ stack.push({ obj1: obj12[i], obj2: obj22[i] });
484
+ }
485
+ } else if ((0, import_types.isObjectLike)(obj12) && obj22 !== null) {
486
+ for (const key in obj12) {
487
+ if (Object.prototype.hasOwnProperty.call(obj12, key)) {
488
+ if (!Object.prototype.hasOwnProperty.call(obj22, key)) {
489
+ return false;
490
+ }
491
+ stack.push({ obj1: obj12[key], obj2: obj22[key] });
492
+ }
489
493
  }
490
494
  }
495
+ } else {
496
+ if (obj12 !== obj22) {
497
+ return false;
498
+ }
491
499
  }
492
- } else {
493
- return obj2 === obj1;
494
500
  }
495
501
  return true;
496
502
  };
@@ -20,6 +20,8 @@ var string_exports = {};
20
20
  __export(string_exports, {
21
21
  customDecodeURIComponent: () => customDecodeURIComponent,
22
22
  customEncodeURIComponent: () => customEncodeURIComponent,
23
+ decodeNewlines: () => decodeNewlines,
24
+ encodeNewlines: () => encodeNewlines,
23
25
  findKeyPosition: () => findKeyPosition,
24
26
  lowercaseFirstLetter: () => lowercaseFirstLetter,
25
27
  replaceLiteralsWithObjectFields: () => replaceLiteralsWithObjectFields,
@@ -123,6 +125,12 @@ const replaceOctalEscapeSequences = (str) => {
123
125
  return char;
124
126
  });
125
127
  };
128
+ const encodeNewlines = (str) => {
129
+ return str.split("\n").join("/////n").split("`").join("/////tilde").split("$").join("/////dlrsgn");
130
+ };
131
+ const decodeNewlines = (encodedStr) => {
132
+ return encodedStr.split("/////n").join("\n").split("/////tilde").join("`").split("/////dlrsgn").join("$");
133
+ };
126
134
  const customEncodeURIComponent = (str) => {
127
135
  return str.split("").map((char) => {
128
136
  if (/[^a-zA-Z0-9\s]/.test(char)) {
package/object.js CHANGED
@@ -539,30 +539,38 @@ export const isEqualDeep = (param, element, visited = new Set()) => {
539
539
  }
540
540
 
541
541
  export const deepContains = (obj1, obj2) => {
542
- if (typeof obj1 !== typeof obj2) {
543
- return false
544
- }
542
+ const stack = [{ obj1, obj2 }]
545
543
 
546
- if (isObjectLike(obj1)) {
547
- if (Array.isArray(obj1) && Array.isArray(obj2)) {
548
- if (obj1.length !== obj2.length) {
549
- return false
550
- }
551
- for (let i = 0; i < obj1.length; i++) {
552
- if (!deepContains(obj1[i], obj2[i])) {
544
+ while (stack.length) {
545
+ const { obj1, obj2 } = stack.pop()
546
+
547
+ if (typeof obj1 !== typeof obj2) {
548
+ return false
549
+ }
550
+
551
+ if (isObjectLike(obj1)) {
552
+ if (Array.isArray(obj1) && Array.isArray(obj2)) {
553
+ if (obj1.length !== obj2.length) {
553
554
  return false
554
555
  }
555
- }
556
- } else if (isObjectLike(obj1) && obj2 !== null) {
557
- for (const key in obj1) {
558
- const hasOwnProperty = Object.prototype.hasOwnProperty.call(obj2, key)
559
- if (!hasOwnProperty || !deepContains(obj1[key], obj2[key])) {
560
- return false
556
+ for (let i = 0; i < obj1.length; i++) {
557
+ stack.push({ obj1: obj1[i], obj2: obj2[i] })
558
+ }
559
+ } else if (isObjectLike(obj1) && obj2 !== null) {
560
+ for (const key in obj1) {
561
+ if (Object.prototype.hasOwnProperty.call(obj1, key)) {
562
+ if (!Object.prototype.hasOwnProperty.call(obj2, key)) {
563
+ return false
564
+ }
565
+ stack.push({ obj1: obj1[key], obj2: obj2[key] })
566
+ }
561
567
  }
562
568
  }
569
+ } else {
570
+ if (obj1 !== obj2) {
571
+ return false
572
+ }
563
573
  }
564
- } else {
565
- return obj2 === obj1
566
574
  }
567
575
 
568
576
  return true
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@domql/utils",
3
- "version": "2.5.112",
3
+ "version": "2.5.114",
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": "8a59640e77bcd22114bdf64dfa4945604b5bfd1f",
26
+ "gitHead": "61b7ecee05aaf0d6682e5f3cdb11f0091e880f3d",
27
27
  "devDependencies": {
28
28
  "@babel/core": "^7.12.0"
29
29
  }
package/string.js CHANGED
@@ -125,6 +125,14 @@ export const replaceOctalEscapeSequences = (str) => {
125
125
  })
126
126
  }
127
127
 
128
+ export const encodeNewlines = (str) => {
129
+ return str.split('\n').join('/////n').split('`').join('/////tilde').split('$').join('/////dlrsgn')
130
+ }
131
+
132
+ export const decodeNewlines = (encodedStr) => {
133
+ return encodedStr.split('/////n').join('\n').split('/////tilde').join('`').split('/////dlrsgn').join('$')
134
+ }
135
+
128
136
  export const customEncodeURIComponent = (str) => {
129
137
  return str.split('').map(char => {
130
138
  if (/[^a-zA-Z0-9\s]/.test(char)) {