@techmely/utils
Version:
Collection of helpful JavaScript / TypeScript utils
23 lines (18 loc) • 414 B
JavaScript
/*!
* @techmely/utils
* Copyright(c) 2021-2024 Techmely <techmely.creation@gmail.com>
* MIT Licensed
*/
// src/uniqueObject.ts
function uniqueObj(items, uniqueKey) {
const map = /* @__PURE__ */ new Map();
for (const item of items) {
const key = item[uniqueKey];
if (!map.has(key)) {
map.set(key, item);
}
}
return [...map.values()];
}
exports.uniqueObj = uniqueObj;
;