@sumaris-net/ngx-components 1.23.27 → 1.23.28
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/sumaris-net.ngx-components.umd.js +11 -6
- package/bundles/sumaris-net.ngx-components.umd.js.map +1 -1
- package/bundles/sumaris-net.ngx-components.umd.min.js +1 -1
- package/bundles/sumaris-net.ngx-components.umd.min.js.map +1 -1
- package/esm2015/src/app/shared/functions.js +12 -7
- package/fesm2015/sumaris-net.ngx-components.js +11 -6
- package/fesm2015/sumaris-net.ngx-components.js.map +1 -1
- package/package.json +1 -1
- package/src/app/shared/functions.d.ts +8 -3
- package/sumaris-net.ngx-components.metadata.json +1 -1
|
@@ -424,16 +424,21 @@
|
|
|
424
424
|
return rv;
|
|
425
425
|
}, {});
|
|
426
426
|
}
|
|
427
|
-
|
|
427
|
+
/**
|
|
428
|
+
* Remove duplicated value, in array. Will compute a unique key (from given properties, or given function)
|
|
429
|
+
* @param values
|
|
430
|
+
* @param propertiesOrKeyFn
|
|
431
|
+
*/
|
|
432
|
+
function arrayDistinct(values, propertiesOrKeyFn) {
|
|
428
433
|
if (isEmptyArray(values))
|
|
429
434
|
return values;
|
|
430
|
-
var properties =
|
|
431
|
-
var
|
|
432
|
-
(typeof
|
|
433
|
-
|
|
435
|
+
var properties = (!propertiesOrKeyFn && Object.keys(values[0])) || (Array.isArray(propertiesOrKeyFn) && propertiesOrKeyFn);
|
|
436
|
+
var getKey = (typeof propertiesOrKeyFn === 'function' && propertiesOrKeyFn)
|
|
437
|
+
|| (typeof propertiesOrKeyFn === 'string' && (function (obj) { return getPropertyByPathAsString(obj, propertiesOrKeyFn); }))
|
|
438
|
+
|| (function (obj) { return joinPropertiesPath(obj, properties, '|'); });
|
|
434
439
|
var existingIds = new Set();
|
|
435
440
|
return values.reduce(function (res, item) {
|
|
436
|
-
var uniqueKey =
|
|
441
|
+
var uniqueKey = getKey(item);
|
|
437
442
|
if (existingIds.has(uniqueKey))
|
|
438
443
|
return res; // Skip if duplicate
|
|
439
444
|
existingIds.add(uniqueKey);
|