UNPKG

@techmely/utils

Version:

Collection of helpful JavaScript / TypeScript utils

21 lines (17 loc) 390 B
/*! * @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()]; } export { uniqueObj };