coffee-core
Version:
Coffee IT API core library
22 lines • 819 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.removeListDuplicatesByKey = exports.removeListDuplicates = exports.shuffleArray = void 0;
const shuffleArray = (array) => {
return array
.map((value) => ({ value, sort: Math.random() }))
.sort((a, b) => a.sort - b.sort)
.map((obj) => obj.value);
};
exports.shuffleArray = shuffleArray;
const removeListDuplicates = (array) => {
return [...new Set(array)];
};
exports.removeListDuplicates = removeListDuplicates;
const removeListDuplicatesByKey = (array, key) => {
if (array.length === 0) {
return array;
}
return [...new Map(array.map((item) => [item[key], item])).values()];
};
exports.removeListDuplicatesByKey = removeListDuplicatesByKey;
//# sourceMappingURL=array-utilis.js.map