@alessiofrittoli/web-utils
Version:
Common TypeScript web utilities
1 lines • 689 B
JavaScript
;var r=e=>e.length<=0?e:[...new Set(e)],T=(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())},f=e=>e.replace(/\s/g,"").split(",").filter(Boolean);function g(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},p=e=>h([...e]);exports.arrayObjectUnique=T;exports.arrayUnique=r;exports.chunkInto=g;exports.listToArray=f;exports.shuffle=h;exports.shuffleCopy=p;