@domql/utils 2.5.13 → 2.5.14
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 +28 -0
- package/object.js +30 -0
- package/package.json +2 -2
package/dist/cjs/object.js
CHANGED
|
@@ -21,6 +21,7 @@ __export(object_exports, {
|
|
|
21
21
|
clone: () => clone,
|
|
22
22
|
deepClone: () => deepClone,
|
|
23
23
|
deepCloneExclude: () => deepCloneExclude,
|
|
24
|
+
deepContains: () => deepContains,
|
|
24
25
|
deepDestringify: () => deepDestringify,
|
|
25
26
|
deepMerge: () => deepMerge,
|
|
26
27
|
deepStringify: () => deepStringify,
|
|
@@ -406,6 +407,33 @@ const isEqualDeep = (param, element, visited = /* @__PURE__ */ new Set()) => {
|
|
|
406
407
|
}
|
|
407
408
|
return true;
|
|
408
409
|
};
|
|
410
|
+
const deepContains = (obj1, obj2) => {
|
|
411
|
+
if (typeof obj1 !== typeof obj2) {
|
|
412
|
+
return false;
|
|
413
|
+
}
|
|
414
|
+
if ((0, import_types.isObjectLike)(obj1)) {
|
|
415
|
+
if (Array.isArray(obj1) && Array.isArray(obj2)) {
|
|
416
|
+
if (obj1.length !== obj2.length) {
|
|
417
|
+
return false;
|
|
418
|
+
}
|
|
419
|
+
for (let i = 0; i < obj1.length; i++) {
|
|
420
|
+
if (!deepContains(obj1[i], obj2[i])) {
|
|
421
|
+
return false;
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
} else if ((0, import_types.isObjectLike)(obj1) && obj2 !== null) {
|
|
425
|
+
for (const key in obj1) {
|
|
426
|
+
const hasOwnProperty = Object.prototype.hasOwnProperty.call(obj2, key);
|
|
427
|
+
if (!hasOwnProperty || !deepContains(obj1[key], obj2[key])) {
|
|
428
|
+
return false;
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
} else {
|
|
433
|
+
return obj2 === obj1;
|
|
434
|
+
}
|
|
435
|
+
return true;
|
|
436
|
+
};
|
|
409
437
|
const removeFromObject = (obj, props) => {
|
|
410
438
|
if (props === void 0 || props === null)
|
|
411
439
|
return obj;
|
package/object.js
CHANGED
|
@@ -449,6 +449,36 @@ export const isEqualDeep = (param, element, visited = new Set()) => {
|
|
|
449
449
|
return true
|
|
450
450
|
}
|
|
451
451
|
|
|
452
|
+
export const deepContains = (obj1, obj2) => {
|
|
453
|
+
if (typeof obj1 !== typeof obj2) {
|
|
454
|
+
return false
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
if (isObjectLike(obj1)) {
|
|
458
|
+
if (Array.isArray(obj1) && Array.isArray(obj2)) {
|
|
459
|
+
if (obj1.length !== obj2.length) {
|
|
460
|
+
return false
|
|
461
|
+
}
|
|
462
|
+
for (let i = 0; i < obj1.length; i++) {
|
|
463
|
+
if (!deepContains(obj1[i], obj2[i])) {
|
|
464
|
+
return false
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
} else if (isObjectLike(obj1) && obj2 !== null) {
|
|
468
|
+
for (const key in obj1) {
|
|
469
|
+
const hasOwnProperty = Object.prototype.hasOwnProperty.call(obj2, key)
|
|
470
|
+
if (!hasOwnProperty || !deepContains(obj1[key], obj2[key])) {
|
|
471
|
+
return false
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
} else {
|
|
476
|
+
return obj2 === obj1
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
return true
|
|
480
|
+
}
|
|
481
|
+
|
|
452
482
|
export const removeFromObject = (obj, props) => {
|
|
453
483
|
if (props === undefined || props === null) return obj
|
|
454
484
|
if (is(props)('string', 'number')) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@domql/utils",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.14",
|
|
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": "
|
|
26
|
+
"gitHead": "ab852cb3a435b154f6b32a9a664f65ec56a9c49f",
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@babel/core": "^7.12.0"
|
|
29
29
|
}
|