@domql/utils 2.5.143 → 2.5.144

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.
@@ -38,6 +38,7 @@ __export(object_exports, {
38
38
  exec: () => exec,
39
39
  flattenRecursive: () => flattenRecursive,
40
40
  hasOwnProperty: () => hasOwnProperty,
41
+ isCyclic: () => isCyclic,
41
42
  isEmpty: () => isEmpty,
42
43
  isEmptyObject: () => isEmptyObject,
43
44
  isEqualDeep: () => isEqualDeep,
@@ -643,3 +644,22 @@ const detectInfiniteLoop = (arr) => {
643
644
  }
644
645
  }
645
646
  };
647
+ const isCyclic = (obj) => {
648
+ const seenObjects = [];
649
+ function detect(obj2) {
650
+ if (obj2 && typeof obj2 === "object") {
651
+ if (seenObjects.indexOf(obj2) !== -1) {
652
+ return true;
653
+ }
654
+ seenObjects.push(obj2);
655
+ for (const key in obj2) {
656
+ if (Object.hasOwnProperty.call(obj2, key) && detect(obj2[key])) {
657
+ console.log(obj2, "cycle at " + key);
658
+ return true;
659
+ }
660
+ }
661
+ }
662
+ return false;
663
+ }
664
+ return detect(obj);
665
+ };
package/object.js CHANGED
@@ -795,3 +795,25 @@ export const detectInfiniteLoop = arr => {
795
795
  }
796
796
  }
797
797
  }
798
+
799
+ export const isCyclic = (obj) => {
800
+ const seenObjects = []
801
+
802
+ function detect (obj) {
803
+ if (obj && typeof obj === 'object') {
804
+ if (seenObjects.indexOf(obj) !== -1) {
805
+ return true
806
+ }
807
+ seenObjects.push(obj)
808
+ for (const key in obj) {
809
+ if (Object.hasOwnProperty.call(obj, key) && detect(obj[key])) {
810
+ console.log(obj, 'cycle at ' + key)
811
+ return true
812
+ }
813
+ }
814
+ }
815
+ return false
816
+ }
817
+
818
+ return detect(obj)
819
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@domql/utils",
3
- "version": "2.5.143",
3
+ "version": "2.5.144",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "module": "index.js",
@@ -25,7 +25,7 @@
25
25
  "build": "yarn build:cjs",
26
26
  "prepublish": "rimraf -I dist && yarn build && yarn copy:package:cjs"
27
27
  },
28
- "gitHead": "46440d5034244c18657bf272df1bdc3e8ff666c5",
28
+ "gitHead": "9026efab1932521ec5eec3e88261eadb81f2e3cb",
29
29
  "devDependencies": {
30
30
  "@babel/core": "^7.12.0"
31
31
  }