@utilify/array
Advanced tools
+1
-1
@@ -1,1 +0,1 @@ | ||
| "use strict";function t(t){return[...new Set(t)]}exports.after=function(t,n){return t.slice(n+1)},exports.before=function(t,n){return t.slice(0,n)},exports.chunk=function(t,n){const e=[];for(let r=0;r<t.length;r+=n)e.push(t.slice(r,r+n));return e},exports.compact=function(t){return t.filter((t=>![void 0,null,!1,NaN,0,0n,""].includes(t)))},exports.difference=function(t,n){return t.filter((t=>!n.includes(t)))},exports.first=function(t,n=1){return t.slice(0,n)},exports.flattenArr=function(t,n=1/0){return t.flat(n)},exports.getRandom=function(t){return t[Math.floor(Math.random()*t.length)]},exports.isIterable=function(t){return null!=t&&"function"==typeof t?.[Symbol.iterator]},exports.last=function(t,n=1){return t.slice(-n)},exports.rotate=function(t,n){const e=t.length;return n=(n%e+e)%e,t.slice(n).concat(t.slice(0,n))},exports.sanitizeArr=function(t,n,e){const r=[];for(const o of t)n.includes(o)?void 0!==e&&r.push(e):r.push(o);return r},exports.shuffle=function(t){for(let n=t.length-1;n>0;n--){const e=Math.floor(Math.random()*(n+1));[t[n],t[e]]=[t[e],t[n]]}return t},exports.swap=function(t,n,e){return[t[n],t[e]]=[t[e],t[n]],t},exports.union=function(...n){return t(n.reduce(((t,n)=>[...t,...n]),[]))},exports.unique=t; | ||
| "use strict";function t(t){return[...new Set(t)]}exports.after=function(t,n){return t.slice(n+1)},exports.before=function(t,n){return t.slice(0,n)},exports.chunk=function(t,n){const e=[];for(let r=0;r<t.length;r+=n)e.push(t.slice(r,r+n));return e},exports.compact=function(t){return t.filter((t=>![void 0,null,!1,NaN,0,0n,""].includes(t)))},exports.difference=function(t,n){return t.filter((t=>!n.includes(t)))},exports.first=function(t,n=1){return t.slice(0,n)},exports.flattenArr=function(t,n=1/0){return t.flat(n)},exports.isIterable=function(t){return null!=t&&"function"==typeof t?.[Symbol.iterator]},exports.last=function(t,n=1){return t.slice(-n)},exports.rotate=function(t,n){const e=t.length;return n=(n%e+e)%e,t.slice(n).concat(t.slice(0,n))},exports.sample=function(t){return t[Math.floor(Math.random()*t.length)]},exports.sanitizeArr=function(t,n,e){const r=[];for(const o of t)n.includes(o)?void 0!==e&&r.push(e):r.push(o);return r},exports.shuffle=function(t){for(let n=t.length-1;n>0;n--){const e=Math.floor(Math.random()*(n+1));[t[n],t[e]]=[t[e],t[n]]}return t},exports.swap=function(t,n,e){return[t[n],t[e]]=[t[e],t[n]],t},exports.union=function(...n){return t(n.reduce(((t,n)=>[...t,...n]),[]))},exports.unique=t; |
+3
-3
@@ -36,5 +36,5 @@ declare function after(str: string, index: number): string; | ||
| declare function getRandom(str: string): string; | ||
| declare function getRandom<T>(arr: T[]): T; | ||
| declare function sample(str: string): string; | ||
| declare function sample<T>(arr: T[]): T; | ||
| export { after, before, chunk, compact, difference, first, flattenArr, getRandom, isIterable, last, rotate, sanitizeArr, shuffle, swap, union, unique }; | ||
| export { after, before, chunk, compact, difference, first, flattenArr, isIterable, last, rotate, sample, sanitizeArr, shuffle, swap, union, unique }; |
+1
-1
@@ -1,1 +0,1 @@ | ||
| function n(n,t){return n.slice(t+1)}function t(n,t){return n.slice(0,t)}function r(n,t){const r=[];for(let u=0;u<n.length;u+=t)r.push(n.slice(u,u+t));return r}function u(n){return n.filter((n=>![void 0,null,!1,NaN,0,0n,""].includes(n)))}function e(n,t=1/0){return n.flat(t)}function o(n){return null!=n&&"function"==typeof n?.[Symbol.iterator]}function c(n,t){const r=n.length;return t=(t%r+r)%r,n.slice(t).concat(n.slice(0,t))}function i(n){for(let t=n.length-1;t>0;t--){const r=Math.floor(Math.random()*(t+1));[n[t],n[r]]=[n[r],n[t]]}return n}function f(n,t,r){return[n[t],n[r]]=[n[r],n[t]],n}function l(n){return[...new Set(n)]}function s(n,t){return n.filter((n=>!t.includes(n)))}function h(n,t=1){return n.slice(0,t)}function a(n,t=1){return n.slice(-t)}function d(...n){return l(n.reduce(((n,t)=>[...n,...t]),[]))}function p(n,t,r){const u=[];for(const e of n)t.includes(e)?void 0!==r&&u.push(r):u.push(e);return u}function g(n){return n[Math.floor(Math.random()*n.length)]}export{n as after,t as before,r as chunk,u as compact,s as difference,h as first,e as flattenArr,g as getRandom,o as isIterable,a as last,c as rotate,p as sanitizeArr,i as shuffle,f as swap,d as union,l as unique}; | ||
| function n(n,t){return n.slice(t+1)}function t(n,t){return n.slice(0,t)}function r(n,t){const r=[];for(let u=0;u<n.length;u+=t)r.push(n.slice(u,u+t));return r}function u(n){return n.filter((n=>![void 0,null,!1,NaN,0,0n,""].includes(n)))}function e(n,t=1/0){return n.flat(t)}function o(n){return null!=n&&"function"==typeof n?.[Symbol.iterator]}function c(n,t){const r=n.length;return t=(t%r+r)%r,n.slice(t).concat(n.slice(0,t))}function i(n){for(let t=n.length-1;t>0;t--){const r=Math.floor(Math.random()*(t+1));[n[t],n[r]]=[n[r],n[t]]}return n}function f(n,t,r){return[n[t],n[r]]=[n[r],n[t]],n}function l(n){return[...new Set(n)]}function s(n,t){return n.filter((n=>!t.includes(n)))}function h(n,t=1){return n.slice(0,t)}function a(n,t=1){return n.slice(-t)}function d(...n){return l(n.reduce(((n,t)=>[...n,...t]),[]))}function p(n,t,r){const u=[];for(const e of n)t.includes(e)?void 0!==r&&u.push(r):u.push(e);return u}function g(n){return n[Math.floor(Math.random()*n.length)]}export{n as after,t as before,r as chunk,u as compact,s as difference,h as first,e as flattenArr,o as isIterable,a as last,c as rotate,g as sample,p as sanitizeArr,i as shuffle,f as swap,d as union,l as unique}; |
+2
-2
| { | ||
| "name": "@utilify/array", | ||
| "version": "2.0.0", | ||
| "version": "2.0.1", | ||
| "description": "A collection of utility functions for array manipulation and transformation. Simplifies common operations like chunking, flattening, shuffling, finding differences, and more.", | ||
@@ -14,6 +14,6 @@ "keywords": [ | ||
| "flattenArr", | ||
| "getRandom", | ||
| "isIterable", | ||
| "last", | ||
| "rotate", | ||
| "sample", | ||
| "sanitizeArr", | ||
@@ -20,0 +20,0 @@ "shuffle", |
11218
-0.16%