@stemy/ngx-utils 12.2.15 → 12.2.17
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 +118 -33
- package/bundles/stemy-ngx-utils.umd.js.map +1 -1
- package/esm2015/ngx-utils/common-types.js +6 -1
- package/esm2015/ngx-utils/utils/object.utils.js +76 -30
- package/esm2015/public_api.js +2 -2
- package/esm2015/stemy-ngx-utils.js +3 -2
- package/fesm2015/stemy-ngx-utils.js +81 -29
- package/fesm2015/stemy-ngx-utils.js.map +1 -1
- package/ngx-utils/common-types.d.ts +1 -0
- package/ngx-utils/utils/object.utils.d.ts +3 -0
- package/package.json +1 -1
- package/public_api.d.ts +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,17 +488,19 @@
|
|
|
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]+)");
|
|
497
|
-
|
|
501
|
+
var target = !obj ? null : obj.constructor;
|
|
502
|
+
var type = !target ? null : Reflect.getMetadata("objectType", target);
|
|
503
|
+
return (type || Object.prototype.toString.call(obj).match(regex)[1]).toLowerCase();
|
|
498
504
|
};
|
|
499
505
|
ObjectUtils.isPrimitive = function (value) {
|
|
500
506
|
var type = typeof value;
|
|
@@ -541,6 +547,9 @@
|
|
|
541
547
|
ObjectUtils.isSet = function (value) {
|
|
542
548
|
return value instanceof Set;
|
|
543
549
|
};
|
|
550
|
+
ObjectUtils.isConstructor = function (value) {
|
|
551
|
+
return (value && typeof value === "function" && value.prototype && value.prototype.constructor) === value && value.name !== "Object";
|
|
552
|
+
};
|
|
544
553
|
ObjectUtils.checkInterface = function (obj, interFaceObject) {
|
|
545
554
|
return ObjectUtils.isInterface(obj, interFaceObject);
|
|
546
555
|
};
|
|
@@ -578,33 +587,102 @@
|
|
|
578
587
|
return str.length >= width ? str : new Array(width - str.length + 1).join(chr) + str;
|
|
579
588
|
};
|
|
580
589
|
ObjectUtils.copyRecursive = function (target, source, predicate, copies) {
|
|
581
|
-
|
|
590
|
+
var e_2, _a, e_3, _b, e_4, _c;
|
|
582
591
|
if (ObjectUtils.isPrimitive(source) || ObjectUtils.isDate(source) || ObjectUtils.isBlob(source) || ObjectUtils.isFunction(source))
|
|
583
592
|
return source;
|
|
584
|
-
if (
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
593
|
+
if (copies.has(source))
|
|
594
|
+
return copies.get(source);
|
|
595
|
+
if (ObjectUtils.isArray(source)) {
|
|
596
|
+
target = ObjectUtils.isArray(target) ? Array.from(target) : [];
|
|
597
|
+
copies.set(source, target);
|
|
598
|
+
for (var index = 0; index < source.length; index++) {
|
|
599
|
+
var item = source[index];
|
|
600
|
+
if (!predicate(item, index, target, source))
|
|
601
|
+
continue;
|
|
602
|
+
if (target.length > index)
|
|
603
|
+
target[index] = ObjectUtils.copyRecursive(target[index], item, predicate, copies);
|
|
604
|
+
else
|
|
605
|
+
target.push(ObjectUtils.copyRecursive(null, item, predicate, copies));
|
|
596
606
|
}
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
607
|
+
return target;
|
|
608
|
+
}
|
|
609
|
+
// If object defines __shouldCopy as false, then don't copy it
|
|
610
|
+
if (source.__shouldCopy === false)
|
|
611
|
+
return source;
|
|
612
|
+
// Copy object
|
|
613
|
+
var shouldCopy = ObjectUtils.isFunction(source.__shouldCopy) ? source.__shouldCopy : shouldCopyDefault;
|
|
614
|
+
if (ObjectUtils.isConstructor(source.constructor)) {
|
|
615
|
+
if (!target) {
|
|
616
|
+
try {
|
|
617
|
+
target = new source.constructor();
|
|
618
|
+
}
|
|
619
|
+
catch (e) {
|
|
620
|
+
var proto = source.constructor.prototype || source.prototype;
|
|
621
|
+
target = Object.create(proto);
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
else {
|
|
626
|
+
target = Object.assign({}, target || {});
|
|
627
|
+
}
|
|
628
|
+
// Set to copies to prevent circular references
|
|
629
|
+
copies.set(source, target);
|
|
630
|
+
// Copy map entries
|
|
631
|
+
if (target instanceof Map) {
|
|
632
|
+
if (source instanceof Map) {
|
|
633
|
+
try {
|
|
634
|
+
for (var _d = __values(source.entries()), _e = _d.next(); !_e.done; _e = _d.next()) {
|
|
635
|
+
var _f = __read(_e.value, 2), key = _f[0], value = _f[1];
|
|
636
|
+
if (!predicate(value, key, target, source))
|
|
637
|
+
continue;
|
|
638
|
+
target.set(key, !shouldCopy(key, value) ? value : ObjectUtils.copyRecursive(target.get(key), value, predicate, copies));
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
642
|
+
finally {
|
|
643
|
+
try {
|
|
644
|
+
if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
|
|
645
|
+
}
|
|
646
|
+
finally { if (e_2) throw e_2.error; }
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
return target;
|
|
650
|
+
}
|
|
651
|
+
// Copy object members
|
|
652
|
+
var keys = Object.keys(source);
|
|
653
|
+
try {
|
|
654
|
+
for (var keys_2 = __values(keys), keys_2_1 = keys_2.next(); !keys_2_1.done; keys_2_1 = keys_2.next()) {
|
|
655
|
+
var key = keys_2_1.value;
|
|
656
|
+
if (!predicate(source[key], key, target, source))
|
|
657
|
+
continue;
|
|
658
|
+
target[key] = !shouldCopy(key, source[key]) ? source[key] : ObjectUtils.copyRecursive(target[key], source[key], predicate, copies);
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
662
|
+
finally {
|
|
663
|
+
try {
|
|
664
|
+
if (keys_2_1 && !keys_2_1.done && (_b = keys_2.return)) _b.call(keys_2);
|
|
665
|
+
}
|
|
666
|
+
finally { if (e_3) throw e_3.error; }
|
|
667
|
+
}
|
|
668
|
+
// Copy object properties
|
|
669
|
+
var descriptors = Object.getOwnPropertyDescriptors(source);
|
|
670
|
+
try {
|
|
671
|
+
for (var _g = __values(Object.keys(descriptors)), _h = _g.next(); !_h.done; _h = _g.next()) {
|
|
672
|
+
var key = _h.value;
|
|
673
|
+
if (keys.indexOf(key) >= 0)
|
|
674
|
+
continue;
|
|
675
|
+
Object.defineProperty(target, key, descriptors[key]);
|
|
605
676
|
}
|
|
606
677
|
}
|
|
607
|
-
|
|
678
|
+
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
679
|
+
finally {
|
|
680
|
+
try {
|
|
681
|
+
if (_h && !_h.done && (_c = _g.return)) _c.call(_g);
|
|
682
|
+
}
|
|
683
|
+
finally { if (e_4) throw e_4.error; }
|
|
684
|
+
}
|
|
685
|
+
return target;
|
|
608
686
|
};
|
|
609
687
|
return ObjectUtils;
|
|
610
688
|
}());
|
|
@@ -682,6 +760,11 @@
|
|
|
682
760
|
ReflectUtils.defineMetadata("factoryDependencies", dependencies, target, method);
|
|
683
761
|
};
|
|
684
762
|
}
|
|
763
|
+
function ObjectType(type) {
|
|
764
|
+
return function (target) {
|
|
765
|
+
ReflectUtils.defineMetadata("objectType", type, target);
|
|
766
|
+
};
|
|
767
|
+
}
|
|
685
768
|
var PaginationItemContext = /** @class */ (function () {
|
|
686
769
|
function PaginationItemContext(item, parallelItem, count, index, dataIndex) {
|
|
687
770
|
this.item = item;
|
|
@@ -6230,6 +6313,7 @@
|
|
|
6230
6313
|
exports.MinPipe = MinPipe;
|
|
6231
6314
|
exports.NgxTemplateOutletDirective = NgxTemplateOutletDirective;
|
|
6232
6315
|
exports.NgxUtilsModule = NgxUtilsModule;
|
|
6316
|
+
exports.ObjectType = ObjectType;
|
|
6233
6317
|
exports.ObjectUtils = ObjectUtils;
|
|
6234
6318
|
exports.ObservableUtils = ObservableUtils;
|
|
6235
6319
|
exports.OpenApiService = OpenApiService;
|
|
@@ -6278,11 +6362,12 @@
|
|
|
6278
6362
|
exports.ValuedPromise = ValuedPromise;
|
|
6279
6363
|
exports.ValuesPipe = ValuesPipe;
|
|
6280
6364
|
exports.Vector = Vector;
|
|
6281
|
-
exports["ɵa"] =
|
|
6282
|
-
exports["ɵb"] =
|
|
6283
|
-
exports["ɵc"] =
|
|
6284
|
-
exports["ɵd"] =
|
|
6285
|
-
exports["ɵe"] =
|
|
6365
|
+
exports["ɵa"] = defaultPredicate;
|
|
6366
|
+
exports["ɵb"] = pipes;
|
|
6367
|
+
exports["ɵc"] = directives;
|
|
6368
|
+
exports["ɵd"] = components;
|
|
6369
|
+
exports["ɵe"] = providers;
|
|
6370
|
+
exports["ɵf"] = loadConfig;
|
|
6286
6371
|
|
|
6287
6372
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
6288
6373
|
|