UNPKG

@estarlincito/utils

Version:

A collection of utility functions designed to simplify and speed up development tasks in JavaScript and TypeScript projects.

2 lines (1 loc) 470 B
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class m{constructor(){}static getUniqueByKey(n,e,...s){const c=new Set;return n.reduce((i,l)=>{const a=t=>t.split(":").reduce((r,d)=>r?.[d],l),o=a(e),u=JSON.stringify({[e]:o,...Object.fromEntries(s.map(t=>[t,a(t)]))});if(!c.has(u)){c.add(u);const t={};t[e]=o,s.forEach(r=>{t[r]=a(r)}),i.push(t)}return i},[])}static getUniqueValues=(n,e)=>[...new Set(n.map(s=>s[e]))]}exports.ArrayUtils=m;