@stemy/ngx-utils 12.2.15 → 12.2.16

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.
@@ -317,8 +317,12 @@
317
317
  return value;
318
318
  }
319
319
 
320
- var defaultPredicate = function () { return true; };
321
- var ɵ0 = defaultPredicate;
320
+ function defaultPredicate(value, key, target, source) {
321
+ return true;
322
+ }
323
+ function shouldCopyDefault(key, value) {
324
+ return true;
325
+ }
322
326
  var hasBlob = typeof Blob !== "undefined" && !!Blob;
323
327
  var hasFile = typeof File !== "undefined" && !!File;
324
328
  var ObjectUtils = /** @class */ (function () {
@@ -484,13 +488,13 @@
484
488
  return isNaN(key) || isArray ? target : Object.values(target);
485
489
  };
486
490
  ObjectUtils.filter = function (obj, predicate) {
487
- return ObjectUtils.copyRecursive(null, obj, predicate, new Map());
491
+ return ObjectUtils.copyRecursive(null, obj, predicate || defaultPredicate, new Map());
488
492
  };
489
493
  ObjectUtils.copy = function (obj) {
490
- return ObjectUtils.copyRecursive(null, obj, null, new Map());
494
+ return ObjectUtils.copyRecursive(null, obj, defaultPredicate, new Map());
491
495
  };
492
496
  ObjectUtils.assign = function (target, source, predicate) {
493
- return ObjectUtils.copyRecursive(target, source, predicate, new Map());
497
+ return ObjectUtils.copyRecursive(target, source, predicate || defaultPredicate, new Map());
494
498
  };
495
499
  ObjectUtils.getType = function (obj) {
496
500
  var regex = new RegExp("\\s([a-zA-Z]+)");
@@ -541,6 +545,9 @@
541
545
  ObjectUtils.isSet = function (value) {
542
546
  return value instanceof Set;
543
547
  };
548
+ ObjectUtils.isConstructor = function (value) {
549
+ return (value && typeof value === "function" && value.prototype && value.prototype.constructor) === value && value.name !== "Object";
550
+ };
544
551
  ObjectUtils.checkInterface = function (obj, interFaceObject) {
545
552
  return ObjectUtils.isInterface(obj, interFaceObject);
546
553
  };
@@ -578,33 +585,102 @@
578
585
  return str.length >= width ? str : new Array(width - str.length + 1).join(chr) + str;
579
586
  };
580
587
  ObjectUtils.copyRecursive = function (target, source, predicate, copies) {
581
- predicate = predicate || defaultPredicate;
588
+ var e_2, _a, e_3, _b, e_4, _c;
582
589
  if (ObjectUtils.isPrimitive(source) || ObjectUtils.isDate(source) || ObjectUtils.isBlob(source) || ObjectUtils.isFunction(source))
583
590
  return source;
584
- if (!copies.has(source)) {
585
- if (ObjectUtils.isArray(source)) {
586
- target = ObjectUtils.isArray(target) ? Array.from(target) : [];
587
- copies.set(source, target);
588
- source.forEach(function (item, index) {
589
- if (!predicate(item, index, target, source))
590
- return;
591
- if (target.length > index)
592
- target[index] = ObjectUtils.copyRecursive(target[index], item, predicate, copies);
593
- else
594
- target.push(ObjectUtils.copyRecursive(null, item, predicate, copies));
595
- });
591
+ if (copies.has(source))
592
+ return copies.get(source);
593
+ if (ObjectUtils.isArray(source)) {
594
+ target = ObjectUtils.isArray(target) ? Array.from(target) : [];
595
+ copies.set(source, target);
596
+ for (var index = 0; index < source.length; index++) {
597
+ var item = source[index];
598
+ if (!predicate(item, index, target, source))
599
+ continue;
600
+ if (target.length > index)
601
+ target[index] = ObjectUtils.copyRecursive(target[index], item, predicate, copies);
602
+ else
603
+ target.push(ObjectUtils.copyRecursive(null, item, predicate, copies));
596
604
  }
597
- else {
598
- target = Object.assign({}, target);
599
- copies.set(source, target);
600
- Object.keys(source).forEach(function (key) {
601
- if (!predicate(source[key], key, target, source))
602
- return;
603
- target[key] = ObjectUtils.copyRecursive(target[key], source[key], predicate, copies);
604
- });
605
+ return target;
606
+ }
607
+ // If object defines __shouldCopy as false, then don't copy it
608
+ if (source.__shouldCopy === false)
609
+ return source;
610
+ // Copy object
611
+ var shouldCopy = ObjectUtils.isFunction(source.__shouldCopy) ? source.__shouldCopy : shouldCopyDefault;
612
+ if (ObjectUtils.isConstructor(source.constructor)) {
613
+ if (!target) {
614
+ try {
615
+ target = new source.constructor();
616
+ }
617
+ catch (e) {
618
+ var proto = source.constructor.prototype || source.prototype;
619
+ target = Object.create(proto);
620
+ }
621
+ }
622
+ }
623
+ else {
624
+ target = Object.assign({}, target || {});
625
+ }
626
+ // Set to copies to prevent circular references
627
+ copies.set(source, target);
628
+ // Copy map entries
629
+ if (target instanceof Map) {
630
+ if (source instanceof Map) {
631
+ try {
632
+ for (var _d = __values(source.entries()), _e = _d.next(); !_e.done; _e = _d.next()) {
633
+ var _f = __read(_e.value, 2), key = _f[0], value = _f[1];
634
+ if (!predicate(value, key, target, source))
635
+ continue;
636
+ target.set(key, !shouldCopy(key, value) ? value : ObjectUtils.copyRecursive(target.get(key), value, predicate, copies));
637
+ }
638
+ }
639
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
640
+ finally {
641
+ try {
642
+ if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
643
+ }
644
+ finally { if (e_2) throw e_2.error; }
645
+ }
646
+ }
647
+ return target;
648
+ }
649
+ // Copy object members
650
+ var keys = Object.keys(source);
651
+ try {
652
+ for (var keys_2 = __values(keys), keys_2_1 = keys_2.next(); !keys_2_1.done; keys_2_1 = keys_2.next()) {
653
+ var key = keys_2_1.value;
654
+ if (!predicate(source[key], key, target, source))
655
+ continue;
656
+ target[key] = !shouldCopy(key, source[key]) ? source[key] : ObjectUtils.copyRecursive(target[key], source[key], predicate, copies);
657
+ }
658
+ }
659
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
660
+ finally {
661
+ try {
662
+ if (keys_2_1 && !keys_2_1.done && (_b = keys_2.return)) _b.call(keys_2);
663
+ }
664
+ finally { if (e_3) throw e_3.error; }
665
+ }
666
+ // Copy object properties
667
+ var descriptors = Object.getOwnPropertyDescriptors(source);
668
+ try {
669
+ for (var _g = __values(Object.keys(descriptors)), _h = _g.next(); !_h.done; _h = _g.next()) {
670
+ var key = _h.value;
671
+ if (keys.indexOf(key) >= 0)
672
+ continue;
673
+ Object.defineProperty(target, key, descriptors[key]);
674
+ }
675
+ }
676
+ catch (e_4_1) { e_4 = { error: e_4_1 }; }
677
+ finally {
678
+ try {
679
+ if (_h && !_h.done && (_c = _g.return)) _c.call(_g);
605
680
  }
681
+ finally { if (e_4) throw e_4.error; }
606
682
  }
607
- return copies.get(source);
683
+ return target;
608
684
  };
609
685
  return ObjectUtils;
610
686
  }());
@@ -6278,11 +6354,12 @@
6278
6354
  exports.ValuedPromise = ValuedPromise;
6279
6355
  exports.ValuesPipe = ValuesPipe;
6280
6356
  exports.Vector = Vector;
6281
- exports["ɵa"] = pipes;
6282
- exports["ɵb"] = directives;
6283
- exports["ɵc"] = components;
6284
- exports["ɵd"] = providers;
6285
- exports["ɵe"] = loadConfig;
6357
+ exports["ɵa"] = defaultPredicate;
6358
+ exports["ɵb"] = pipes;
6359
+ exports["ɵc"] = directives;
6360
+ exports["ɵd"] = components;
6361
+ exports["ɵe"] = providers;
6362
+ exports["ɵf"] = loadConfig;
6286
6363
 
6287
6364
  Object.defineProperty(exports, '__esModule', { value: true });
6288
6365