@alessiofrittoli/web-utils
Version:
Common TypeScript web utilities
1 lines • 654 B
JavaScript
var T=e=>e.length<=0?e:[...new Set(e)],f=(e,n)=>{if(e.length<=0)return e;let t=new Map;return e.map(o=>{t.has(o[n])||t.set(o[n],o);}),Array.from(t.values())},g=e=>e.replace(/\s/g,"").split(",").filter(Boolean);function p(e,n){let t=n&&"size"in n&&n.size,o=n&&"count"in n&&n.count,s=o?Math.ceil(e.length/o):t||1,l=o||Math.ceil(e.length/s);return Array.from({length:l},(c,u)=>e.slice(u*s,u*s+s)).filter(c=>c.length>0)}var h=e=>{for(let n=e.length-1;n>0;n--){let t=Math.floor(Math.random()*(n+1));[e[n],e[t]]=[e[t],e[n]];}return e},k=e=>h([...e]);export{f as arrayObjectUnique,T as arrayUnique,p as chunkInto,g as listToArray,h as shuffle,k as shuffleCopy};