@sumaris-net/ngx-components 1.23.26 → 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 +15 -7
- 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/doc/changelog.md +5 -0
- package/esm2015/src/app/shared/functions.js +16 -8
- package/fesm2015/sumaris-net.ngx-components.js +15 -7
- 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,15 +424,23 @@
|
|
|
424
424
|
return rv;
|
|
425
425
|
}, {});
|
|
426
426
|
}
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
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) {
|
|
433
|
+
if (isEmptyArray(values))
|
|
434
|
+
return values;
|
|
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, '|'); });
|
|
431
439
|
var existingIds = new Set();
|
|
432
|
-
return
|
|
433
|
-
var uniqueKey =
|
|
440
|
+
return values.reduce(function (res, item) {
|
|
441
|
+
var uniqueKey = getKey(item);
|
|
434
442
|
if (existingIds.has(uniqueKey))
|
|
435
|
-
return res; // Skip
|
|
443
|
+
return res; // Skip if duplicate
|
|
436
444
|
existingIds.add(uniqueKey);
|
|
437
445
|
return res.concat(item);
|
|
438
446
|
}, []);
|