@stemy/ngx-utils 12.2.0 → 12.2.3
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/bundles/stemy-ngx-utils.umd.js +45 -26
- package/bundles/stemy-ngx-utils.umd.js.map +1 -1
- package/esm2015/ngx-utils/utils/file-system.js +6 -1
- package/esm2015/ngx-utils/utils/math.utils.js +3 -2
- package/esm2015/ngx-utils/utils/object.utils.js +36 -25
- package/fesm2015/stemy-ngx-utils.js +43 -26
- package/fesm2015/stemy-ngx-utils.js.map +1 -1
- package/ngx-utils/utils/math.utils.d.ts +1 -0
- package/ngx-utils/utils/object.utils.d.ts +1 -1
- package/package.json +1 -1
- package/stemy-ngx-utils.metadata.json +1 -1
|
@@ -349,7 +349,11 @@
|
|
|
349
349
|
Object.getOwnPropertyNames(obj).forEach(function (p) { return props.add(p); });
|
|
350
350
|
return Array.from(props);
|
|
351
351
|
};
|
|
352
|
-
ObjectUtils.equals = function (a, b) {
|
|
352
|
+
ObjectUtils.equals = function (a, b, visited) {
|
|
353
|
+
if (visited === void 0) { visited = null; }
|
|
354
|
+
visited = visited || new Set();
|
|
355
|
+
if (visited.has(a) && visited.has(b))
|
|
356
|
+
return true;
|
|
353
357
|
if (a === b)
|
|
354
358
|
return true;
|
|
355
359
|
if (a === null || b === null)
|
|
@@ -359,12 +363,14 @@
|
|
|
359
363
|
var at = typeof a, bt = typeof b;
|
|
360
364
|
var length, key, keySet;
|
|
361
365
|
if (at == bt && at == "object") {
|
|
366
|
+
visited.add(a);
|
|
367
|
+
visited.add(b);
|
|
362
368
|
if (Array.isArray(a)) {
|
|
363
369
|
if (!Array.isArray(b))
|
|
364
370
|
return false;
|
|
365
371
|
if ((length = a.length) == b.length) {
|
|
366
372
|
for (key = 0; key < length; key++) {
|
|
367
|
-
if (!ObjectUtils.equals(a[key], b[key]))
|
|
373
|
+
if (!ObjectUtils.equals(a[key], b[key], visited))
|
|
368
374
|
return false;
|
|
369
375
|
}
|
|
370
376
|
return true;
|
|
@@ -377,7 +383,7 @@
|
|
|
377
383
|
keySet = Object.create(null);
|
|
378
384
|
for (key in a) {
|
|
379
385
|
if (a.hasOwnProperty(key)) {
|
|
380
|
-
if (!ObjectUtils.equals(a[key], b[key])) {
|
|
386
|
+
if (!ObjectUtils.equals(a[key], b[key], visited)) {
|
|
381
387
|
return false;
|
|
382
388
|
}
|
|
383
389
|
keySet[key] = true;
|
|
@@ -474,13 +480,13 @@
|
|
|
474
480
|
return isNaN(key) || isArray ? target : Object.values(target);
|
|
475
481
|
};
|
|
476
482
|
ObjectUtils.filter = function (obj, predicate) {
|
|
477
|
-
return ObjectUtils.copyRecursive(null, obj, predicate);
|
|
483
|
+
return ObjectUtils.copyRecursive(null, obj, predicate, new Map());
|
|
478
484
|
};
|
|
479
485
|
ObjectUtils.copy = function (obj) {
|
|
480
|
-
return ObjectUtils.copyRecursive(null, obj);
|
|
486
|
+
return ObjectUtils.copyRecursive(null, obj, null, new Map());
|
|
481
487
|
};
|
|
482
488
|
ObjectUtils.assign = function (target, source, predicate) {
|
|
483
|
-
return ObjectUtils.copyRecursive(target, source, predicate);
|
|
489
|
+
return ObjectUtils.copyRecursive(target, source, predicate, new Map());
|
|
484
490
|
};
|
|
485
491
|
ObjectUtils.getType = function (obj) {
|
|
486
492
|
var regex = new RegExp("\\s([a-zA-Z]+)");
|
|
@@ -567,28 +573,34 @@
|
|
|
567
573
|
var str = ObjectUtils.isDefined(obj) ? obj.toString() : "";
|
|
568
574
|
return str.length >= width ? str : new Array(width - str.length + 1).join(chr) + str;
|
|
569
575
|
};
|
|
570
|
-
ObjectUtils.copyRecursive = function (target, source, predicate) {
|
|
576
|
+
ObjectUtils.copyRecursive = function (target, source, predicate, copies) {
|
|
571
577
|
predicate = predicate || defaultPredicate;
|
|
572
578
|
if (ObjectUtils.isPrimitive(source) || ObjectUtils.isDate(source) || ObjectUtils.isBlob(source) || ObjectUtils.isFunction(source))
|
|
573
579
|
return source;
|
|
574
|
-
if (
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
580
|
+
if (!copies.has(source)) {
|
|
581
|
+
if (ObjectUtils.isArray(source)) {
|
|
582
|
+
target = ObjectUtils.isArray(target) ? Array.from(target) : [];
|
|
583
|
+
copies.set(source, target);
|
|
584
|
+
source.forEach(function (item, index) {
|
|
585
|
+
if (!predicate(item, index, target, source))
|
|
586
|
+
return;
|
|
587
|
+
if (target.length > index)
|
|
588
|
+
target[index] = ObjectUtils.copyRecursive(target[index], item, predicate, copies);
|
|
589
|
+
else
|
|
590
|
+
target.push(ObjectUtils.copyRecursive(null, item, predicate, copies));
|
|
591
|
+
});
|
|
592
|
+
}
|
|
593
|
+
else {
|
|
594
|
+
target = Object.assign({}, target);
|
|
595
|
+
copies.set(source, target);
|
|
596
|
+
Object.keys(source).forEach(function (key) {
|
|
597
|
+
if (!predicate(source[key], key, target, source))
|
|
598
|
+
return;
|
|
599
|
+
target[key] = ObjectUtils.copyRecursive(target[key], source[key], predicate, copies);
|
|
600
|
+
});
|
|
601
|
+
}
|
|
585
602
|
}
|
|
586
|
-
return
|
|
587
|
-
if (!predicate(source[key], key, result, source))
|
|
588
|
-
return result;
|
|
589
|
-
result[key] = ObjectUtils.copyRecursive(result[key], source[key], predicate);
|
|
590
|
-
return result;
|
|
591
|
-
}, Object.assign({}, target));
|
|
603
|
+
return copies.get(source);
|
|
592
604
|
};
|
|
593
605
|
return ObjectUtils;
|
|
594
606
|
}());
|
|
@@ -1407,7 +1419,13 @@
|
|
|
1407
1419
|
.concat(["level-" + this.level]);
|
|
1408
1420
|
}
|
|
1409
1421
|
FileSystemEntry.prototype.open = function () {
|
|
1422
|
+
var _this = this;
|
|
1410
1423
|
this.result = this.result || this.openCb(this.data, this);
|
|
1424
|
+
this.result.then(function (res) {
|
|
1425
|
+
if (Array.isArray(res))
|
|
1426
|
+
return;
|
|
1427
|
+
_this.result = null;
|
|
1428
|
+
});
|
|
1411
1429
|
return this.result;
|
|
1412
1430
|
};
|
|
1413
1431
|
return FileSystemEntry;
|
|
@@ -1690,7 +1708,7 @@
|
|
|
1690
1708
|
}
|
|
1691
1709
|
MathUtils.equal = function (a, b, epsilon) {
|
|
1692
1710
|
if (epsilon === void 0) { epsilon = null; }
|
|
1693
|
-
epsilon = ObjectUtils.isNumber(epsilon) ? epsilon :
|
|
1711
|
+
epsilon = ObjectUtils.isNumber(epsilon) ? epsilon : MathUtils.EPSILON;
|
|
1694
1712
|
return Math.abs(a - b) < epsilon;
|
|
1695
1713
|
};
|
|
1696
1714
|
MathUtils.clamp = function (value, min, max) {
|
|
@@ -1734,7 +1752,8 @@
|
|
|
1734
1752
|
return (_a = values[index]) !== null && _a !== void 0 ? _a : null;
|
|
1735
1753
|
};
|
|
1736
1754
|
return MathUtils;
|
|
1737
|
-
}());
|
|
1755
|
+
}());
|
|
1756
|
+
MathUtils.EPSILON = 1e-9;
|
|
1738
1757
|
|
|
1739
1758
|
/**
|
|
1740
1759
|
* Use this service to determine which is the current environment
|