tinkit 0.0.0-stage → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +135 -2
- package/dist/arrays/index.d.ts +1168 -0
- package/dist/arrays/index.js +1 -0
- package/dist/async/index.d.ts +729 -0
- package/dist/async/index.js +1 -0
- package/dist/cache/index.d.ts +165 -0
- package/dist/cache/index.js +1 -0
- package/dist/color/index.d.ts +328 -0
- package/dist/color/index.js +1 -0
- package/dist/date/index.d.ts +1152 -0
- package/dist/date/index.js +1 -0
- package/dist/decorators/index.d.ts +313 -0
- package/dist/decorators/index.js +1 -0
- package/dist/easing/index.d.ts +452 -0
- package/dist/easing/index.js +1 -0
- package/dist/emitter/index.d.ts +104 -0
- package/dist/emitter/index.js +1 -0
- package/dist/format/index.d.ts +317 -0
- package/dist/format/index.js +1 -0
- package/dist/functions/index.d.ts +648 -0
- package/dist/functions/index.js +1 -0
- package/dist/guards/index.d.ts +1009 -0
- package/dist/guards/index.js +1 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.js +1 -0
- package/dist/iterables/index.d.ts +501 -0
- package/dist/iterables/index.js +1 -0
- package/dist/math/index.d.ts +670 -0
- package/dist/math/index.js +1 -0
- package/dist/objects/index.d.ts +1308 -0
- package/dist/objects/index.js +1 -0
- package/dist/random/index.d.ts +184 -0
- package/dist/random/index.js +1 -0
- package/dist/search/index.d.ts +151 -0
- package/dist/search/index.js +1 -0
- package/dist/store/index.d.ts +71 -0
- package/dist/store/index.js +1 -0
- package/dist/strings/index.d.ts +751 -0
- package/dist/strings/index.js +3 -0
- package/dist/url/index.d.ts +357 -0
- package/dist/url/index.js +1 -0
- package/dist/utils/assert.d.ts +81 -0
- package/dist/utils/assert.js +1 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +0 -0
- package/dist/utils/types.d.ts +82 -0
- package/dist/utils/types.js +0 -0
- package/dist/validate/index.d.ts +409 -0
- package/dist/validate/index.js +1 -0
- package/llms-full.txt +708 -0
- package/llms.txt +42 -0
- package/package.json +144 -5
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{isIterable as me}from"../guards/index.js";import{median as ye}from"../math/index.js";import{assertFunction as f,assertInteger as R,assertNumber as O,describe as X,draw as W}from"../utils/assert.js";const N=2**32-1,he=64;function ke(e,n){return e.includes(n)}function Ie(e){return e[0]}function Be(e){return e[e.length-1]}function Ke(e){const n=[];for(let t=0;t<e.length;t++){if(!(t in e))continue;const r=e[t];if(Array.isArray(r))for(let o=0;o<r.length;o++)o in r&&n.push(r[o]);else n.push(r)}return n}function ve(e){const n=[],t=[],r=[];let o,u=e,i=0;for(;;)if(i===u.length){if(t.length===0)return n;u=t.pop(),i=r.pop(),o?.delete(u)}else if(i++in u){const l=u[i-1];if(!Array.isArray(l)){n.push(l);continue}if(t.push(u),r.push(i),o!==void 0?o.add(u):t.length===he&&(o=new Set(t)),o===void 0?t.includes(l):o.has(l))throw new TypeError("flattenDeep: cannot flatten a circular array");u=l,i=0}}function pe(e){const n=Array.isArray(e)?e:Array.from(e);if(n.length<=32){const u=[];for(const i of n)u.includes(i)||u.push(i);return u}const t=new Set(n),r=Array.from(t),o=0;return t.has(o)&&Object.is(n[n.indexOf(o)],-0)&&(r[r.indexOf(o)]=-0),r}function C(e,n){return Array.isArray(e)&&Array.isArray(n)&&e.length+n.length<=32}function Ue(e,n){return pe(Array.isArray(e)&&Array.isArray(n)?e.concat(n):[...e,...n])}function Me(e,n){const t=[];if(C(e,n)){for(const o of e)n.includes(o)&&!t.includes(o)&&t.push(o);return t}const r=new Set(n);for(const o of e)r.delete(o)&&t.push(o);return t}function ne(e,n){const t=[];if(C(e,n)){for(const o of e)!n.includes(o)&&!t.includes(o)&&t.push(o);return t}const r=new Set(n);for(const o of e)r.has(o)||(r.add(o),t.push(o));return t}function Ne(e,n){const t=Array.from(e),r=Array.from(n);return ne(t,r).concat(ne(r,t))}function Oe(e,n){if(C(e,n)){for(const r of e)if(!n.includes(r))return!1;return!0}const t=new Set(n);for(const r of e)if(!t.has(r))return!1;return!0}function S(e,n,t){if(t-n>32||e.constructor!==Array)return e.slice(n,t);const r=new Array(t-n);for(let o=0;n<t;o++,n++)n in e&&(r[o]=e[n]);return r}function Ee(e,n){R("chunk","size",n,1);const t=new Array(Math.ceil(e.length/n));for(let r=0;r<t.length;r++)t[r]=S(e,r*n,Math.min((r+1)*n,e.length));return t}function $e(e){const n=[];for(let t=0;t<e.length;t++){const r=e[t];r&&n.push(r)}return n}function be(e,n,t=1){const r=n===void 0?0:e,o=n===void 0?e:n;O("range","start",e,Number.isFinite(e),"a finite number"),n!==void 0&&O("range","end",n,Number.isFinite(n),"a finite number"),O("range","step",t,Number.isFinite(t)&&t!==0,"a finite number other than 0");const u=ge(r,o,t),i=new Array(u);for(let l=0;l<u;l++)i[l]=r+l*t;return i}function ge(e,n,t){const r=(n-e)/t,o=Math.round(r);let u=Math.max(0,r===o||Math.abs(r-o)<=4*Number.EPSILON*((Math.abs(e)+Math.abs(n))/Math.abs(t)+Math.abs(r))?o:Math.ceil(r));if(u>N)throw new RangeError(`range: the range would contain ${u} items, more than an array can hold`);for(;u>0&&(e+(u-1)*t-n)*t>=0;)u--;return u}function De(...e){return Ae(e)}function P(){return Object.setPrototypeOf({},null)}function je(e,n){f("groupBy","keyFn",n);const t=P();for(let r=0;r<e.length;r++){const o=e[r],u=n(o,r),i=t[u];i===void 0?t[u]=[o]:i.push(o)}return t}function We(e,n){f("keyBy","keyFn",n);const t=P();for(let r=0;r<e.length;r++)t[n(e[r],r)]=e[r];return t}function Ce(e,n){f("countBy","keyFn",n);const t=P();for(let r=0;r<e.length;r++){const o=n(e[r],r);t[o]=(t[o]??0)+1}return t}function Pe(e,n){f("partition","predicate",n);const t=[],r=[];for(let o=0;o<e.length;o++)n(e[o],o)?t.push(e[o]):r.push(e[o]);return[t,r]}function Fe(e,n){f("uniqueBy","keyFn",n);const t=new Set,r=[];for(let o=0;o<e.length;o++){const u=n(e[o],o);t.has(u)||(t.add(u),r.push(e[o]))}return r}function Y(e){return e instanceof Date?e.getTime():e??NaN}function D(e){return typeof e=="number"?e:Y(e)}function F(e,n){const t=typeof e=="string";return t!==(typeof n=="string")?t?1:-1:e<n?-1:e>n?1:0}function j(e,n,t){return e!==e?n!==n?0:1:n!==n?-1:t*F(e,n)}function E(e,n,t,r){if(t==="asc"||t==="desc")return t==="asc"?1:-1;throw new RangeError(`${e}: \`${r===void 0?n:`${n}[${r}]`}\` must be 'asc' or 'desc', got ${String(t)}`)}function _(e,n){if(e.length>12){e.sort(n);return}for(let t=1;t<e.length;t++){const r=e[t];let o=t;for(;o>0&&n(e[o-1],r)>0;o--)e[o]=e[o-1];e[o]=r}}function te(e,n,t="asc"){f("sortBy","selector",n),E("sortBy","order",t);const r=e.length,o=[],u=[],i=[];for(let s=0;s<r;s++){const a=n(e[s],s),g=typeof a=="number"?a:Y(a);o.push(g),(g!==g?i:u).push(s)}_(u,t==="asc"?function(s,a){return F(o[s],o[a])}:function(s,a){return F(o[a],o[s])});const l=new Array(r);for(let s=0;s<u.length;s++)l[s]=e[u[s]];for(let s=0;s<i.length;s++)l[u.length+s]=e[i[s]];return l}function Ze(e,n=Math.random){const t=Array.from(e);for(let r=t.length-1;r>0;r--){const o=Math.floor(W("shuffle",n)*(r+1)),u=t[r];t[r]=t[o],t[o]=u}return t}function qe(e,n=Math.random){if(e.length!==0)return e[Math.floor(W("sample",n)*e.length)]}function Ge(e,n){return R("take","n",n,0),S(e,0,Math.min(n,e.length))}function Ve(e,n){return R("drop","n",n,0),S(e,Math.min(n,e.length),e.length)}function Ae(e){if(e.length===0)return[];let n=e[0].length;for(let r=1;r<e.length;r++)n=Math.min(n,e[r].length);const t=new Array(n);for(let r=0;r<n;r++){const o=new Array(e.length);for(let u=0;u<e.length;u++)o[u]=e[u][r];t[r]=o}return t}function ze(e,n,t=1){R("windowed","size",n,1),R("windowed","step",t,1);const r=e.length<n?0:Math.floor((e.length-n)/t)+1;if(r*n>N)throw new RangeError(`windowed: the result would contain ${r} windows of ${n} items, more than 2 ** 32 - 1 items in all`);const o=[];for(let u=0;u+n<=e.length;u+=t)o.push(S(e,u,u+n));return o}function Xe(e){const n=[];for(let t=1;t<e.length;t++)n.push([e[t-1],e[t]]);return n}function re(e,n,t){let r,o=NaN,u=NaN,i=0;for(;i<e.length&&(u=n(e[i],i),typeof u=="number");i++)if(u===u){r=e[i++],o=u;break}if(o===o)for(;i<e.length&&(u=n(e[i],i),typeof u=="number");i++)(t<0?u<o:u>o)&&(r=e[i],o=u);let l=o===o;for(;i<e.length;i++){const s=Y(u);s===s&&(!l||F(s,o)===t)&&(l=!0,r=e[i],o=s),i+1<e.length&&(u=n(e[i+1],i+1))}return r}function Ye(e,n){return f("minBy","selector",n),re(e,n,-1)}function _e(e,n){return f("maxBy","selector",n),re(e,n,1)}function Je(e,n){return f("sumBy","selector",n),oe(e,n,1)}function oe(e,n,t){let r=0,o=0;for(let u=0;u<e.length;u++){const i=+n(e[u],u),l=r+i;o+=Math.abs(r)>=Math.abs(i)?r-l+i:i-l+r,r=l}return Number.isFinite(r)?r/t+o/t:r/t}function $(e,n,t,r,o){const u=t<0?r+t:t,i=o?r:r-1;return O(e,n,t,Number.isInteger(t)&&u>=0&&u<=i,i<0?"a valid index, but the array is empty":`an integer in [${-r}, ${i}]`),u}function Qe(e,n,t){const r=$("move","from",n,e.length,!1),o=$("move","to",t,e.length,!1),u=Array.from(e),[i]=u.splice(r,1);return u.splice(o,0,i),u}function Le(e,n,...t){const r=$("insertAt","index",n,e.length,!0),o=Array.from(e);return o.splice(r,0,...t),o}function He(e,n,t=1){const r=$("removeAt","index",n,e.length,!1);R("removeAt","count",t,0);const o=Array.from(e);return o.splice(r,t),o}function xe(e,n){return e<n?-1:e>n?1:0}function J(e,n,t,r,o=!1){if(r===void 0){if(Number.isNaN(t))throw new RangeError(`${e}: \`value\` must not be NaN when no comparator is given, got NaN`)}else f(e,"compare",r);const u=r??xe;let i=0,l=n.length;for(;i<l;){const s=i+l>>>1,a=u(n[s],t);a<0||o&&a===0?i=s+1:l=s}return[i,u]}function en(e,n,t){return J("sortedIndex",e,n,t)[0]}function nn(e,n,t){const[r,o]=J("binarySearch",e,n,t);return r<e.length&&o(e[r],n)===0?r:-1}function tn(...e){let n=1;for(const o of e)n*=o.length;if(n*e.length>N)throw new RangeError(`cartesianProduct: the product would contain ${n} tuples of ${e.length} items, more than 2 ** 32 - 1 items in all`);const t=[],r=new Array(e.length).fill(0);for(let o=0;o<n;o++){const u=[];for(let i=0;i<e.length;i++)u.push(e[i][r[i]]);t.push(u);for(let i=e.length-1;i>=0&&(r[i]++,!(r[i]<e[i].length));i--)r[i]=0}return t}function rn(e,n){const t=[];for(let r=0;r<e.length;r++)r>0&&t.push(n),t.push(e[r]);return t}function Z(e,n){const t=new Array;for(const r of e)t.push(n(r));return t}function on(e,n,t){f("differenceBy","keyFn",t);const r=Z(n,t),o=[];if(C(e,r)){for(const i of e){const l=t(i);r.includes(l)||(r.push(l),o.push(i))}return o}const u=new Set(r);for(const i of e){const l=t(i);u.has(l)||(u.add(l),o.push(i))}return o}function un(e,n,t){f("intersectionBy","keyFn",t);const r=new Set(Z(n,t)),o=[];for(const u of e)r.delete(t(u))&&o.push(u);return o}function Q(e,n){return e===n||Number.isNaN(e)&&Number.isNaN(n)}function ue(e,n,t){if(!me(t))throw new TypeError(`${e}: \`${n}\` must be an iterable, got ${X(t)}`);return Array.from(t)}function ie(e,n,t,r,o){const u=ue(e,"a",n),i=ue(e,"b",t);f(e,"equals",r);const{maxEdits:l=1/0}=o;R(e,"maxEdits",l,0,!0);const s=Math.ceil(l/2);let a=0;function g(d){if(a+=d,a>l)throw new RangeError(`${e}: the sequences differ by more than \`maxEdits\` (${l}) insertions and deletions`)}const c=[],I=[],B=[],h=Math.ceil((u.length+i.length)/2)+1,v=new Int32Array(2*h),U=new Int32Array(2*h);function ee(){for(const d of I)c.push({type:"delete",value:u[d],indexA:d});for(const d of B)c.push({type:"insert",value:i[d],indexB:d});I.length=0,B.length=0}function q(d,k){ee(),c.push({type:"equal",value:u[d],indexA:d,indexB:k})}function de(d,k,A,M){const p=k-d,w=M-A,y=p-w,K=y%2!==0;v[h+1]=0,U[h+1]=0;for(let b=0;;b++){b>s&&g(1/0);for(let T=-b;T<=b;T+=2){let m=T===-b||T!==b&&v[h+T-1]<v[h+T+1]?v[h+T+1]:v[h+T-1]+1,x=m-T;const V=m,z=x;for(;m<p&&x<w&&r(u[d+m],i[A+x]);)m++,x++;if(v[h+T]=m,K&&Math.abs(y-T)<=b-1&&m+U[h+y-T]>=p)return[d+V,A+z,d+m,A+x]}for(let T=-b;T<=b;T+=2){let m=T===-b||T!==b&&U[h+T-1]<U[h+T+1]?U[h+T+1]:U[h+T-1]+1,x=m-T;const V=m,z=x;for(;m<p&&x<w&&r(u[k-1-m],i[M-1-x]);)m++,x++;if(U[h+T]=m,!K&&Math.abs(y-T)<=b&&m+v[h+y-T]>=p)return[k-m,M-x,k-V,M-z]}}}function G(d,k,A,M){for(;d<k&&A<M&&r(u[d],i[A]);)q(d++,A++);let p=k,w=M;for(;p>d&&w>A&&r(u[p-1],i[w-1]);)p--,w--;if(d===p){g(w-A);for(let y=A;y<w;y++)B.push(y)}else if(A===w){g(p-d);for(let y=d;y<p;y++)I.push(y)}else{const[y,K,b,T]=de(d,p,A,w);G(d,y,A,K);for(let m=y,x=K;m<b;m++,x++)q(m,x);G(b,p,T,w)}for(let y=p,K=w;y<k;y++,K++)q(y,K)}return G(0,u.length,0,i.length),ee(),c}function ln(e,n,t=Q,r={}){return ie("diffSequences",e,n,t,r)}function sn(e,n,t=Q,r={}){const o=[];for(const u of ie("longestCommonSubsequence",e,n,t,r))u.type==="equal"&&o.push(u.value);return o}function an(e,n,t){f("unionBy","keyFn",t);const r=new Set,o=[];for(const u of[e,n])for(const i of u){const l=t(i);r.has(l)||(r.add(l),o.push(i))}return o}function le(e,n,t,r){for(let o=0;o<e.length;o++)t.has(n[o])||(t.add(n[o]),r.push(e[o]));return r}function fn(e,n,t){f("symmetricDifferenceBy","keyFn",t);const r=Array.from(e),o=Array.from(n),u=Z(r,t),i=Z(o,t),l=le(r,u,new Set(i),[]);return le(o,i,new Set(u),l)}function L(e,n,t){for(const r of e){let o=0;for(;o<t.length&&!n(r,t[o]);)o++;o===t.length&&t.push(r)}return t}function cn(e,n){return f("uniqueWith","equals",n),L(e,n,[])}function Tn(e,n,t){return f("unionWith","equals",t),L(n,t,L(e,t,[]))}function dn(e,n,t){f("differenceWith","equals",t);const r=Array.isArray(n)?n.slice():Array.from(n),o=[];for(const u of e){let i=0;for(;i<r.length&&!t(u,r[i]);)i++;i===r.length&&(r.push(u),o.push(u))}return o}function mn(e,n,t){f("intersectionWith","equals",t);const r=Array.isArray(n)?n:Array.from(n),o=[];for(const u of e){let i=0;for(;i<r.length&&!t(u,r[i]);)i++;if(i===r.length)continue;let l=0;for(;l<o.length&&!t(u,o[l]);)l++;l===o.length&&o.push(u)}return o}function yn(e,n,t="asc"){if(!Array.isArray(n))throw new TypeError(`orderBy: \`selectors\` must be an array of functions, got ${X(n)}`);const r=typeof t=="string";if(!r&&!Array.isArray(t))throw new TypeError(`orderBy: \`orders\` must be 'asc', 'desc' or an array of them, got ${X(t)}`);const o=n.length;if(!r&&t.length>o)throw new RangeError(`orderBy: \`orders\` must not be longer than \`selectors\` (${o}), got ${t.length} directions`);const u=r?E("orderBy","orders",t):0,i=[];for(let c=0;c<o;c++)typeof n[c]!="function"&&f("orderBy",`selectors[${c}]`,n[c]),i.push(r?u:E("orderBy","orders",t[c]??"asc",c));if(o===1)return te(e,n[0],i[0]===1?"asc":"desc");const l=e.length,s=[],a=[];for(let c=0;c<l;c++){for(let I=0;I<o;I++)s.push(D(n[I](e[c],c)));a.push(c)}_(a,function(c,I){for(let B=0;B<o;B++){const h=j(s[c*o+B],s[I*o+B],i[B]);if(h!==0)return h}return 0});const g=new Array(l);for(let c=0;c<l;c++)g[c]=e[a[c]];return g}function se(e,n,t,r,o){for(;;){let u=r;for(let s=2*r+1;s<=2*r+2&&s<t;s++){const a=j(n[s],n[u],o);(a>0||a===0&&e[s]>e[u])&&(u=s)}if(u===r)return;const i=e[r],l=n[r];e[r]=e[u],n[r]=n[u],e[u]=i,n[u]=l,r=u}}function ae(e,n,t,r,o){f(e,"selector",r);const u=E(e,"order",o),i=[],l=[];if(t===0)return[i,l,u];for(let s=0;s<t;s++)i.push(s),l.push(D(r(n[s],s)));for(let s=(t>>1)-1;s>=0;s--)se(i,l,t,s,u);for(let s=t;s<n.length;s++){const a=D(r(n[s],s));j(a,l[0],u)<0&&(i[0]=s,l[0]=a,se(i,l,t,0,u))}return[i,l,u]}function hn(e,n,t,r="asc"){if(R("takeFirstBy","n",n,0),n>=e.length)return f("takeFirstBy","selector",t),E("takeFirstBy","order",r),te(e,t,r);const[o,u,i]=ae("takeFirstBy",e,n,t,r),l=be(o.length);return _(l,function(s,a){return j(u[s],u[a],i)||o[s]-o[a]}),l.map(function(s){return e[o[s]]})}function pn(e,n,t,r="asc"){O("nthBy","index",n,Number.isInteger(n),"an integer");const o=n<0?e.length+n:n,[u]=ae("nthBy",e,o>=0&&o<e.length?o+1:0,t,r);return u.length===0?void 0:e[u[0]]}function fe(e,n,t,r,o,u){f(e,"selector",r);const i=E(e,"order",o),l=D(r(t));let s=0,a=n.length;for(;s<a;){const g=s+a>>>1,c=j(D(r(n[g])),l,i);c<0||u&&c===0?s=g+1:a=g}return s}function bn(e,n,t,r="asc"){return fe("sortedIndexBy",e,n,t,r,!1)}function gn(e,n,t,r="asc"){return fe("sortedLastIndexBy",e,n,t,r,!0)}function An(e,n,t){return J("sortedLastIndex",e,n,t,!0)[0]}function xn(e,n){return R("takeLast","n",n,0),S(e,Math.max(e.length-n,0),e.length)}function wn(e,n){return R("dropLast","n",n,0),S(e,0,Math.max(e.length-n,0))}function ce(e,n,t){f(e,"predicate",t);let r=n.length;for(;r>0&&t(n[r-1],r-1);)r--;return r}function Rn(e,n){return S(e,ce("takeLastWhile",e,n),e.length)}function Sn(e,n){return S(e,0,ce("dropLastWhile",e,n))}function kn(e,n){f("chunkBy","keyFn",n);const t=[];let r=[],o;for(let u=0;u<e.length;u++){const i=n(e[u],u);u>0&&(i===o||i!==i&&o!==o)?r.push(e[u]):(r=[e[u]],t.push(r)),o=i}return t}function In(e,n){f("splitWhen","predicate",n);let t=0;for(;t<e.length&&!n(e[t],t);)t++;return[S(e,0,t),S(e,t,e.length)]}function Bn(e,n,t){const r=$("swap","i",n,e.length,!1),o=$("swap","j",t,e.length,!1),u=Array.from(e);return u[r]=e[o],u[o]=e[r],u}function Kn(e,n){O("rotate","k",n,Number.isInteger(n),"an integer");const t=e.length,r=new Array(t),o=(n%t+t)%t;for(let u=0;u<t;u++)r[u]=e[u<o?u-o+t:u-o];return r}function vn(e,n,t){t!==void 0&&f("toggle","keyFn",t);const r=t===void 0?n:t(n),o=[];for(let u=0;u<e.length;u++){const i=e[u];Q(t===void 0?i:t(i),r)||o.push(i)}return o.length===e.length&&o.push(n),o}function Un(e){return e==null?[]:Array.isArray(e)?S(e,0,e.length):[e]}function Mn(e,n){if(e.length!==n.length)throw new RangeError(`zipObject: \`values\` must have as many items as \`keys\` (${e.length}), got ${n.length}`);const t=P();for(let r=0;r<e.length;r++)t[e[r]]=n[r];return Object.setPrototypeOf(t,Object.prototype)}function Nn(e,...n){f("zipWith","fn",e);const t=e;let r=n.length===0?0:n[0].length;for(let i=1;i<n.length;i++)r=Math.min(r,n[i].length);const o=new Array(r);if(n.length===2){const[i,l]=n;for(let s=0;s<r;s++)o[s]=t(i[s],l[s]);return o}const u=new Array(n.length);for(let i=0;i<r;i++){for(let l=0;l<n.length;l++)u[l]=n[l][i];o[i]=t(...u)}return o}function On(e,n,t=Math.random){R("sampleSize","n",n,0);const r=e.length,o=Math.min(n,r),u=new Array(o);if(r<=64*o){const l=S(e,0,r);for(let s=0;s<o;s++){const a=s+Math.floor(W("sampleSize",t)*(r-s));u[s]=l[a],l[a]=l[s]}return u}const i=new Map;for(let l=0;l<o;l++){const s=l+Math.floor(W("sampleSize",t)*(r-l));u[l]=e[i.get(s)??s],i.set(s,i.get(l)??l)}return u}function En(e,n){return f("averageBy","selector",n),oe(e,n,e.length)}function $n(e,n){f("medianBy","selector",n);const t=new Array(e.length);for(let r=0;r<e.length;r++)t[r]=n(e[r],r);return ye(t)}function H(e,n,t){if(n>N||t>N)throw new RangeError(`${e}: the result would contain ${n} tuples holding ${t} items, more than 2 ** 32 - 1`)}function Te(e,n){const t=new Array(n.length);for(let r=0;r<n.length;r++)t[r]=e[n[r]];return t}function Dn(e,n){R("combinations","k",n,0);const t=e.length;if(n>t)return[];let r=1;for(let i=0;i<n&&r<=N;i++)r=r*(t-i)/(i+1);H("combinations",r,r*n);const o=[],u=[];for(let i=0;i<n;i++)u.push(i);for(;;){o.push(Te(e,u));let i=n-1;for(;i>=0&&u[i]===t-n+i;)i--;if(i<0)return o;u[i]++;for(let l=i+1;l<n;l++)u[l]=u[l-1]+1}}function jn(e,n=e.length){R("permutations","k",n,0);const t=e.length;if(n>t)return[];let r=1;for(let s=0;s<n&&r<=N;s++)r*=t-s;H("permutations",r,r*n);const o=[],u=[],i=new Array(t).fill(!1);let l=0;for(;;){for(u.length===n&&(o.push(Te(e,u)),l=t);l<t&&i[l];)l++;if(l<t)i[l]=!0,u.push(l),l=0;else{if(u.length===0)return o;const s=u.pop();i[s]=!1,l=s+1}}}function Wn(e){const n=e.length;H("powerSet",2**n,n*2**(n-1));const t=[[]];for(let r=0;r<n;r++){const o=t.length;for(let u=0;u<o;u++){const i=t[u].slice();i.push(e[r]),t.push(i)}}return t}export{En as averageBy,nn as binarySearch,tn as cartesianProduct,Ee as chunk,kn as chunkBy,Dn as combinations,$e as compact,ke as contains,Ce as countBy,ln as diffSequences,ne as difference,on as differenceBy,dn as differenceWith,Ve as drop,wn as dropLast,Sn as dropLastWhile,Ie as first,Ke as flatten,ve as flattenDeep,je as groupBy,Le as insertAt,Me as intersection,un as intersectionBy,mn as intersectionWith,rn as intersperse,Oe as isSubset,We as keyBy,Be as last,sn as longestCommonSubsequence,_e as maxBy,$n as medianBy,Ye as minBy,Qe as move,pn as nthBy,yn as orderBy,Xe as pairwise,Pe as partition,jn as permutations,Wn as powerSet,be as range,He as removeAt,pe as removeDuplicates,Kn as rotate,qe as sample,On as sampleSize,Ze as shuffle,te as sortBy,en as sortedIndex,bn as sortedIndexBy,An as sortedLastIndex,gn as sortedLastIndexBy,In as splitWhen,Je as sumBy,Bn as swap,Ne as symmetricDifference,fn as symmetricDifferenceBy,Ge as take,hn as takeFirstBy,xn as takeLast,Rn as takeLastWhile,Un as toArray,vn as toggle,Ue as union,an as unionBy,Tn as unionWith,Fe as uniqueBy,cn as uniqueWith,Ae as unzip,ze as windowed,De as zip,Mn as zipObject,Nn as zipWith};
|