From 7c66b01cc4d610f7a80f6777b4ca429189d5f1fc Mon Sep 17 00:00:00 2001 From: Ray Epps Date: Sat, 7 Jan 2023 23:37:26 -0700 Subject: [PATCH 1/3] allow for default value in series prev/next --- src/series.ts | 17 ++++++++++++----- src/tests/series.test.ts | 8 ++++++++ 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/series.ts b/src/series.ts index 480736f2..08810479 100644 --- a/src/series.ts +++ b/src/series.ts @@ -55,16 +55,20 @@ export const series = ( * in the series or default if the given value is * the last item in the series */ - const next = (current: T): T => { - return itemsByIndex[indexesByKey[toKey(current)] + 1] ?? first() + const next = (current: T, defaultValue?: T): T => { + return ( + itemsByIndex[indexesByKey[toKey(current)] + 1] ?? defaultValue ?? first() + ) } /** * Given an item in the series returns the previous item * in the series or default if the given value is * the first item in the series */ - const previous = (current: T): T => { - return itemsByIndex[indexesByKey[toKey(current)] - 1] ?? last() + const previous = (current: T, defaultValue?: T): T => { + return ( + itemsByIndex[indexesByKey[toKey(current)] - 1] ?? defaultValue ?? last() + ) } /** * A more dynamic method than next and previous that @@ -76,7 +80,10 @@ export const series = ( if (num === 0) return current const abs = Math.abs(num) const rel = abs > items.length ? abs % items.length : abs - return list(0, rel - 1).reduce(num > 0 ? next : previous, current) + return list(0, rel - 1).reduce( + acc => (num > 0 ? next(acc) : previous(acc)), + current + ) } return { min, diff --git a/src/tests/series.test.ts b/src/tests/series.test.ts index a30ac482..66abd08a 100644 --- a/src/tests/series.test.ts +++ b/src/tests/series.test.ts @@ -56,6 +56,10 @@ describe('series module', () => { const result = sut.next('friday') assert.equal(result, 'monday') }) + test('returns the given default when the last is exhausted', () => { + const result = sut.next('friday', 'wednesday') + assert.equal(result, 'wednesday') + }) }) describe('previous function', () => { @@ -67,6 +71,10 @@ describe('series module', () => { const result = sut.previous('monday') assert.equal(result, 'friday') }) + test('returns the given default when the first is exhausted', () => { + const result = sut.previous('monday', 'wednesday') + assert.equal(result, 'wednesday') + }) }) describe('spin function', () => { From aa2071d8c231a5eaf573a7bc916fb18cba439b14 Mon Sep 17 00:00:00 2001 From: Ray Epps Date: Sat, 7 Jan 2023 23:39:00 -0700 Subject: [PATCH 2/3] bump version -> 10.6.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7eb2a180..22dc066b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "radash", - "version": "10.5.0", + "version": "10.6.0", "description": "Functional utility library - modern, simple, typed, powerful", "main": "dist/cjs/index.cjs", "module": "dist/esm/index.mjs", From d2ad4e0653b851c94e75aff1a9471a4ca9903ac2 Mon Sep 17 00:00:00 2001 From: Ray Epps Date: Sat, 7 Jan 2023 23:47:58 -0700 Subject: [PATCH 3/3] run build --- cdn/radash.esm.js | 13 ++++++++----- cdn/radash.js | 13 ++++++++----- cdn/radash.min.js | 2 +- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/cdn/radash.esm.js b/cdn/radash.esm.js index 1edb270e..848d1f33 100644 --- a/cdn/radash.esm.js +++ b/cdn/radash.esm.js @@ -761,18 +761,21 @@ const series = (items, toKey = (item) => `${item}`) => { const last = () => { return itemsByIndex[items.length - 1]; }; - const next = (current) => { - return itemsByIndex[indexesByKey[toKey(current)] + 1] ?? first(); + const next = (current, defaultValue) => { + return itemsByIndex[indexesByKey[toKey(current)] + 1] ?? defaultValue ?? first(); }; - const previous = (current) => { - return itemsByIndex[indexesByKey[toKey(current)] - 1] ?? last(); + const previous = (current, defaultValue) => { + return itemsByIndex[indexesByKey[toKey(current)] - 1] ?? defaultValue ?? last(); }; const spin = (current, num) => { if (num === 0) return current; const abs = Math.abs(num); const rel = abs > items.length ? abs % items.length : abs; - return list(0, rel - 1).reduce(num > 0 ? next : previous, current); + return list(0, rel - 1).reduce( + (acc) => num > 0 ? next(acc) : previous(acc), + current + ); }; return { min, diff --git a/cdn/radash.js b/cdn/radash.js index 82616263..b37f204e 100644 --- a/cdn/radash.js +++ b/cdn/radash.js @@ -764,18 +764,21 @@ var radash = (function (exports) { const last = () => { return itemsByIndex[items.length - 1]; }; - const next = (current) => { - return itemsByIndex[indexesByKey[toKey(current)] + 1] ?? first(); + const next = (current, defaultValue) => { + return itemsByIndex[indexesByKey[toKey(current)] + 1] ?? defaultValue ?? first(); }; - const previous = (current) => { - return itemsByIndex[indexesByKey[toKey(current)] - 1] ?? last(); + const previous = (current, defaultValue) => { + return itemsByIndex[indexesByKey[toKey(current)] - 1] ?? defaultValue ?? last(); }; const spin = (current, num) => { if (num === 0) return current; const abs = Math.abs(num); const rel = abs > items.length ? abs % items.length : abs; - return list(0, rel - 1).reduce(num > 0 ? next : previous, current); + return list(0, rel - 1).reduce( + (acc) => num > 0 ? next(acc) : previous(acc), + current + ); }; return { min, diff --git a/cdn/radash.min.js b/cdn/radash.min.js index ea876fbb..67adc80c 100644 --- a/cdn/radash.min.js +++ b/cdn/radash.min.js @@ -1 +1 @@ -var radash=function(s){"use strict";const _=t=>!!t&&t.constructor===Symbol,b=t=>!!t&&t.constructor===Array,k=t=>!!t&&t.constructor===Object,j=t=>t==null||typeof t!="object"&&typeof t!="function",p=t=>!!(t&&t.constructor&&t.call&&t.apply),R=t=>typeof t=="string"||t instanceof String,Z=t=>h(t)&&t%1===0,q=t=>h(t)&&t%1!==0,h=t=>{try{return Number(t)===t}catch{return!1}},z=t=>Object.prototype.toString.call(t)==="[object Date]",I=t=>{if(t===!0||t===!1||t==null)return!0;if(h(t))return t===0;if(z(t))return isNaN(t.getTime());if(p(t)||_(t))return!1;const e=t.length;if(h(e))return e===0;const n=t.size;return h(n)?n===0:Object.keys(t).length===0},P=(t,e)=>{if(Object.is(t,e))return!0;if(t instanceof Date&&e instanceof Date)return t.getTime()===e.getTime();if(t instanceof RegExp&&e instanceof RegExp)return t.toString()===e.toString();if(typeof t!="object"||t===null||typeof e!="object"||e===null)return!1;const n=Reflect.ownKeys(t),r=Reflect.ownKeys(e);if(n.length!==r.length)return!1;for(let i=0;it.reduce((n,r)=>{const i=e(r);return n[i]||(n[i]=[]),n[i].push(r),n},{});function K(...t){return!t||!t.length?[]:new Array(Math.max(...t.map(({length:e})=>e))).fill([]).map((e,n)=>t.map(r=>r[n]))}function J(t,e){if(!t||!t.length)return{};const n=p(e)?e:b(e)?(r,i)=>e[i]:(r,i)=>e;return t.reduce((r,i,u)=>(r[i]=n(i,u),r),{})}const O=(t,e)=>!t||(t.length??0)===0?null:t.reduce(e),W=(t,e)=>(t||[]).reduce((n,r)=>n+(e?e(r):r),0),X=(t,e=void 0)=>t?.length>0?t[0]:e,Y=(t,e=void 0)=>t?.length>0?t[t.length-1]:e,S=(t,e,n=!1)=>{if(!t)return[];const r=(u,c)=>e(u)-e(c),i=(u,c)=>e(c)-e(u);return t.slice().sort(n===!0?i:r)},G=(t,e,n="asc")=>{if(!t)return[];const r=(u,c)=>`${e(u)}`.localeCompare(e(c)),i=(u,c)=>`${e(c)}`.localeCompare(e(u));return t.slice().sort(n==="desc"?i:r)},H=(t,e)=>t?t.reduce((n,r)=>{const i=e(r);return n[i]=(n[i]??0)+1,n},{}):{},Q=(t,e,n)=>{if(!t)return[];if(!e)return[...t];for(let r=0;rr)=>t.reduce((r,i)=>(r[e(i)]=n(i),r),{}),V=(t,e,n)=>t?t.reduce((r,i,u)=>(n(i,u)&&r.push(e(i,u)),r),[]):[],v=(t,e)=>{const n=e||(r=>r);return O(t,(r,i)=>n(r)>n(i)?r:i)},x=(t,e)=>{const n=e||(r=>r);return O(t,(r,i)=>n(r){const n=Math.ceil(t.length/e);return new Array(n).fill(null).map((r,i)=>t.slice(i*e,i*e+e))},et=(t,e)=>{const n=t.reduce((r,i)=>{const u=e?e(i):i;return r[u]||(r[u]=i),r},{});return Object.values(n)};function*A(t,e,n=i=>i,r=1){const i=p(n)?n:()=>n,u=e?t:0,c=e??t;for(let o=u;o<=c&&(yield i(o),!(o+r>c));o+=r);}const C=(t,e,n,r)=>Array.from(A(t,e,n,r)),nt=t=>t.reduce((e,n)=>(e.push(...n),e),[]),rt=(t,e,n)=>{if(!t||!e)return!1;const r=n??(u=>u),i=e.reduce((u,c)=>(u[r(c)]=!0,u),{});return t.some(u=>i[r(u)])},B=(t,e)=>t?t.reduce((n,r)=>{const[i,u]=n;return e(r)?[[...i,r],u]:[i,[...u,r]]},[[],[]]):[[],[]],it=(t,e,n)=>!e&&!t?[]:e?t?n?t.reduce((r,i)=>{const u=e.find(c=>n(i)===n(c));return u?r.push(u):r.push(i),r},[]):t:[]:t,st=(t,e,n)=>{if(!t&&!e)return[];if(!e)return[...t];if(!t)return[e];for(let r=0;r{if(!t&&!e)return[];if(!t)return[e];if(!e)return[...t];const i=n?(o,l)=>n(o,l)===n(e,l):o=>o===e;return t.find(i)?t.filter((o,l)=>!i(o,l)):(r?.strategy??"append")==="append"?[...t,e]:[e,...t]},ct=t=>t?.filter(e=>!!e)??[],L=(t,e,n)=>{let r=n;for(let i=1;i<=t;i++)r=e(r,i);return r},ot=(t,e,n=r=>r)=>{if(!t?.length&&!e?.length)return[];if(t?.length===void 0)return[...e];if(!e?.length)return[...t];const r=e.reduce((i,u)=>(i[n(u)]=!0,i),{});return t.filter(i=>!r[n(i)])};function ft(t,e){if(t.length===0)return t;const n=e%t.length;return n===0?t:[...t.slice(-n,t.length),...t.slice(0,-n)]}const lt=async(t,e,n)=>{const r=n!==void 0;if(!r&&t?.length<1)throw new Error("Cannot reduce empty array with no init value");const i=r?t:t.slice(1);let u=r?n:t[0];for(const c of i)u=await e(u,c);return u},at=async(t,e)=>{if(!t)return[];let n=[],r=0;for(const i of t){const u=await e(i,r++);n.push(u)}return n},dt=async t=>{const e=[],n=(u,c)=>e.push({fn:u,rethrow:c?.rethrow??!1}),[r,i]=await m(t)(n);for(const{fn:u,rethrow:c}of e){const[o]=await m(u)(r);if(c)throw o}if(r)throw r;return i};class gt extends Error{constructor(e=[]){super();const n=e.find(r=>r.name)?.name??"";this.name=`AggregateError(${n}...)`,this.message=`AggregateError with ${e.length} errors`,this.stack=e.find(r=>r.stack)?.stack??this.stack,this.errors=e}}const ht=async(t,e,n)=>{const r=e.map((a,y)=>({index:y,item:a})),i=async a=>{const y=[];for(;;){const f=r.pop();if(!f)return a(y);const[d,g]=await m(n)(f.item);y.push({error:d,result:g,index:f.index})}},u=C(1,t).map(()=>new Promise(i)),c=await Promise.all(u),[o,l]=B(S(c.flat(),a=>a.index),a=>!!a.error);if(o.length>0)throw new gt(o.map(a=>a.error));return l.map(a=>a.result)},mt=async(t,e)=>{const n=t?.times??3,r=t?.delay,i=t?.backoff??null;for(const u of A(1,n)){const[c,o]=await m(e)(l=>{throw{_exited:l}});if(!c)return o;if(c._exited)throw c._exited;if(u===n)throw c;r&&await E(r),i&&await E(i(u))}},E=t=>new Promise(e=>setTimeout(e,t)),m=t=>async(...e)=>{try{return[void 0,await t(...e)]}catch(n){return[n,void 0]}},wt=(...t)=>(...e)=>t.slice(1).reduce((n,r)=>r(n),t[0](...e)),yt=(...t)=>t.reverse().reduce((e,n)=>n(e)),pt=(t,...e)=>(...n)=>t(...e,...n),bt=(t,e)=>n=>t({...e,...n}),kt=t=>new Proxy({},{get:(e,n)=>t(n)}),Ot=(t,e,n,r)=>function(...u){const c=n?n(...u):JSON.stringify({args:u}),o=t[c];if(o!==void 0&&(!o.exp||o.exp>new Date().getTime()))return o.value;const l=e(...u);return t[c]={exp:r?new Date().getTime()+r:null,value:l},l},At=(t,e={})=>Ot({},t,e.key??null,e.ttl??null),Ct=({delay:t},e)=>{let n,r=!0;const i=(...u)=>{r?(clearTimeout(n),n=setTimeout(()=>{r&&e(...u)},t)):e(...u)};return i.cancel=()=>{r=!1},i.flush=(...u)=>e(...u),i},Et=({interval:t},e)=>{let n=!0;return(...i)=>{n&&(e(...i),n=!1,setTimeout(()=>{n=!0},t))}},$t=(t,e)=>{const n=()=>{};return new Proxy(Object.assign(n,t),{get:(r,i)=>r[i],set:(r,i,u)=>(r[i]=u,!0),apply:(r,i,u)=>e(Object.assign({},r))(...u)})},Nt=(t,e)=>{const n=e===void 0?0:e;if(t==null)return n;const r=parseFloat(t);return isNaN(r)?n:r},_t=(t,e)=>{const n=e===void 0?0:e;if(t==null)return n;const r=parseInt(t);return isNaN(r)?n:r},jt=(t,e=n=>n===void 0)=>t?Object.keys(t).reduce((r,i)=>(e(t[i])||(r[i]=t[i]),r),{}):{},$=(t,e)=>Object.keys(t).reduce((r,i)=>(r[e(i,t[i])]=t[i],r),{}),zt=(t,e)=>Object.keys(t).reduce((r,i)=>(r[i]=e(t[i],i),r),{}),Pt=(t,e)=>t?Object.entries(t).reduce((n,[r,i])=>{const[u,c]=e(r,i);return n[u]=c,n},{}):{},St=t=>t?Object.keys(t).reduce((n,r)=>(n[t[r]]=r,n),{}):{},Tt=t=>$(t,e=>e.toLowerCase()),Bt=t=>$(t,e=>e.toUpperCase()),Lt=t=>{if(j(t))return t;if(typeof t=="function")return t.bind({});const e=new t.constructor;return Object.getOwnPropertyNames(t).forEach(n=>{e[n]=t[n]}),e},Mt=(t,e)=>{if(!t)return[];const n=Object.entries(t);return n.length===0?[]:n.reduce((r,i)=>(r.push(e(i[0],i[1])),r),[])},Dt=(t,e)=>t?e.reduce((n,r)=>(t.hasOwnProperty(r)&&(n[r]=t[r]),n),{}):{},Ft=(t,e)=>t?!e||e.length===0?t:e.reduce((n,r)=>(delete n[r],n),{...t}):{},M=(t,e,n=null)=>{const r=e.split(/[\.\[\]]/g);let i=t;for(const u of r){if(i===null||i===void 0)return n;u.trim()!==""&&(i=i[u])}return i===void 0?n:i},D=(t,e)=>!t&&!e?{}:t?e?Object.entries(t).reduce((n,[r,i])=>({...n,[r]:(()=>k(i)?D(i,e[r]):e[r])()}),{}):t:e,F=t=>{if(!t)return[];const e=(n,r)=>k(n)?Object.entries(n).flatMap(([i,u])=>e(u,[...r,i])):b(n)?n.flatMap((i,u)=>e(i,[...r,`${u}`])):[r.join(".")];return e(t,[])},Rt=t=>t?T(F(t),e=>e,e=>M(t,e)):{},N=(t,e)=>Math.floor(Math.random()*(e-t+1)+t),Zt=t=>{const e=t.length;if(e===0)return null;const n=N(0,e-1);return t[n]},qt=t=>t.map(e=>({rand:Math.random(),value:e})).sort((e,n)=>e.rand-n.rand).map(e=>e.value),It=(t,e="")=>{const n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"+e;return L(t,r=>r+n.charAt(N(0,n.length-1)),"")},Ut=(t,e=n=>`${n}`)=>{const{indexesByKey:n,itemsByIndex:r}=t.reduce((f,d,g)=>({indexesByKey:{...f.indexesByKey,[e(d)]:g},itemsByIndex:{...f.itemsByIndex,[g]:d}}),{indexesByKey:{},itemsByIndex:{}}),i=(f,d)=>n[e(f)]n[e(f)]>n[e(d)]?f:d,c=()=>r[0],o=()=>r[t.length-1],l=f=>r[n[e(f)]+1]??c(),a=f=>r[n[e(f)]-1]??o();return{min:i,max:u,first:c,last:o,next:l,previous:a,spin:(f,d)=>{if(d===0)return f;const g=Math.abs(d),Qt=g>t.length?g%t.length:g;return C(0,Qt-1).reduce(d>0?l:a,f)}}},w=t=>{if(!t||t.length===0)return"";const e=t.toLowerCase();return e.substring(0,1).toUpperCase()+e.substring(1,e.length)},Kt=t=>{const e=t?.replace(/([A-Z])+/g,w)?.split(/(?=[A-Z])|[\.\-\s_]/).map(n=>n.toLowerCase())??[];return e.length===0?"":e.length===1?e[0]:e.reduce((n,r)=>`${n}${r.charAt(0).toUpperCase()}${r.slice(1)}`)},Jt=t=>{const e=t?.replace(/([A-Z])+/g,w).split(/(?=[A-Z])|[\.\-\s_]/).map(n=>n.toLowerCase())??[];return e.length===0?"":e.length===1?e[0]:e.reduce((n,r)=>`${n}_${r.toLowerCase()}`)},Wt=t=>{const e=t?.replace(/([A-Z])+/g,w)?.split(/(?=[A-Z])|[\.\-\s_]/).map(n=>n.toLowerCase())??[];return e.length===0?"":e.length===1?e[0]:e.reduce((n,r)=>`${n}-${r.toLowerCase()}`)},Xt=t=>{const e=t?.split(/[\.\-\s_]/).map(n=>n.toLowerCase())??[];return e.length===0?"":e.map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join("")},Yt=t=>t?t.split(/(?=[A-Z])|[\.\-\s_]/).map(e=>e.trim()).filter(e=>!!e).map(e=>w(e.toLowerCase())).join(" "):"",Gt=(t,e,n=/\{\{(.+?)\}\}/g)=>Array.from(t.matchAll(n)).reduce((r,i)=>r.replace(i[0],e[i[1]]),t),Ht=(t,e=" ")=>{if(!t)return"";const n=new RegExp(`^[${e}]+|[${e}]+$`,"g");return t.replace(n,"")};return s.alphabetical=G,s.assign=D,s.boil=O,s.callable=$t,s.camel=Kt,s.capitalize=w,s.chain=wt,s.clone=Lt,s.cluster=tt,s.compose=yt,s.counting=H,s.crush=Rt,s.dash=Wt,s.debounce=Ct,s.defer=dt,s.diff=ot,s.draw=Zt,s.first=X,s.flat=nt,s.fork=B,s.get=M,s.group=U,s.intersects=rt,s.invert=St,s.isArray=b,s.isDate=z,s.isEmpty=I,s.isEqual=P,s.isFloat=q,s.isFunction=p,s.isInt=Z,s.isNumber=h,s.isObject=k,s.isPrimitive=j,s.isString=R,s.isSymbol=_,s.iterate=L,s.keys=F,s.last=Y,s.list=C,s.listify=Mt,s.lowerize=Tt,s.map=at,s.mapEntries=Pt,s.mapKeys=$,s.mapValues=zt,s.max=v,s.memo=At,s.merge=it,s.min=x,s.objectify=T,s.omit=Ft,s.parallel=ht,s.partial=pt,s.partob=bt,s.pascal=Xt,s.pick=Dt,s.proxied=kt,s.random=N,s.range=A,s.reduce=lt,s.replace=Q,s.replaceOrAppend=st,s.retry=mt,s.select=V,s.series=Ut,s.shake=jt,s.shift=ft,s.shuffle=qt,s.sift=ct,s.sleep=E,s.snake=Jt,s.sort=S,s.sum=W,s.template=Gt,s.throttle=Et,s.title=Yt,s.toFloat=Nt,s.toInt=_t,s.toggle=ut,s.trim=Ht,s.try=m,s.tryit=m,s.uid=It,s.unique=et,s.upperize=Bt,s.zip=K,s.zipToObject=J,s}({}); +var radash=function(s){"use strict";const _=t=>!!t&&t.constructor===Symbol,b=t=>!!t&&t.constructor===Array,k=t=>!!t&&t.constructor===Object,j=t=>t==null||typeof t!="object"&&typeof t!="function",p=t=>!!(t&&t.constructor&&t.call&&t.apply),Z=t=>typeof t=="string"||t instanceof String,q=t=>h(t)&&t%1===0,I=t=>h(t)&&t%1!==0,h=t=>{try{return Number(t)===t}catch{return!1}},z=t=>Object.prototype.toString.call(t)==="[object Date]",U=t=>{if(t===!0||t===!1||t==null)return!0;if(h(t))return t===0;if(z(t))return isNaN(t.getTime());if(p(t)||_(t))return!1;const e=t.length;if(h(e))return e===0;const n=t.size;return h(n)?n===0:Object.keys(t).length===0},P=(t,e)=>{if(Object.is(t,e))return!0;if(t instanceof Date&&e instanceof Date)return t.getTime()===e.getTime();if(t instanceof RegExp&&e instanceof RegExp)return t.toString()===e.toString();if(typeof t!="object"||t===null||typeof e!="object"||e===null)return!1;const n=Reflect.ownKeys(t),r=Reflect.ownKeys(e);if(n.length!==r.length)return!1;for(let i=0;it.reduce((n,r)=>{const i=e(r);return n[i]||(n[i]=[]),n[i].push(r),n},{});function J(...t){return!t||!t.length?[]:new Array(Math.max(...t.map(({length:e})=>e))).fill([]).map((e,n)=>t.map(r=>r[n]))}function W(t,e){if(!t||!t.length)return{};const n=p(e)?e:b(e)?(r,i)=>e[i]:(r,i)=>e;return t.reduce((r,i,u)=>(r[i]=n(i,u),r),{})}const O=(t,e)=>!t||(t.length??0)===0?null:t.reduce(e),X=(t,e)=>(t||[]).reduce((n,r)=>n+(e?e(r):r),0),Y=(t,e=void 0)=>t?.length>0?t[0]:e,G=(t,e=void 0)=>t?.length>0?t[t.length-1]:e,S=(t,e,n=!1)=>{if(!t)return[];const r=(u,c)=>e(u)-e(c),i=(u,c)=>e(c)-e(u);return t.slice().sort(n===!0?i:r)},H=(t,e,n="asc")=>{if(!t)return[];const r=(u,c)=>`${e(u)}`.localeCompare(e(c)),i=(u,c)=>`${e(c)}`.localeCompare(e(u));return t.slice().sort(n==="desc"?i:r)},Q=(t,e)=>t?t.reduce((n,r)=>{const i=e(r);return n[i]=(n[i]??0)+1,n},{}):{},V=(t,e,n)=>{if(!t)return[];if(!e)return[...t];for(let r=0;rr)=>t.reduce((r,i)=>(r[e(i)]=n(i),r),{}),v=(t,e,n)=>t?t.reduce((r,i,u)=>(n(i,u)&&r.push(e(i,u)),r),[]):[],x=(t,e)=>{const n=e||(r=>r);return O(t,(r,i)=>n(r)>n(i)?r:i)},tt=(t,e)=>{const n=e||(r=>r);return O(t,(r,i)=>n(r){const n=Math.ceil(t.length/e);return new Array(n).fill(null).map((r,i)=>t.slice(i*e,i*e+e))},nt=(t,e)=>{const n=t.reduce((r,i)=>{const u=e?e(i):i;return r[u]||(r[u]=i),r},{});return Object.values(n)};function*A(t,e,n=i=>i,r=1){const i=p(n)?n:()=>n,u=e?t:0,c=e??t;for(let o=u;o<=c&&(yield i(o),!(o+r>c));o+=r);}const C=(t,e,n,r)=>Array.from(A(t,e,n,r)),rt=t=>t.reduce((e,n)=>(e.push(...n),e),[]),it=(t,e,n)=>{if(!t||!e)return!1;const r=n??(u=>u),i=e.reduce((u,c)=>(u[r(c)]=!0,u),{});return t.some(u=>i[r(u)])},B=(t,e)=>t?t.reduce((n,r)=>{const[i,u]=n;return e(r)?[[...i,r],u]:[i,[...u,r]]},[[],[]]):[[],[]],st=(t,e,n)=>!e&&!t?[]:e?t?n?t.reduce((r,i)=>{const u=e.find(c=>n(i)===n(c));return u?r.push(u):r.push(i),r},[]):t:[]:t,ut=(t,e,n)=>{if(!t&&!e)return[];if(!e)return[...t];if(!t)return[e];for(let r=0;r{if(!t&&!e)return[];if(!t)return[e];if(!e)return[...t];const i=n?(o,a)=>n(o,a)===n(e,a):o=>o===e;return t.find(i)?t.filter((o,a)=>!i(o,a)):(r?.strategy??"append")==="append"?[...t,e]:[e,...t]},ot=t=>t?.filter(e=>!!e)??[],L=(t,e,n)=>{let r=n;for(let i=1;i<=t;i++)r=e(r,i);return r},ft=(t,e,n=r=>r)=>{if(!t?.length&&!e?.length)return[];if(t?.length===void 0)return[...e];if(!e?.length)return[...t];const r=e.reduce((i,u)=>(i[n(u)]=!0,i),{});return t.filter(i=>!r[n(i)])};function lt(t,e){if(t.length===0)return t;const n=e%t.length;return n===0?t:[...t.slice(-n,t.length),...t.slice(0,-n)]}const at=async(t,e,n)=>{const r=n!==void 0;if(!r&&t?.length<1)throw new Error("Cannot reduce empty array with no init value");const i=r?t:t.slice(1);let u=r?n:t[0];for(const c of i)u=await e(u,c);return u},dt=async(t,e)=>{if(!t)return[];let n=[],r=0;for(const i of t){const u=await e(i,r++);n.push(u)}return n},gt=async t=>{const e=[],n=(u,c)=>e.push({fn:u,rethrow:c?.rethrow??!1}),[r,i]=await m(t)(n);for(const{fn:u,rethrow:c}of e){const[o]=await m(u)(r);if(c)throw o}if(r)throw r;return i};class ht extends Error{constructor(e=[]){super();const n=e.find(r=>r.name)?.name??"";this.name=`AggregateError(${n}...)`,this.message=`AggregateError with ${e.length} errors`,this.stack=e.find(r=>r.stack)?.stack??this.stack,this.errors=e}}const mt=async(t,e,n)=>{const r=e.map((d,y)=>({index:y,item:d})),i=async d=>{const y=[];for(;;){const f=r.pop();if(!f)return d(y);const[l,g]=await m(n)(f.item);y.push({error:l,result:g,index:f.index})}},u=C(1,t).map(()=>new Promise(i)),c=await Promise.all(u),[o,a]=B(S(c.flat(),d=>d.index),d=>!!d.error);if(o.length>0)throw new ht(o.map(d=>d.error));return a.map(d=>d.result)},wt=async(t,e)=>{const n=t?.times??3,r=t?.delay,i=t?.backoff??null;for(const u of A(1,n)){const[c,o]=await m(e)(a=>{throw{_exited:a}});if(!c)return o;if(c._exited)throw c._exited;if(u===n)throw c;r&&await E(r),i&&await E(i(u))}},E=t=>new Promise(e=>setTimeout(e,t)),m=t=>async(...e)=>{try{return[void 0,await t(...e)]}catch(n){return[n,void 0]}},yt=(...t)=>(...e)=>t.slice(1).reduce((n,r)=>r(n),t[0](...e)),pt=(...t)=>t.reverse().reduce((e,n)=>n(e)),bt=(t,...e)=>(...n)=>t(...e,...n),kt=(t,e)=>n=>t({...e,...n}),Ot=t=>new Proxy({},{get:(e,n)=>t(n)}),At=(t,e,n,r)=>function(...u){const c=n?n(...u):JSON.stringify({args:u}),o=t[c];if(o!==void 0&&(!o.exp||o.exp>new Date().getTime()))return o.value;const a=e(...u);return t[c]={exp:r?new Date().getTime()+r:null,value:a},a},Ct=(t,e={})=>At({},t,e.key??null,e.ttl??null),Et=({delay:t},e)=>{let n,r=!0;const i=(...u)=>{r?(clearTimeout(n),n=setTimeout(()=>{r&&e(...u)},t)):e(...u)};return i.cancel=()=>{r=!1},i.flush=(...u)=>e(...u),i},$t=({interval:t},e)=>{let n=!0;return(...i)=>{n&&(e(...i),n=!1,setTimeout(()=>{n=!0},t))}},Nt=(t,e)=>{const n=()=>{};return new Proxy(Object.assign(n,t),{get:(r,i)=>r[i],set:(r,i,u)=>(r[i]=u,!0),apply:(r,i,u)=>e(Object.assign({},r))(...u)})},_t=(t,e)=>{const n=e===void 0?0:e;if(t==null)return n;const r=parseFloat(t);return isNaN(r)?n:r},jt=(t,e)=>{const n=e===void 0?0:e;if(t==null)return n;const r=parseInt(t);return isNaN(r)?n:r},zt=(t,e=n=>n===void 0)=>t?Object.keys(t).reduce((r,i)=>(e(t[i])||(r[i]=t[i]),r),{}):{},$=(t,e)=>Object.keys(t).reduce((r,i)=>(r[e(i,t[i])]=t[i],r),{}),Pt=(t,e)=>Object.keys(t).reduce((r,i)=>(r[i]=e(t[i],i),r),{}),St=(t,e)=>t?Object.entries(t).reduce((n,[r,i])=>{const[u,c]=e(r,i);return n[u]=c,n},{}):{},Tt=t=>t?Object.keys(t).reduce((n,r)=>(n[t[r]]=r,n),{}):{},Bt=t=>$(t,e=>e.toLowerCase()),Lt=t=>$(t,e=>e.toUpperCase()),Mt=t=>{if(j(t))return t;if(typeof t=="function")return t.bind({});const e=new t.constructor;return Object.getOwnPropertyNames(t).forEach(n=>{e[n]=t[n]}),e},Dt=(t,e)=>{if(!t)return[];const n=Object.entries(t);return n.length===0?[]:n.reduce((r,i)=>(r.push(e(i[0],i[1])),r),[])},Ft=(t,e)=>t?e.reduce((n,r)=>(t.hasOwnProperty(r)&&(n[r]=t[r]),n),{}):{},Rt=(t,e)=>t?!e||e.length===0?t:e.reduce((n,r)=>(delete n[r],n),{...t}):{},M=(t,e,n=null)=>{const r=e.split(/[\.\[\]]/g);let i=t;for(const u of r){if(i===null||i===void 0)return n;u.trim()!==""&&(i=i[u])}return i===void 0?n:i},D=(t,e)=>!t&&!e?{}:t?e?Object.entries(t).reduce((n,[r,i])=>({...n,[r]:(()=>k(i)?D(i,e[r]):e[r])()}),{}):t:e,F=t=>{if(!t)return[];const e=(n,r)=>k(n)?Object.entries(n).flatMap(([i,u])=>e(u,[...r,i])):b(n)?n.flatMap((i,u)=>e(i,[...r,`${u}`])):[r.join(".")];return e(t,[])},Zt=t=>t?T(F(t),e=>e,e=>M(t,e)):{},N=(t,e)=>Math.floor(Math.random()*(e-t+1)+t),qt=t=>{const e=t.length;if(e===0)return null;const n=N(0,e-1);return t[n]},It=t=>t.map(e=>({rand:Math.random(),value:e})).sort((e,n)=>e.rand-n.rand).map(e=>e.value),Ut=(t,e="")=>{const n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"+e;return L(t,r=>r+n.charAt(N(0,n.length-1)),"")},Kt=(t,e=n=>`${n}`)=>{const{indexesByKey:n,itemsByIndex:r}=t.reduce((f,l,g)=>({indexesByKey:{...f.indexesByKey,[e(l)]:g},itemsByIndex:{...f.itemsByIndex,[g]:l}}),{indexesByKey:{},itemsByIndex:{}}),i=(f,l)=>n[e(f)]n[e(f)]>n[e(l)]?f:l,c=()=>r[0],o=()=>r[t.length-1],a=(f,l)=>r[n[e(f)]+1]??l??c(),d=(f,l)=>r[n[e(f)]-1]??l??o();return{min:i,max:u,first:c,last:o,next:a,previous:d,spin:(f,l)=>{if(l===0)return f;const g=Math.abs(l),Vt=g>t.length?g%t.length:g;return C(0,Vt-1).reduce(R=>l>0?a(R):d(R),f)}}},w=t=>{if(!t||t.length===0)return"";const e=t.toLowerCase();return e.substring(0,1).toUpperCase()+e.substring(1,e.length)},Jt=t=>{const e=t?.replace(/([A-Z])+/g,w)?.split(/(?=[A-Z])|[\.\-\s_]/).map(n=>n.toLowerCase())??[];return e.length===0?"":e.length===1?e[0]:e.reduce((n,r)=>`${n}${r.charAt(0).toUpperCase()}${r.slice(1)}`)},Wt=t=>{const e=t?.replace(/([A-Z])+/g,w).split(/(?=[A-Z])|[\.\-\s_]/).map(n=>n.toLowerCase())??[];return e.length===0?"":e.length===1?e[0]:e.reduce((n,r)=>`${n}_${r.toLowerCase()}`)},Xt=t=>{const e=t?.replace(/([A-Z])+/g,w)?.split(/(?=[A-Z])|[\.\-\s_]/).map(n=>n.toLowerCase())??[];return e.length===0?"":e.length===1?e[0]:e.reduce((n,r)=>`${n}-${r.toLowerCase()}`)},Yt=t=>{const e=t?.split(/[\.\-\s_]/).map(n=>n.toLowerCase())??[];return e.length===0?"":e.map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join("")},Gt=t=>t?t.split(/(?=[A-Z])|[\.\-\s_]/).map(e=>e.trim()).filter(e=>!!e).map(e=>w(e.toLowerCase())).join(" "):"",Ht=(t,e,n=/\{\{(.+?)\}\}/g)=>Array.from(t.matchAll(n)).reduce((r,i)=>r.replace(i[0],e[i[1]]),t),Qt=(t,e=" ")=>{if(!t)return"";const n=new RegExp(`^[${e}]+|[${e}]+$`,"g");return t.replace(n,"")};return s.alphabetical=H,s.assign=D,s.boil=O,s.callable=Nt,s.camel=Jt,s.capitalize=w,s.chain=yt,s.clone=Mt,s.cluster=et,s.compose=pt,s.counting=Q,s.crush=Zt,s.dash=Xt,s.debounce=Et,s.defer=gt,s.diff=ft,s.draw=qt,s.first=Y,s.flat=rt,s.fork=B,s.get=M,s.group=K,s.intersects=it,s.invert=Tt,s.isArray=b,s.isDate=z,s.isEmpty=U,s.isEqual=P,s.isFloat=I,s.isFunction=p,s.isInt=q,s.isNumber=h,s.isObject=k,s.isPrimitive=j,s.isString=Z,s.isSymbol=_,s.iterate=L,s.keys=F,s.last=G,s.list=C,s.listify=Dt,s.lowerize=Bt,s.map=dt,s.mapEntries=St,s.mapKeys=$,s.mapValues=Pt,s.max=x,s.memo=Ct,s.merge=st,s.min=tt,s.objectify=T,s.omit=Rt,s.parallel=mt,s.partial=bt,s.partob=kt,s.pascal=Yt,s.pick=Ft,s.proxied=Ot,s.random=N,s.range=A,s.reduce=at,s.replace=V,s.replaceOrAppend=ut,s.retry=wt,s.select=v,s.series=Kt,s.shake=zt,s.shift=lt,s.shuffle=It,s.sift=ot,s.sleep=E,s.snake=Wt,s.sort=S,s.sum=X,s.template=Ht,s.throttle=$t,s.title=Gt,s.toFloat=_t,s.toInt=jt,s.toggle=ct,s.trim=Qt,s.try=m,s.tryit=m,s.uid=Ut,s.unique=nt,s.upperize=Lt,s.zip=J,s.zipToObject=W,s}({});