@stemy/ngx-utils 12.2.14 → 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.
- package/bundles/stemy-ngx-utils.umd.js +112 -33
- package/bundles/stemy-ngx-utils.umd.js.map +1 -1
- package/esm2015/ngx-utils/pipes/find.pipe.js +4 -2
- package/esm2015/ngx-utils/utils/object.utils.js +73 -29
- package/esm2015/stemy-ngx-utils.js +3 -2
- package/fesm2015/stemy-ngx-utils.js +76 -29
- package/fesm2015/stemy-ngx-utils.js.map +1 -1
- package/ngx-utils/utils/object.utils.d.ts +3 -0
- package/package.json +1 -1
- package/stemy-ngx-utils.d.ts +2 -1
- package/stemy-ngx-utils.metadata.json +1 -1
|
@@ -317,8 +317,12 @@
|
|
|
317
317
|
return value;
|
|
318
318
|
}
|
|
319
319
|
|
|
320
|
-
|
|
321
|
-
|
|
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,
|
|
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
|
-
|
|
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 (
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
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
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
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
|
+
}
|
|
605
621
|
}
|
|
606
622
|
}
|
|
607
|
-
|
|
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);
|
|
680
|
+
}
|
|
681
|
+
finally { if (e_4) throw e_4.error; }
|
|
682
|
+
}
|
|
683
|
+
return target;
|
|
608
684
|
};
|
|
609
685
|
return ObjectUtils;
|
|
610
686
|
}());
|
|
@@ -4430,7 +4506,9 @@
|
|
|
4430
4506
|
if (!ObjectUtils.isArray(values))
|
|
4431
4507
|
return [];
|
|
4432
4508
|
params = params || {};
|
|
4433
|
-
params
|
|
4509
|
+
if (ObjectUtils.isObject(params)) {
|
|
4510
|
+
params.values = values;
|
|
4511
|
+
}
|
|
4434
4512
|
var filterFunc = ObjectUtils.isFunction(filter) ? filter : function (value, index, params, values) {
|
|
4435
4513
|
return ObjectUtils.evaluate(filter, { value: value, index: index, params: params, values: values });
|
|
4436
4514
|
};
|
|
@@ -6276,11 +6354,12 @@
|
|
|
6276
6354
|
exports.ValuedPromise = ValuedPromise;
|
|
6277
6355
|
exports.ValuesPipe = ValuesPipe;
|
|
6278
6356
|
exports.Vector = Vector;
|
|
6279
|
-
exports["ɵa"] =
|
|
6280
|
-
exports["ɵb"] =
|
|
6281
|
-
exports["ɵc"] =
|
|
6282
|
-
exports["ɵd"] =
|
|
6283
|
-
exports["ɵe"] =
|
|
6357
|
+
exports["ɵa"] = defaultPredicate;
|
|
6358
|
+
exports["ɵb"] = pipes;
|
|
6359
|
+
exports["ɵc"] = directives;
|
|
6360
|
+
exports["ɵd"] = components;
|
|
6361
|
+
exports["ɵe"] = providers;
|
|
6362
|
+
exports["ɵf"] = loadConfig;
|
|
6284
6363
|
|
|
6285
6364
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
6286
6365
|
|