fp-toolkit
Advanced tools
Comparing version 1.5.0 to 1.6.1
@@ -1,1 +0,1 @@ | ||
var fpToolkit=function(i){"use strict";function M(t,e,n,r,o,s,c,b,C){switch(arguments.length){case 1:return t;case 2:return function(){return e(t.apply(this,arguments))};case 3:return function(){return n(e(t.apply(this,arguments)))};case 4:return function(){return r(n(e(t.apply(this,arguments))))};case 5:return function(){return o(r(n(e(t.apply(this,arguments)))))};case 6:return function(){return s(o(r(n(e(t.apply(this,arguments))))))};case 7:return function(){return c(s(o(r(n(e(t.apply(this,arguments)))))))};case 8:return function(){return b(c(s(o(r(n(e(t.apply(this,arguments))))))))};case 9:return function(){return C(b(c(s(o(r(n(e(t.apply(this,arguments)))))))))}}}function u(t,e,n,r,o,s,c,b,C){switch(arguments.length){case 1:return t;case 2:return e(t);case 3:return n(e(t));case 4:return r(n(e(t)));case 5:return o(r(n(e(t))));case 6:return s(o(r(n(e(t)))));case 7:return c(s(o(r(n(e(t))))));case 8:return b(c(s(o(r(n(e(t)))))));case 9:return C(b(c(s(o(r(n(e(t))))))));default:{let D=arguments[0];for(let Y=1;Y<arguments.length;Y++)D=arguments[Y](D);return D}}}const It=t=>e=>(t(e),e),Ft=t=>e=>e.then(n=>(t(n),n)),Wt=t=>t==="",Z=t=>t.trim(),x=t=>t.toLowerCase(),Lt=t=>t.toUpperCase(),T=t=>typeof t=="string",Ut=t=>t.length,Kt=t=>t.split("").reverse().join(""),Ht=t=>e=>{const n=e.split(t);return n.length>0?n:[e]},I=t=>{if(t.length<1)return"";const[e,...n]=t.split("");return[e.toUpperCase(),...n].join("")},F=t=>{if(t.length<1)return"";const[e,...n]=t.split("");return[e.toLowerCase(),...n].join("")},Gt=Object.freeze(Object.defineProperty({__proto__:null,capitalize:I,isEmpty:Wt,isString:T,length:Ut,reverse:Kt,split:Ht,toLowerCase:x,toUpperCase:Lt,trim:Z,uncapitalize:F},Symbol.toStringTag,{value:"Module"})),N=t=>({equals:(e,n)=>e===n||t(e,n)}),Jt=(t,e)=>({equals:(n,r)=>n===r||t.equals(e(n),e(r))}),Qt=t=>N((e,n)=>{for(const r in t)if(!t[r].equals(e[r],n[r]))return!1;return!0}),W=Object.freeze(N((t,e)=>t===e)),Xt=N((t,e)=>t.valueOf()===e.valueOf()),p=Object.freeze(Object.defineProperty({__proto__:null,Date:Xt,Default:W,Number:W,String:W,deriveFrom:Jt,ofEquals:N,ofStruct:Qt},Symbol.toStringTag,{value:"Module"})),q=t=>({compare:(e,n)=>e===n?0:t(e,n)}),Yt=({compare:t})=>q((e,n)=>t(n,e)),tt=(t,e)=>({compare:(n,r)=>n===r?0:t.compare(e(n),e(r))}),L=q((t,e)=>{const n=T(t)?t:globalThis.String(t),r=T(e)?e:globalThis.String(e);return n<r?-1:n>r?1:0}),Zt=(...t)=>t.length<1?L:q((e,n)=>t.reduce((r,o)=>r!==0?r:o.compare(e,n),0)),et=q((t,e)=>e-t>0?-1:1),xt=L,te=tt(et,t=>t.valueOf()),ee=t=>({compare:t.compare,equals:(e,n)=>e===n||t.compare(e,n)===0}),ne=({compare:t})=>(e,n)=>t(e,n)===1,nt=({compare:t})=>(e,n)=>t(e,n)>=0,re=({compare:t})=>(e,n)=>t(e,n)===-1,rt=({compare:t})=>(e,n)=>t(e,n)<=0,$=Object.freeze(Object.defineProperty({__proto__:null,Date:te,Default:L,Number:et,String:xt,deriveEqualityComparer:ee,deriveFrom:tt,geq:nt,getComposite:Zt,gt:ne,isBetween:t=>(e,n)=>r=>nt(t)(r,e)&&rt(t)(r,n),leq:rt,lt:re,ofCompare:q,reverse:Yt},Symbol.toStringTag,{value:"Module"})),oe=t=>p.ofEquals((e,n)=>e==null&&n==null||e!=null&&n!=null&&t.equals(e,n)),se=t=>e=>e??t,ce=t=>e=>e??t(),ue=t=>e=>e!=null?t(e):e,ot=t=>e=>e!=null?t(e):e,le=Object.freeze(Object.defineProperty({__proto__:null,bind:ot,defaultValue:se,defaultWith:ce,flatMap:ot,getEqualityComparer:oe,map:ue},Symbol.toStringTag,{value:"Module"})),R=t=>{throw new Error(`assertExhaustive failed at runtime! It was called with ${t}`)},E=t=>({_tag:"Some",some:t}),ae=E,h=Object.freeze({_tag:"None"}),ie=t=>typeof t!="function",st=(t,e)=>ie(t)?t:t(e),v=t=>e=>{switch(e._tag){case"Some":return st(t.some,e.some);case"None":return st(t.none,void 0);default:return R(e)}},ct=t=>v({some:e=>E(t(e)),none:h}),fe=t=>v({some:e=>t(e)?E(e):h,none:h}),pe=t=>v({some:e=>t(e)?E(e):h,none:h}),ut=t=>v({some:e=>e,none:t}),ge=t=>v({some:e=>e,none:t}),lt=t=>v({some:t,none:h}),de=lt,k=t=>t._tag==="Some",me=t=>t._tag==="None",at=t=>e=>k(e[0])&&k(e[1])?E(t(e[0].some,e[1].some)):h,a=Object.freeze(Object.defineProperty({__proto__:null,bind:lt,defaultValue:ut,defaultWith:ge,filter:fe,flatMap:de,getEqualityComparer:({equals:t})=>p.ofEquals((e,n)=>u([e,n],at((r,o)=>t(r,o)),ut(!1))),isNone:me,isSome:k,map:ct,map2:at,map3:t=>e=>k(e[0])&&k(e[1])&&k(e[2])?E(t(e[0].some,e[1].some,e[2].some)):h,match:v,none:h,of:ae,ofNullish:t=>t!=null?E(t):h,refine:pe,some:E,tee:t=>e=>u(e,ct(n=>(t(n),n))),toNullish:(t,e=!0)=>u(t,v({some:n=>n,none:e?null:void 0})),tryCatch:t=>{try{return E(t())}catch{return h}}},Symbol.toStringTag,{value:"Module"})),d=t=>({_tag:"Ok",ok:t}),f=t=>({_tag:"Err",err:t}),he=d,ye=t=>typeof t!="function",it=(t,e)=>ye(t)?t:t(e),y=t=>e=>{switch(e._tag){case"Ok":return it(t.ok,e.ok);case"Err":return it(t.err,e.err);default:return R(e)}},$e=(t,e)=>n=>u(n,y({ok:r=>t(r)?d(r):f(e(r)),err:r=>f(r)})),Ee=t=>e=>u(e,y({ok:n=>d(t(n)),err:n=>f(n)})),ve=t=>e=>u(e,y({ok:n=>d(n),err:n=>f(t(n))})),_e=(t,e)=>y({ok:n=>d(t(n)),err:n=>f(e(n))}),ft=t=>e=>u(e,y({ok:n=>n,err:t})),Oe=t=>e=>u(e,y({ok:n=>n,err:t})),pt=t=>y({ok:t,err:e=>f(e)}),be=pt,j=t=>t._tag==="Ok",w=t=>t._tag==="Err",gt=t=>e=>j(e[0])&&j(e[1])?d(t(e[0].ok,e[1].ok)):w(e[0])?f(e[0].err):f(e[1].err),Se=t=>e=>j(e[0])&&j(e[1])&&j(e[2])?d(t(e[0].ok,e[1].ok,e[2].ok)):w(e[0])?f(e[0].err):w(e[1])?f(e[1].err):f(e[2].err);function Me(t,e){const n=r=>r instanceof Error?r:Error(String(r));try{return d(t())}catch(r){return e!=null?f(e(r)):f(n(r))}}const l=Object.freeze(Object.defineProperty({__proto__:null,bind:pt,defaultValue:ft,defaultWith:Oe,err:f,flatMap:be,getEqualityComparer:(t,e)=>p.ofEquals((n,r)=>w(n)&&w(r)&&e.equals(n.err,r.err)?!0:u([n,r],gt((o,s)=>t.equals(o,s)),ft(!1))),isErr:w,isOk:j,map:Ee,map2:gt,map3:Se,mapBoth:_e,mapErr:ve,match:y,of:he,ofOption:t=>a.match({some:d,none:M(t,f)}),ok:d,refine:$e,tee:t=>e=>u(e,y({ok:n=>(t(n),d(n)),err:n=>f(n)})),teeErr:t=>e=>u(e,y({ok:n=>d(n),err:n=>(t(n),f(n))})),tryCatch:Me},Symbol.toStringTag,{value:"Module"})),dt=t=>()=>Promise.resolve(t),ke=t=>e=>()=>e().then(t),mt=t=>e=>()=>e().then(n=>t(n)()),je=mt,we=t=>()=>t().then(e=>e()),Pe=dt({}),Ce=t=>e=>async()=>{const n=t<=0?0:Math.floor(t);return await new Promise(r=>setTimeout(r,n)),await e()},qe=t=>async()=>{const e=[];for(let n=0;n<t.length;n++)e.push(await t[n]());return e},ht=t=>t(),A=Object.freeze(Object.defineProperty({__proto__:null,asyncify:t=>(...e)=>()=>t(...e),bind:mt,delay:Ce,flatMap:je,flatten:we,map:ke,never:()=>new Promise(()=>{}),of:dt,ofPromise:t=>()=>t,parallel:t=>()=>Promise.all(t.map(ht)),sequential:qe,start:ht,tee:t=>e=>async()=>{const n=await e();return t(n),n},unit:Pe},Symbol.toStringTag,{value:"Module"})),Re=t=>()=>Promise.resolve(l.ok(t)),yt=t=>()=>Promise.resolve(l.err(t)),ze=t=>e=>()=>e().then(l.map(t)),De=t=>e=>()=>e().then(l.mapErr(t)),Te=(t,e)=>n=>()=>n().then(l.mapBoth(t,e)),$t=t=>e=>async()=>{const n=await e();return await u(n,l.match({ok:t,err:r=>yt(r)}),A.start)},Ne=$t,Et=t=>e=>()=>e().then(l.bind(t)),Ae=Et,Ve=t=>()=>Promise.resolve(t),Be=t=>()=>t().then(e=>l.ok(e));function Ie(t,e){return async()=>{const n=r=>r instanceof Error?r:Error(String(r));try{return l.ok(await t())}catch(r){return e!=null?l.err(e(r)):l.err(n(r))}}}const Fe=Object.freeze(Object.defineProperty({__proto__:null,bind:$t,bindResult:Et,err:yt,flatMap:Ne,flatMapResult:Ae,map:ze,mapBoth:Te,mapErr:De,match:t=>e=>()=>e().then(l.match(t)),ofAsync:Be,ofResult:Ve,ok:Re,start:t=>t(),tee:t=>e=>A.tee(l.tee(t))(e),teeErr:t=>e=>A.tee(l.teeErr(t))(e),tryCatch:Ie},Symbol.toStringTag,{value:"Module"}));function We(t){return e=>e.filter(t)}const Le=t=>e=>e.filter(t),Ue=t=>e=>e.map(t),Ke=t=>e=>e.map(t),He=t=>e=>{const n=[];for(let r=0;r<e.length;r++){const o=t(e[r]);a.isSome(o)&&n.push(o.some)}return n},Ge=t=>e=>{const n=[];for(let r=0;r<e.length;r++){const o=t(e[r]);l.isOk(o)&&n.push(o.ok)}return n},vt=t=>t.length>0?a.some(t[0]):a.none,Je=vt,Qe=t=>{if(t.length===0)return a.none;const[e,...n]=t;return a.some(n)},Xe=t=>e=>{const n=t<=0?0:Math.floor(t);if(n>e.length)return e;const r=[];for(let o=0;o<e.length&&o<n;o++)r.push(e[o]);return r},Ye=t=>e=>{const n=t<=0?0:Math.floor(t);if(n>=e.length)return[];const r=[];for(let o=n;o<e.length;o++)r.push(e[o]);return r},Ze=(t,e)=>n=>n.reduce(e,t),xe=(t,e)=>n=>n.reduceRight(e,t),tn=t=>typeof t!="function",_t=(t,e)=>tn(t)?t:t(e),en=t=>e=>e.length>0?_t(t.nonEmpty,e):_t(t.empty,void 0),g=t=>t.length===0,nn=t=>t.length>0,Ot=t=>e=>e.flatMap(t),rn=Ot,bt=t=>e=>[...e,t],on=t=>e=>[t,...e],sn=t=>e=>{const n=new Map;return e.forEach(r=>{const o=t(r);return n.has(o)?n.set(o,u(n.get(o),bt(r))):n.set(o,[r])}),n},St=t=>e=>[...e,...t],cn=t=>e=>[...t,...e],Mt=t=>e=>e.some(t),un=Mt,ln=t=>t.flat(),an=t=>e=>{if(g(e))return[];const n=t<=1?1:Math.floor(t),r=Math.ceil(e.length/n),o=[...globalThis.Array(r)].map(()=>[]);let s=0;for(let c=0;c<e.length;c++)c!==0&&c%n===0&&s++,o[s].push(e[c]);return o},fn=t=>t.length,V=(t,e=p.Default)=>n=>{if(g(n))return!1;const r=o=>e.equals(t,o);return n.some(r)},kt=t=>e=>{if(g(e))return[];const n=[];return e.forEach(r=>{V(r,t)(n)||n.push(r)}),n},pn=(t,e)=>n=>{if(g(n))return[];const r=[],o=[];return n.forEach(s=>{const c=t(s);V(c,e)(o)||(o.push(c),r.push(s))}),r},gn=t=>e=>g(e)?[]:e.slice(0).sort(t==null?void 0:t.compare),dn=(t,e=$.Default)=>n=>g(n)?[]:n.slice(0).sort((r,o)=>e.compare(t(r),t(o))),mn=t=>t.slice(0).reverse(),jt=t=>e=>a.ofNullish(e.find(t)),hn=Object.freeze(Object.defineProperty({__proto__:null,append:bt,asMutable:t=>t,bind:Ot,choose:He,chooseR:Ge,chunk:an,concat:St,concatFirst:cn,contains:V,except:(t,e)=>n=>{if(g(n))return[];if(g(t))return n;const r=[];for(let o=0;o<n.length;o++)u(t,V(n[o],e))||r.push(n[o]);return r},exists:Mt,filter:We,filteri:Le,find:jt,findIndex:t=>e=>{const n=e.findIndex(t);return n<0?a.none:a.some(n)},first:Je,flatMap:rn,flatten:ln,getEqualityComparer:({equals:t})=>p.ofEquals((e,n)=>{if(g(e)&&g(n))return!0;if(e.length!==n.length)return!1;for(let r=0;r<e.length;r++)if(!t(e[r],n[r]))return!1;return!0}),groupBy:sn,head:vt,isEmpty:g,isNonEmpty:nn,iter:t=>e=>e.forEach(n=>t(n)),length:fn,map:Ue,mapi:Ke,match:en,prepend:on,reduce:Ze,reduceRight:xe,reverse:mn,skip:Ye,some:un,sort:gn,sortBy:dn,tail:Qe,take:Xe,union:(t,e)=>n=>g(t)&&g(n)?[]:u(n,St(t),kt(e)),uniq:kt,uniqBy:pn},Symbol.toStringTag,{value:"Module"})),wt=t=>t[0],yn=wt,$n=t=>({head:t[0],tail:t.slice(1)}),En=t=>e=>e.map(t),Pt=t=>e=>e.flatMap(t),vn=Object.freeze(Object.defineProperty({__proto__:null,bind:Pt,destruct:$n,first:yn,flatMap:Pt,getEqualityComparer:({equals:t})=>p.ofEquals((e,n)=>{if(e.length!==n.length)return!1;for(let r=0;r<e.length;r++)if(!t(e[r],n[r]))return!1;return!0}),head:wt,make:(t,e)=>{const n=t<=1?1:Math.floor(t);return[...Array(n).keys()].map(e)},map:En,of:t=>[t],range:(t,e)=>{const n=Math.floor(t),r=Math.floor(e);if(n>=r)return[n];const o=[];for(let s=n;s<=r;s++)o.push(s);return o},reverse:t=>t.slice(0).reverse(),sort:(t=$.Default)=>e=>e.slice(0).sort(t.compare)},Symbol.toStringTag,{value:"Module"})),P=(t,{equals:e}=p.Default)=>n=>{if(n.size<1)return a.none;for(const[r,o]of n)if(e(r,t))return a.some([r,o]);return a.none},_n=(t,e=p.Default)=>n=>u(n,P(t,e),a.isSome),On=(t,e=p.Default)=>n=>u(n,P(t,e),a.map(([,r])=>r)),U=([t,e],n=p.Default)=>r=>{if(r.size<1){const s=_();return s.set(t,e),s}const o=new globalThis.Map(r);return u(r,P(t,n),a.match({none:()=>(o.set(t,e),o),some:([s])=>(o.set(s,e),o)}))},bn=t=>e=>{if(e.size<1)return _();const n=_();for(const[r,o]of e)n.set(r,t(r,o));return n},Sn=(t,e=$.Default)=>n=>a.ofNullish(K(e)(n).find(t)),_=()=>new globalThis.Map,Mn=t=>e=>{if(e.size<1)return!1;for(const[,n]of e)if(t(n))return!0;return!1},kn=(t,e,n=p.Default)=>r=>u(r,P(t,n),a.match({some:([o,s])=>{const c=new globalThis.Map(r);return c.set(o,e(s)),c},none:r})),jn=t=>t.size,wn=t=>t.size<1,K=({compare:t}=$.Default)=>e=>Array.from(e.keys()).sort(t),Pn=(t=$.Default)=>e=>{const n=[];for(const[,r]of e)n.push(r);return n.sort(t.compare)},H=(t=$.Default)=>e=>K(t)(e).map(n=>[n,e.get(n)]),Cn=Object.freeze(Object.defineProperty({__proto__:null,change:kn,containsKey:_n,empty:_,every:t=>e=>{if(e.size<1)return!0;for(const[n,r]of e)if(!t(n,r))return!1;return!0},exists:Mn,filter:t=>e=>{if(e.size<1)return _();const n=_();for(const[r,o]of e)t(r,o)&&n.set(r,o);return n},find:On,findKey:Sn,findWithKey:P,isEmpty:wn,iter:t=>e=>{if(!(e.size<1))for(const[n,r]of e)t(n,r)},keys:K,map:bn,ofArray:(t,e=p.Default)=>t.length<1?new globalThis.Map:t.reduce((n,r)=>U(r,e)(n),_()),ofRecord:(t,e=p.Default)=>Object.entries(t).reduce((n,[r,o])=>U([r,o],e)(n),_()),reduce:(t,e,n=$.Default)=>r=>H(n)(r).reduce((o,[s,c])=>e(o,s,c),t),reduceRight:(t,e,n=$.Default)=>r=>H(n)(r).reduceRight((o,[s,c])=>e(o,s,c),t),remove:(t,e=p.Default)=>n=>u(n,P(t,e),a.match({some:([r])=>{const o=new globalThis.Map(n);return o.delete(r),o},none:n})),set:U,size:jn,toArray:H,values:Pn},Symbol.toStringTag,{value:"Module"})),Ct=Object.freeze({_tag:"NotStarted"}),qt=Object.freeze({_tag:"InProgress"}),Rt=t=>({_tag:"Resolved",resolved:t}),O=(t,...e)=>(r=>typeof r=="function")(t)?t(...e):t,zt=t=>e=>{switch(e._tag){case"NotStarted":return O(t.notStarted);case"InProgress":return O(t.inProgress);case"Resolved":return O(t.resolved,e.resolved);default:return R(e)}},z=t=>e=>{switch(e._tag){case"NotStarted":return O(t.notStarted!=null?t.notStarted:t.orElse);case"InProgress":return O(t.inProgress!=null?t.inProgress:t.orElse);case"Resolved":return t.resolved!=null?O(t.resolved,e.resolved):O(t.orElse);default:return O(t.orElse)}},qn=z({resolved:!1,orElse:!0}),S=Object.freeze(Object.defineProperty({__proto__:null,inProgress:qt,isInProgress:t=>u(t,z({inProgress:!0,orElse:!1})),isResolved:t=>u(t,z({resolved:!0,orElse:!1})),isResolvedWith:(t,e=p.Default)=>z({resolved:n=>e.equals(n,t),orElse:!1}),isUnresolved:qn,map:t=>zt({resolved:M(t,Rt),inProgress:qt,notStarted:Ct}),match:zt,matchOrElse:z,notStarted:Ct,resolved:Rt},Symbol.toStringTag,{value:"Module"})),Rn=(t,e)=>`Must be an enum value in the set ${e}{ ${t.join(", ")} }`,Dt=t=>u(a.some(t),a.refine(T),a.map(M(Z,x)),a.defaultValue(t)),zn=t=>typeof t=="string"||typeof t=="number",Dn=(t,e)=>n=>u(a.ofNullish(n),l.ofOption(()=>`Enum${e?` ${e}`:""} cannot be null/undefined`),l.refine(zn,()=>`Enum${e?` ${e}`:""} must be a string or number`),l.map(Dt),l.bind(r=>u(t,jt(o=>Dt(o)===r),a.match({some:o=>l.ok(o),none:()=>l.err(Rn(t,e))})))),G=t=>typeof t=="function",Tn=t=>e=>n=>{const r=Object.entries(t).find(([,c])=>c===n);if(!r)throw new TypeError(`Expected to match against an enum where '${n}' is a valid value.`);const o=r[0];if(!Object.hasOwn(e,o))throw new TypeError(`Expected a matcher containing a case for '${o}'.`);const s=e[o];return G(s)?s():s},Nn=t=>e=>n=>{const r=Object.entries(t).find(([,s])=>s===n);if(!r)throw new TypeError(`Expected to match against an enum where '${n}' is a valid value.`);const o=r[0];if(Object.hasOwn(e,o)){const s=e[o];return G(s)?s():s}return G(e.orElse)?e.orElse():e.orElse},An=(t,e="")=>{const n=Object.entries(t).reduce((o,[s,c])=>({...o,[s]:c}),{}),r=Object.values(t);return{...n,values:r,parse:Dn(r,e),match:Tn(t),matchOrElse:Nn(t)}},Vn=t=>typeof t=="function",Tt=(t,e,n)=>Object.entries(t).reduce((r,o)=>{const[s,c]=o,b=I(s),C=n.length>0?`${n}${b}`:`${b}`;return Object.assign(r,{[s]:Vn(c)?(...D)=>({[e]:C,...c(...D)}):{[e]:C}})},{}),Nt=(t,e)=>Object.entries(t).reduce((n,r)=>{const[o]=r,s=I(o),c=e.length>0?`${e}${s}`:`${s}`;return Object.assign(n,{[o]:c})},{}),At=(t,e)=>e.length>0?t.replace(new RegExp(`${e}`),""):t,Vt=(t,e)=>n=>r=>{const o=F(At(r[t],e));if(!Object.hasOwn(n,o))throw new TypeError(`Expected to be given a variant with scope ${e}. Actual type was ${r[t]}`);const s=n[o],c={...r};return delete c[t],typeof s=="function"?s(c):s},Bt=(t,e)=>n=>r=>{const o=F(At(r[t],e));if(Object.hasOwn(n,o)){const s=n[o],c={...r};return delete c[t],typeof s=="function"?s(c):s}return typeof n.orElse=="function"?n.orElse():n.orElse},Bn=(t,e,n)=>({...Tt(t,e,n),match:Vt(e,n),matchOrElse:Bt(e,n),types:Nt(t,n)}),In=t=>({...Tt(t,"_tag",""),match:Vt("_tag",""),matchOrElse:Bt("_tag",""),types:Nt(t,"")}),J=t=>S.resolved(l.ok(t)),Q=t=>S.resolved(l.err(t)),Fn=t=>typeof t!="function",m=(t,e)=>Fn(t)?t:t(e),B=(t,e)=>Object.hasOwn(e,t),X=t=>e=>{switch(e._tag){case"InProgress":return m(t.inProgress,void 0);case"NotStarted":return m(t.notStarted,void 0);case"Resolved":return u(e.resolved,l.match({ok:n=>m(t.resolvedOk,n),err:n=>m(t.resolvedErr,n)}));default:return R(e)}},Wn=Object.freeze(Object.defineProperty({__proto__:null,err:Q,map:t=>X({resolvedOk:M(t,J),resolvedErr:Q,inProgress:S.inProgress,notStarted:S.notStarted}),mapErr:t=>X({resolvedErr:M(t,Q),resolvedOk:J,inProgress:S.inProgress,notStarted:S.notStarted}),match:X,matchOrElse:t=>e=>{switch(e._tag){case"InProgress":return B("inProgress",t)?m(t.inProgress,void 0):m(t.orElse,void 0);case"NotStarted":return B("notStarted",t)?m(t.notStarted,void 0):m(t.orElse,void 0);case"Resolved":return u(e.resolved,l.match({ok:n=>B("resolvedOk",t)?m(t.resolvedOk,n):m(t.orElse,void 0),err:n=>B("resolvedErr",t)?m(t.resolvedErr,n):m(t.orElse,void 0)}));default:return R(e)}},ok:J},Symbol.toStringTag,{value:"Module"}));return i.Array=hn,i.Async=A,i.AsyncResult=Fe,i.Deferred=S,i.DeferredResult=Wn,i.EqualityComparer=p,i.Map=Cn,i.NonEmptyArray=vn,i.Nullable=le,i.Option=a,i.OrderingComparer=$,i.Result=l,i.String=Gt,i.enumOf=An,i.flow=M,i.pipe=u,i.tee=It,i.teeAsync=Ft,i.variant=In,i.variantC=Bn,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"}),i}({}); | ||
var fpToolkit=function(l){"use strict";function j(t,e,n,r,o,s,u,p,z){switch(arguments.length){case 1:return t;case 2:return function(){return e(t.apply(this,arguments))};case 3:return function(){return n(e(t.apply(this,arguments)))};case 4:return function(){return r(n(e(t.apply(this,arguments))))};case 5:return function(){return o(r(n(e(t.apply(this,arguments)))))};case 6:return function(){return s(o(r(n(e(t.apply(this,arguments))))))};case 7:return function(){return u(s(o(r(n(e(t.apply(this,arguments)))))))};case 8:return function(){return p(u(s(o(r(n(e(t.apply(this,arguments))))))))};case 9:return function(){return z(p(u(s(o(r(n(e(t.apply(this,arguments)))))))))}}}function c(t,e,n,r,o,s,u,p,z){switch(arguments.length){case 1:return t;case 2:return e(t);case 3:return n(e(t));case 4:return r(n(e(t)));case 5:return o(r(n(e(t))));case 6:return s(o(r(n(e(t)))));case 7:return u(s(o(r(n(e(t))))));case 8:return p(u(s(o(r(n(e(t)))))));case 9:return z(p(u(s(o(r(n(e(t))))))));default:{let D=arguments[0];for(let rt=1;rt<arguments.length;rt++)D=arguments[rt](D);return D}}}const Ht=t=>e=>(t(e),e),Gt=t=>e=>e.then(n=>(t(n),n)),Jt=t=>t==="",ot=t=>t.trim(),st=t=>t.toLowerCase(),Qt=t=>t.toUpperCase(),V=t=>typeof t=="string",Xt=t=>t.length,Yt=t=>t.split("").reverse().join(""),Zt=t=>e=>{const n=e.split(t);return n.length>0?n:[e]},L=t=>{if(t.length<1)return"";const[e,...n]=t.split("");return[e.toUpperCase(),...n].join("")},U=t=>{if(t.length<1)return"";const[e,...n]=t.split("");return[e.toLowerCase(),...n].join("")},xt=Object.freeze(Object.defineProperty({__proto__:null,capitalize:L,isEmpty:Jt,isString:V,length:Xt,reverse:Yt,split:Zt,toLowerCase:st,toUpperCase:Qt,trim:ot,uncapitalize:U},Symbol.toStringTag,{value:"Module"})),B=t=>({equals:(e,n)=>e===n||t(e,n)}),te=(t,e)=>({equals:(n,r)=>n===r||t.equals(e(n),e(r))}),ee=t=>B((e,n)=>{for(const r in t)if(!t[r].equals(e[r],n[r]))return!1;return!0}),H=Object.freeze(B((t,e)=>t===e)),ne=B((t,e)=>t.valueOf()===e.valueOf()),y=Object.freeze(Object.defineProperty({__proto__:null,Date:ne,Default:H,Number:H,String:H,deriveFrom:te,ofEquals:B,ofStruct:ee},Symbol.toStringTag,{value:"Module"})),T=t=>({compare:(e,n)=>e===n?0:t(e,n)}),re=({compare:t})=>T((e,n)=>t(n,e)),ct=(t,e)=>({compare:(n,r)=>n===r?0:t.compare(e(n),e(r))}),G=T((t,e)=>{const n=V(t)?t:globalThis.String(t),r=V(e)?e:globalThis.String(e);return n<r?-1:n>r?1:0}),oe=(...t)=>t.length<1?G:T((e,n)=>t.reduce((r,o)=>r!==0?r:o.compare(e,n),0)),ut=T((t,e)=>e-t>0?-1:1),se=G,ce=ct(ut,t=>t.valueOf()),ue=t=>({compare:t.compare,equals:(e,n)=>e===n||t.compare(e,n)===0}),ie=({compare:t})=>(e,n)=>t(e,n)===1,it=({compare:t})=>(e,n)=>t(e,n)>=0,ae=({compare:t})=>(e,n)=>t(e,n)===-1,at=({compare:t})=>(e,n)=>t(e,n)<=0,E=Object.freeze(Object.defineProperty({__proto__:null,Date:ce,Default:G,Number:ut,String:se,deriveEqualityComparer:ue,deriveFrom:ct,geq:it,getComposite:oe,gt:ie,isBetween:t=>(e,n)=>r=>it(t)(r,e)&&at(t)(r,n),leq:at,lt:ae,ofCompare:T,reverse:re},Symbol.toStringTag,{value:"Module"})),le=t=>y.ofEquals((e,n)=>e==null&&n==null||e!=null&&n!=null&&t.equals(e,n)),fe=t=>e=>e??t,pe=t=>e=>e??t(),ge=t=>e=>e!=null?t(e):e,lt=t=>e=>e!=null?t(e):e,de=Object.freeze(Object.defineProperty({__proto__:null,bind:lt,defaultValue:fe,defaultWith:pe,flatMap:lt,getEqualityComparer:le,map:ge},Symbol.toStringTag,{value:"Module"})),A=t=>{throw new Error(`assertExhaustive failed at runtime! It was called with ${t}`)},v=t=>({_tag:"Some",some:t}),me=v,h=Object.freeze({_tag:"None"}),he=t=>typeof t!="function",ft=(t,e)=>he(t)?t:t(e),_=t=>e=>{switch(e._tag){case"Some":return ft(t.some,e.some);case"None":return ft(t.none,void 0);default:return A(e)}},pt=t=>_({some:e=>v(t(e)),none:h}),ye=t=>_({some:e=>t(e)?v(e):h,none:h}),$e=t=>_({some:e=>t(e)?v(e):h,none:h}),gt=t=>_({some:e=>e,none:t}),ve=t=>_({some:e=>e,none:t}),dt=t=>_({some:t,none:h}),Ee=dt,w=t=>t._tag==="Some",_e=t=>t._tag==="None",mt=t=>e=>w(e[0])&&w(e[1])?v(t(e[0].some,e[1].some)):h,i=Object.freeze(Object.defineProperty({__proto__:null,bind:dt,defaultValue:gt,defaultWith:ve,filter:ye,flatMap:Ee,getEqualityComparer:({equals:t})=>y.ofEquals((e,n)=>c([e,n],mt((r,o)=>t(r,o)),gt(!1))),isNone:_e,isSome:w,map:pt,map2:mt,map3:t=>e=>w(e[0])&&w(e[1])&&w(e[2])?v(t(e[0].some,e[1].some,e[2].some)):h,match:_,none:h,of:me,ofNullish:t=>t!=null?v(t):h,refine:$e,some:v,tee:t=>e=>c(e,pt(n=>(t(n),n))),toNullish:(t,e=!0)=>c(t,_({some:n=>n,none:e?null:void 0})),tryCatch:t=>{try{return v(t())}catch{return h}}},Symbol.toStringTag,{value:"Module"})),d=t=>({_tag:"Ok",ok:t}),f=t=>({_tag:"Err",err:t}),Oe=d,be=t=>typeof t!="function",ht=(t,e)=>be(t)?t:t(e),$=t=>e=>{switch(e._tag){case"Ok":return ht(t.ok,e.ok);case"Err":return ht(t.err,e.err);default:return A(e)}},Se=(t,e)=>n=>c(n,$({ok:r=>t(r)?d(r):f(e(r)),err:r=>f(r)})),ke=t=>e=>c(e,$({ok:n=>d(t(n)),err:n=>f(n)})),Me=t=>e=>c(e,$({ok:n=>d(n),err:n=>f(t(n))})),je=(t,e)=>$({ok:n=>d(t(n)),err:n=>f(e(n))}),yt=t=>e=>c(e,$({ok:n=>n,err:t})),we=t=>e=>c(e,$({ok:n=>n,err:t})),$t=t=>$({ok:t,err:e=>f(e)}),Re=$t,R=t=>t._tag==="Ok",P=t=>t._tag==="Err",vt=t=>e=>R(e[0])&&R(e[1])?d(t(e[0].ok,e[1].ok)):P(e[0])?f(e[0].err):f(e[1].err),Pe=t=>e=>R(e[0])&&R(e[1])&&R(e[2])?d(t(e[0].ok,e[1].ok,e[2].ok)):P(e[0])?f(e[0].err):P(e[1])?f(e[1].err):f(e[2].err);function Ce(t,e){const n=r=>r instanceof Error?r:Error(String(r));try{return d(t())}catch(r){return e!=null?f(e(r)):f(n(r))}}const a=Object.freeze(Object.defineProperty({__proto__:null,bind:$t,defaultValue:yt,defaultWith:we,err:f,flatMap:Re,getEqualityComparer:(t,e)=>y.ofEquals((n,r)=>P(n)&&P(r)&&e.equals(n.err,r.err)?!0:c([n,r],vt((o,s)=>t.equals(o,s)),yt(!1))),isErr:P,isOk:R,map:ke,map2:vt,map3:Pe,mapBoth:je,mapErr:Me,match:$,of:Oe,ofOption:t=>i.match({some:d,none:j(t,f)}),ok:d,refine:Se,tee:t=>e=>c(e,$({ok:n=>(t(n),d(n)),err:n=>f(n)})),teeErr:t=>e=>c(e,$({ok:n=>d(n),err:n=>(t(n),f(n))})),tryCatch:Ce},Symbol.toStringTag,{value:"Module"})),Et=t=>()=>Promise.resolve(t),qe=t=>e=>()=>e().then(t),_t=t=>e=>()=>e().then(n=>t(n)()),ze=_t,Te=t=>()=>t().then(e=>e()),Ae=Et({}),Ne=t=>e=>async()=>{const n=t<=0?0:Math.floor(t);return await new Promise(r=>setTimeout(r,n)),await e()},De=t=>async()=>{const e=[];for(let n=0;n<t.length;n++)e.push(await t[n]());return e},Ot=t=>t(),I=Object.freeze(Object.defineProperty({__proto__:null,asyncify:t=>(...e)=>()=>t(...e),bind:_t,delay:Ne,flatMap:ze,flatten:Te,map:qe,never:()=>new Promise(()=>{}),of:Et,ofPromise:t=>()=>t,parallel:t=>()=>Promise.all(t.map(Ot)),sequential:De,start:Ot,tee:t=>e=>async()=>{const n=await e();return t(n),n},unit:Ae},Symbol.toStringTag,{value:"Module"})),Ve=t=>()=>Promise.resolve(a.ok(t)),bt=t=>()=>Promise.resolve(a.err(t)),Be=t=>e=>()=>e().then(a.map(t)),Ie=t=>e=>()=>e().then(a.mapErr(t)),Ke=(t,e)=>n=>()=>n().then(a.mapBoth(t,e)),St=t=>e=>async()=>{const n=await e();return await c(n,a.match({ok:t,err:r=>bt(r)}),I.start)},We=St,kt=t=>e=>()=>e().then(a.bind(t)),Fe=kt,Le=t=>()=>Promise.resolve(t),Ue=t=>()=>t().then(e=>a.ok(e));function He(t,e){return async()=>{const n=r=>r instanceof Error?r:Error(String(r));try{return a.ok(await t())}catch(r){return e!=null?a.err(e(r)):a.err(n(r))}}}const Ge=Object.freeze(Object.defineProperty({__proto__:null,bind:St,bindResult:kt,err:bt,flatMap:We,flatMapResult:Fe,map:Be,mapBoth:Ke,mapErr:Ie,match:t=>e=>()=>e().then(a.match(t)),ofAsync:Ue,ofResult:Le,ok:Ve,start:t=>t(),tee:t=>e=>I.tee(a.tee(t))(e),teeErr:t=>e=>I.tee(a.teeErr(t))(e),tryCatch:He},Symbol.toStringTag,{value:"Module"}));function Je(t){return e=>e.filter(t)}const Qe=t=>e=>e.filter(t),Xe=t=>e=>e.map(t),Ye=t=>e=>e.map(t),Ze=t=>e=>{const n=[];for(let r=0;r<e.length;r++){const o=t(e[r]);i.isSome(o)&&n.push(o.some)}return n},xe=t=>e=>{const n=[];for(let r=0;r<e.length;r++){const o=t(e[r]);a.isOk(o)&&n.push(o.ok)}return n},Mt=t=>t.length>0?i.some(t[0]):i.none,tn=Mt,en=t=>{if(t.length===0)return i.none;const[e,...n]=t;return i.some(n)},nn=t=>e=>{const n=t<=0?0:Math.floor(t);if(n>e.length)return e;const r=[];for(let o=0;o<e.length&&o<n;o++)r.push(e[o]);return r},rn=t=>e=>{const n=t<=0?0:Math.floor(t);if(n>=e.length)return[];const r=[];for(let o=n;o<e.length;o++)r.push(e[o]);return r},on=(t,e)=>n=>n.reduce(e,t),sn=(t,e)=>n=>n.reduceRight(e,t),cn=t=>typeof t!="function",jt=(t,e)=>cn(t)?t:t(e),un=t=>e=>e.length>0?jt(t.nonEmpty,e):jt(t.empty,void 0),g=t=>t.length===0,an=t=>t.length>0,wt=t=>e=>e.flatMap(t),ln=wt,Rt=t=>e=>[...e,t],fn=t=>e=>[t,...e],pn=t=>e=>{const n=new Map;return e.forEach(r=>{const o=t(r);return n.has(o)?n.set(o,c(n.get(o),Rt(r))):n.set(o,[r])}),n},Pt=t=>e=>[...e,...t],gn=t=>e=>[...t,...e],Ct=t=>e=>e.some(t),dn=Ct,mn=t=>t.flat(),hn=t=>e=>{if(g(e))return[];const n=t<=1?1:Math.floor(t),r=Math.ceil(e.length/n),o=[...globalThis.Array(r)].map(()=>[]);let s=0;for(let u=0;u<e.length;u++)u!==0&&u%n===0&&s++,o[s].push(e[u]);return o},yn=t=>t.length,K=(t,e=y.Default)=>n=>{if(g(n))return!1;const r=o=>e.equals(t,o);return n.some(r)},qt=t=>e=>{if(g(e))return[];const n=[];return e.forEach(r=>{K(r,t)(n)||n.push(r)}),n},$n=(t,e)=>n=>{if(g(n))return[];const r=[],o=[];return n.forEach(s=>{const u=t(s);K(u,e)(o)||(o.push(u),r.push(s))}),r},vn=t=>e=>g(e)?[]:e.slice(0).sort(t==null?void 0:t.compare),En=(t,e=E.Default)=>n=>g(n)?[]:n.slice(0).sort((r,o)=>e.compare(t(r),t(o))),_n=t=>t.slice(0).reverse(),zt=t=>e=>i.ofNullish(e.find(t)),On=Object.freeze(Object.defineProperty({__proto__:null,append:Rt,asMutable:t=>t,bind:wt,choose:Ze,chooseR:xe,chunk:hn,concat:Pt,concatFirst:gn,contains:K,except:(t,e)=>n=>{if(g(n))return[];if(g(t))return n;const r=[];for(let o=0;o<n.length;o++)c(t,K(n[o],e))||r.push(n[o]);return r},exists:Ct,filter:Je,filteri:Qe,find:zt,findIndex:t=>e=>{const n=e.findIndex(t);return n<0?i.none:i.some(n)},first:tn,flatMap:ln,flatten:mn,getEqualityComparer:({equals:t})=>y.ofEquals((e,n)=>{if(g(e)&&g(n))return!0;if(e.length!==n.length)return!1;for(let r=0;r<e.length;r++)if(!t(e[r],n[r]))return!1;return!0}),groupBy:pn,head:Mt,isEmpty:g,isNonEmpty:an,iter:t=>e=>e.forEach(n=>t(n)),length:yn,map:Xe,mapi:Ye,match:un,prepend:fn,reduce:on,reduceRight:sn,reverse:_n,skip:rn,some:dn,sort:vn,sortBy:En,tail:en,take:nn,union:(t,e)=>n=>g(t)&&g(n)?[]:c(n,Pt(t),qt(e)),uniq:qt,uniqBy:$n},Symbol.toStringTag,{value:"Module"})),Tt=t=>t[0],bn=Tt,Sn=t=>({head:t[0],tail:t.slice(1)}),kn=t=>e=>e.map(t),At=t=>e=>e.flatMap(t),Mn=Object.freeze(Object.defineProperty({__proto__:null,bind:At,destruct:Sn,first:bn,flatMap:At,getEqualityComparer:({equals:t})=>y.ofEquals((e,n)=>{if(e.length!==n.length)return!1;for(let r=0;r<e.length;r++)if(!t(e[r],n[r]))return!1;return!0}),head:Tt,make:(t,e)=>{const n=t<=1?1:Math.floor(t);return[...Array(n).keys()].map(e)},map:kn,of:t=>[t],range:(t,e)=>{const n=Math.floor(t),r=Math.floor(e);if(n>=r)return[n];const o=[];for(let s=n;s<=r;s++)o.push(s);return o},reverse:t=>t.slice(0).reverse(),sort:(t=E.Default)=>e=>e.slice(0).sort(t.compare)},Symbol.toStringTag,{value:"Module"})),C=(t,{equals:e}=y.Default)=>n=>{if(n.size<1)return i.none;for(const[r,o]of n)if(e(r,t))return i.some([r,o]);return i.none},jn=(t,e)=>n=>c(n,C(t,e),i.isSome),wn=(t,e)=>n=>c(n,C(t,e),i.map(([,r])=>r)),J=([t,e],n)=>r=>{if(r.size<1){const s=O();return s.set(t,e),s}const o=new globalThis.Map(r);return c(r,C(t,n),i.match({none:()=>(o.set(t,e),o),some:([s])=>(o.set(s,e),o)}))},Rn=t=>e=>{if(e.size<1)return O();const n=O();for(const[r,o]of e)n.set(r,t(r,o));return n},Pn=(t,e)=>n=>c(n,Q(e),r=>r.find(t),i.ofNullish),O=()=>new globalThis.Map,Cn=t=>e=>{if(e.size<1)return!1;for(const[,n]of e)if(t(n))return!0;return!1},qn=(t,e,n)=>r=>c(r,C(t,n),i.match({some:([o,s])=>{const u=new globalThis.Map(r);return u.set(o,e(s)),u},none:r})),zn=t=>t.size,Tn=t=>t.size<1,Q=({compare:t}=E.Default)=>e=>Array.from(e.keys()).sort(t),An=({compare:t}=E.Default)=>e=>{const n=[];for(const[,r]of e)n.push(r);return n.sort(t)},X=t=>e=>c(e,Q(t),n=>n.map(r=>[r,e.get(r)])),Nn=Object.freeze(Object.defineProperty({__proto__:null,change:qn,containsKey:jn,empty:O,every:t=>e=>{if(e.size<1)return!0;for(const[n,r]of e)if(!t(n,r))return!1;return!0},exists:Cn,filter:t=>e=>{if(e.size<1)return O();const n=O();for(const[r,o]of e)t(r,o)&&n.set(r,o);return n},find:wn,findKey:Pn,findWithKey:C,isEmpty:Tn,iter:t=>e=>{if(!(e.size<1))for(const[n,r]of e)t(n,r)},keys:Q,map:Rn,ofArray:(t,e)=>t.length<1?new globalThis.Map:t.reduce((n,r)=>J(r,e)(n),O()),ofRecord:(t,e)=>Object.entries(t).reduce((n,[r,o])=>J([r,o],e)(n),O()),reduce:(t,e,n)=>r=>c(r,X(n),o=>o.reduce((s,[u,p])=>e(s,u,p),t)),reduceRight:(t,e,n)=>r=>c(r,X(n),o=>o.reduceRight((s,[u,p])=>e(s,u,p),t)),remove:(t,e)=>n=>c(n,C(t,e),i.match({some:([r])=>{const o=new globalThis.Map(n);return o.delete(r),o},none:n})),set:J,size:zn,toArray:X,values:An},Symbol.toStringTag,{value:"Module"})),Nt=Object.freeze({_tag:"NotStarted"}),Dt=Object.freeze({_tag:"InProgress"}),Vt=t=>({_tag:"Resolved",resolved:t}),b=(t,...e)=>(r=>typeof r=="function")(t)?t(...e):t,Bt=t=>e=>{switch(e._tag){case"NotStarted":return b(t.notStarted);case"InProgress":return b(t.inProgress);case"Resolved":return b(t.resolved,e.resolved);default:return A(e)}},N=t=>e=>{switch(e._tag){case"NotStarted":return b(t.notStarted!=null?t.notStarted:t.orElse);case"InProgress":return b(t.inProgress!=null?t.inProgress:t.orElse);case"Resolved":return t.resolved!=null?b(t.resolved,e.resolved):b(t.orElse);default:return b(t.orElse)}},Dn=N({resolved:!1,orElse:!0}),k=Object.freeze(Object.defineProperty({__proto__:null,inProgress:Dt,isInProgress:t=>c(t,N({inProgress:!0,orElse:!1})),isResolved:t=>c(t,N({resolved:!0,orElse:!1})),isResolvedWith:(t,e=y.Default)=>N({resolved:n=>e.equals(n,t),orElse:!1}),isUnresolved:Dn,map:t=>Bt({resolved:j(t,Vt),inProgress:Dt,notStarted:Nt}),match:Bt,matchOrElse:N,notStarted:Nt,resolved:Vt},Symbol.toStringTag,{value:"Module"})),Vn=(t,e)=>`Must be an enum value in the set ${e}{ ${t.join(", ")} }`,It=t=>c(i.some(t),i.refine(V),i.map(j(ot,st)),i.defaultValue(t)),Bn=t=>typeof t=="string"||typeof t=="number",In=(t,e)=>n=>c(i.ofNullish(n),a.ofOption(()=>`Enum${e?` ${e}`:""} cannot be null/undefined`),a.refine(Bn,()=>`Enum${e?` ${e}`:""} must be a string or number`),a.map(It),a.bind(r=>c(t,zt(o=>It(o)===r),i.match({some:o=>a.ok(o),none:()=>a.err(Vn(t,e))})))),Y=t=>typeof t=="function",Kn=t=>e=>n=>{const r=Object.entries(t).find(([,u])=>u===n);if(!r)throw new TypeError(`Expected to match against an enum where '${n}' is a valid value.`);const o=r[0];if(!Object.hasOwn(e,o))throw new TypeError(`Expected a matcher containing a case for '${o}'.`);const s=e[o];return Y(s)?s():s},Wn=t=>e=>n=>{const r=Object.entries(t).find(([,s])=>s===n);if(!r)throw new TypeError(`Expected to match against an enum where '${n}' is a valid value.`);const o=r[0];if(Object.hasOwn(e,o)){const s=e[o];return Y(s)?s():s}return Y(e.orElse)?e.orElse():e.orElse},Fn=(t,e="")=>{const n=Object.entries(t).reduce((o,[s,u])=>({...o,[s]:u}),{}),r=Object.values(t);return{...n,values:r,parse:In(r,e),match:Kn(t),matchOrElse:Wn(t)}},Ln=t=>typeof t=="function",Kt=(t,e,n)=>Object.entries(t).reduce((r,o)=>{const[s,u]=o,p=L(s),z=n.length>0?`${n}${p}`:`${p}`;return Object.assign(r,{[s]:Ln(u)?(...D)=>({[e]:z,...u(...D)}):{[e]:z}})},{}),Wt=(t,e)=>Object.entries(t).reduce((n,r)=>{const[o]=r,s=L(o),u=e.length>0?`${e}${s}`:`${s}`;return Object.assign(n,{[o]:u})},{}),Ft=(t,e)=>e.length>0?t.replace(new RegExp(`${e}`),""):t,Lt=(t,e)=>n=>r=>{const o=U(Ft(r[t],e));if(!Object.hasOwn(n,o))throw new TypeError(`Expected to be given a variant with scope ${e}. Actual type was ${r[t]}`);const s=n[o],u={...r};return delete u[t],typeof s=="function"?s(u):s},Ut=(t,e)=>n=>r=>{const o=U(Ft(r[t],e));if(Object.hasOwn(n,o)){const s=n[o],u={...r};return delete u[t],typeof s=="function"?s(u):s}return typeof n.orElse=="function"?n.orElse():n.orElse},Un=(t,e,n)=>({...Kt(t,e,n),match:Lt(e,n),matchOrElse:Ut(e,n),types:Wt(t,n)}),Hn=t=>({...Kt(t,"_tag",""),match:Lt("_tag",""),matchOrElse:Ut("_tag",""),types:Wt(t,"")}),Z=t=>k.resolved(a.ok(t)),x=t=>k.resolved(a.err(t)),Gn=t=>typeof t!="function",m=(t,e)=>Gn(t)?t:t(e),W=(t,e)=>Object.hasOwn(e,t),tt=t=>e=>{switch(e._tag){case"InProgress":return m(t.inProgress,void 0);case"NotStarted":return m(t.notStarted,void 0);case"Resolved":return c(e.resolved,a.match({ok:n=>m(t.resolvedOk,n),err:n=>m(t.resolvedErr,n)}));default:return A(e)}},Jn=Object.freeze(Object.defineProperty({__proto__:null,err:x,map:t=>tt({resolvedOk:j(t,Z),resolvedErr:x,inProgress:k.inProgress,notStarted:k.notStarted}),mapErr:t=>tt({resolvedErr:j(t,x),resolvedOk:Z,inProgress:k.inProgress,notStarted:k.notStarted}),match:tt,matchOrElse:t=>e=>{switch(e._tag){case"InProgress":return W("inProgress",t)?m(t.inProgress,void 0):m(t.orElse,void 0);case"NotStarted":return W("notStarted",t)?m(t.notStarted,void 0):m(t.orElse,void 0);case"Resolved":return c(e.resolved,a.match({ok:n=>W("resolvedOk",t)?m(t.resolvedOk,n):m(t.orElse,void 0),err:n=>W("resolvedErr",t)?m(t.resolvedErr,n):m(t.orElse,void 0)}));default:return A(e)}},ok:Z},Symbol.toStringTag,{value:"Module"})),S=t=>Object.keys(t).length<1,M=()=>({}),q=(t,{equals:e}=y.Default)=>n=>{if(S(n))return i.none;for(const r in n)if(e(r,t.toString()))return i.some([r,n[r]]);return i.none},Qn=(t,e)=>n=>c(n,q(t,e),i.isSome),Xn=(t,e)=>n=>c(n,q(t,e),i.map(([,r])=>r)),F=([t,e],n)=>r=>S(r)?{[t]:e}:c(r,q(t,n),i.match({none:()=>({...r,[t]:e}),some:([o])=>({...r,[o]:e})})),Yn=t=>e=>{if(S(e))return M();const n=M();for(const r in e)n[r]=t(r,e[r]);return n},et=({compare:t}=E.Default)=>e=>Object.keys(e).sort(t),Zn=(t,e=E.Default)=>n=>c(n,et(e),r=>r.find(t),i.ofNullish),xn=t=>e=>{if(S(e))return!1;for(const n in e)if(t(e[n]))return!0;return!1},tr=(t,e,n)=>r=>c(r,q(t,n),i.match({some:([o,s])=>c(r,F([o,e(s)])),none:r})),er=t=>Object.entries(t).length,nr=(t=E.Default)=>e=>{const n=[];for(const r in e)n.push(e[r]);return n.sort(t.compare)},nt=t=>e=>c(e,et(t),n=>n.map(r=>[r,e[r]])),rr=Object.freeze(Object.defineProperty({__proto__:null,change:tr,containsKey:Qn,empty:M,every:t=>e=>{if(S(e))return!0;for(const n in e)if(!t(n,e[n]))return!1;return!0},exists:xn,filter:t=>e=>{if(S(e))return e;const n=M();for(const r in e)t(r,e[r])&&(n[r]=e[r]);return n},find:Xn,findKey:Zn,findWithKey:q,isEmpty:S,iter:t=>e=>{if(!S(e))for(const n in e)t(n,e[n])},keys:et,map:Yn,ofArray:(t,e)=>t.length<1?M():t.reduce((n,r)=>c(n,F(r,e)),M()),ofRecord:(t,e)=>Object.entries(t).reduce((n,[r,o])=>c(n,F([r,o],e)),M()),reduce:(t,e,n)=>r=>c(r,nt(n),o=>o.reduce((s,[u,p])=>e(s,u,p),t)),reduceRight:(t,e,n)=>r=>c(r,nt(n),o=>o.reduceRight((s,[u,p])=>e(s,u,p),t)),remove:(t,e)=>n=>c(n,q(t,e),i.match({some:([r,o])=>{const s={...n};return delete s[r],s},none:n})),set:F,size:er,toArray:nt,values:nr},Symbol.toStringTag,{value:"Module"}));return l.Array=On,l.Async=I,l.AsyncResult=Ge,l.Deferred=k,l.DeferredResult=Jn,l.EqualityComparer=y,l.Map=Nn,l.NonEmptyArray=Mn,l.Nullable=de,l.Option=i,l.OrderingComparer=E,l.Rec=rr,l.Result=a,l.String=xt,l.enumOf=Fn,l.flow=j,l.pipe=c,l.tee=Ht,l.teeAsync=Gt,l.variant=Hn,l.variantC=Un,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"}),l}({}); |
@@ -20,1 +20,2 @@ export { pipe, flow } from "./Composition"; | ||
export { DeferredResult } from "./DeferredResult"; | ||
export { Rec } from "./Rec"; |
@@ -21,3 +21,3 @@ import { EqualityComparer } from "../EqualityComparer"; | ||
*/ | ||
export declare const findWithKey: <K>(key: K, { equals }?: EqualityComparer<K>) => <V>(map: ReadonlyMap<K, V>) => Option<[K, V]>; | ||
export declare const findWithKey: <K>(key: NoInfer<K>, { equals }?: EqualityComparer<NoInfer<K>>) => <V>(map: ReadonlyMap<K, V>) => Option<readonly [K, V]>; | ||
/** | ||
@@ -31,3 +31,3 @@ * Test whether a `Map` contains the given key. Uses the given `EqualityComparer` | ||
*/ | ||
export declare const containsKey: <K>(key: K, equalityComparer?: EqualityComparer<K>) => <V>(map: ReadonlyMap<K, V>) => boolean; | ||
export declare const containsKey: <K>(key: NoInfer<K>, equalityComparer?: EqualityComparer<NoInfer<K>>) => <V>(map: ReadonlyMap<K, V>) => boolean; | ||
/** | ||
@@ -42,3 +42,3 @@ * Get a value associated with the given key from the `Map`. Returns a `Some` | ||
*/ | ||
export declare const find: <K>(key: K, equalityComparer?: EqualityComparer<K>) => <V extends NonNullish>(map: ReadonlyMap<K, V>) => Option<V>; | ||
export declare const find: <K>(key: NoInfer<K>, equalityComparer?: EqualityComparer<NoInfer<K>>) => <V extends NonNullish>(map: ReadonlyMap<K, V>) => Option<V>; | ||
/** | ||
@@ -63,3 +63,3 @@ * Adds a key/value pair to a `Map`. If the given key already exists | ||
*/ | ||
export declare const map: <K, V, R>(f: (k: K, v: V) => R) => (map: ReadonlyMap<K, V>) => ReadonlyMap<K, R>; | ||
export declare const map: <K, V, R>(f: (k: NoInfer<K>, v: NoInfer<V>) => R) => (map: ReadonlyMap<K, V>) => ReadonlyMap<K, R>; | ||
/** | ||
@@ -73,3 +73,3 @@ * Get the first key for which the given predicate function returns | ||
*/ | ||
export declare const findKey: <K extends NonNullish>(predicate: Predicate<K>, orderingComparer?: OrderingComparer<K>) => <V>(map: ReadonlyMap<K, V>) => Option<K>; | ||
export declare const findKey: <K extends NonNullish>(predicate: Predicate<NoInfer<K>>, orderingComparer?: OrderingComparer<NoInfer<K>>) => <V>(map: ReadonlyMap<K, V>) => Option<K>; | ||
/** | ||
@@ -89,7 +89,7 @@ * Creates a new empty map. Essentially an alias for `new globalThis.Map()`. | ||
*/ | ||
export declare const exists: <V>(predicate: Predicate<V>) => <K>(map: ReadonlyMap<K, V>) => boolean; | ||
export declare const exists: <V>(predicate: Predicate<NoInfer<V>>) => <K>(map: ReadonlyMap<K, V>) => boolean; | ||
/** | ||
* Replace the value at a given key in the map using the given | ||
* replacement function. Will use the given `EqualityComparer` | ||
* if passed. Otherwise defaults to reference equality (triple equals). | ||
* if passed. Otherwise, defaults to reference equality (triple equals). | ||
* | ||
@@ -100,3 +100,3 @@ * If the key isn't in the map, returns the map unchanged. | ||
*/ | ||
export declare const change: <K, V>(key: K, f: (v: V) => V, equalityComparer?: EqualityComparer<K>) => (map: ReadonlyMap<K, V>) => ReadonlyMap<K, V>; | ||
export declare const change: <K, V>(key: NoInfer<K>, f: (v: NoInfer<V>) => NoInfer<V>, equalityComparer?: EqualityComparer<NoInfer<K>>) => (map: ReadonlyMap<K, V>) => ReadonlyMap<K, V>; | ||
/** | ||
@@ -122,3 +122,3 @@ * Get the number of key/value pairs in the map. | ||
*/ | ||
export declare const keys: <K>({ compare }?: OrderingComparer<K>) => <V>(map: ReadonlyMap<K, V>) => readonly K[]; | ||
export declare const keys: <K>({ compare }?: OrderingComparer<NoInfer<K>>) => <V>(map: ReadonlyMap<K, V>) => readonly K[]; | ||
/** | ||
@@ -131,3 +131,3 @@ * Gets all the values from the map as an array, including duplicates. Values | ||
*/ | ||
export declare const values: <V>(orderingComparer?: OrderingComparer<V>) => <K>(map: ReadonlyMap<K, V>) => readonly V[]; | ||
export declare const values: <V>({ compare }?: OrderingComparer<NoInfer<V>>) => <K>(map: ReadonlyMap<K, V>) => readonly V[]; | ||
/** | ||
@@ -141,3 +141,3 @@ * Returns the map as an array of key-value tuples. The array will be sorted by | ||
*/ | ||
export declare const toArray: <K>(orderingComparer?: OrderingComparer<K>) => <V>(map: ReadonlyMap<K, V>) => readonly (readonly [K, V])[]; | ||
export declare const toArray: <K>(orderingComparer?: OrderingComparer<NoInfer<K>>) => <V>(map: ReadonlyMap<K, V>) => readonly (readonly [K, V])[]; | ||
/** | ||
@@ -159,3 +159,3 @@ * Also commonly referred to as `fold` or `aggregate`. Applies each key/value | ||
*/ | ||
export declare const reduce: <S, K, V>(init: S, f: (acc: S, k: K, v: V) => S, orderingComparer?: OrderingComparer<K>) => (map: ReadonlyMap<K, V>) => S; | ||
export declare const reduce: <S, K, V>(init: S, f: (acc: S, k: NoInfer<K>, v: NoInfer<V>) => S, orderingComparer?: OrderingComparer<NoInfer<K>>) => (map: ReadonlyMap<K, V>) => S; | ||
/** | ||
@@ -165,3 +165,3 @@ * Like {@link reduce}, but the key-value pairs are passed to the reducer in | ||
*/ | ||
export declare const reduceRight: <S, K, V>(init: S, f: (acc: S, k: K, v: V) => S, orderingComparer?: OrderingComparer<K>) => (map: ReadonlyMap<K, V>) => S; | ||
export declare const reduceRight: <S, K, V>(init: S, f: (acc: S, k: NoInfer<K>, v: NoInfer<V>) => S, orderingComparer?: OrderingComparer<NoInfer<K>>) => (map: ReadonlyMap<K, V>) => S; | ||
/** | ||
@@ -174,3 +174,3 @@ * Get a new map containing only the key/value pairs for which the given | ||
*/ | ||
export declare const filter: <K, V>(f: (k: K, v: V) => boolean) => (map: ReadonlyMap<K, V>) => ReadonlyMap<K, V>; | ||
export declare const filter: <K, V>(f: (k: NoInfer<K>, v: NoInfer<V>) => boolean) => (map: ReadonlyMap<K, V>) => ReadonlyMap<K, V>; | ||
/** | ||
@@ -182,3 +182,3 @@ * Test whether every key/value pair in a map returns `true` for the | ||
*/ | ||
export declare const every: <K, V>(f: (k: K, v: V) => boolean) => (map: ReadonlyMap<K, V>) => boolean; | ||
export declare const every: <K, V>(f: (k: NoInfer<K>, v: NoInfer<V>) => boolean) => (map: ReadonlyMap<K, V>) => boolean; | ||
/** | ||
@@ -196,3 +196,3 @@ * Execute an arbitrary side-effect function for every key/value pair in the map. | ||
*/ | ||
export declare const iter: <K, V>(f: (k: K, v: V) => void) => (map: ReadonlyMap<K, V>) => void; | ||
export declare const iter: <K, V>(f: (k: NoInfer<K>, v: NoInfer<V>) => void) => (map: ReadonlyMap<K, V>) => void; | ||
/** | ||
@@ -211,3 +211,3 @@ * Convert an array of tuples into a map of key/value pairs. | ||
*/ | ||
export declare const remove: <K>(key: K, equalityComparer?: EqualityComparer<K>) => <V>(map: ReadonlyMap<K, V>) => ReadonlyMap<K, V>; | ||
export declare const remove: <K>(key: NoInfer<K>, equalityComparer?: EqualityComparer<NoInfer<K>>) => <V>(map: ReadonlyMap<K, V>) => ReadonlyMap<K, V>; | ||
/** | ||
@@ -214,0 +214,0 @@ * Convert a `Record` object into a map of key/value pairs. Uses `Object.entries` |
@@ -22,3 +22,3 @@ { | ||
], | ||
"version": "1.5.0", | ||
"version": "1.6.1", | ||
"type": "module", | ||
@@ -25,0 +25,0 @@ "main": "./dist/fp-toolkit.cjs", |
@@ -35,7 +35,7 @@ # fp-toolkit ⚒️ | ||
### [Function composition](src/composition/index.ts) | ||
### [Function composition](src/Composition.ts) | ||
The function composition module exposes `pipe` for right-to-left pipelining of values through a set of functions, and it exposes `flow` for right-to-left function composition. | ||
### [Array](src/Array.ts) | ||
### [Array](src/Array/Array.ts) | ||
@@ -52,3 +52,3 @@ The `Array` module is a set of useful, type-safe functions for working with `readonly` arrays using functional composition/pipelining. It offers functions like: | ||
### [NonEmptyArray](src/NonEmptyArray.ts) | ||
### [NonEmptyArray](src/NonEmptyArray/NonEmptyArray.ts) | ||
@@ -63,3 +63,3 @@ The `NonEmptyArray` module is a set of useful, type-safe functions for working with `readonly` arrays that contain at least one element. It offers _additional_ functions on top of the `Array` module like: | ||
### [Async](src/Async.ts) | ||
### [Async](src/Async/Async.ts) | ||
@@ -75,3 +75,3 @@ The `Async` module helps you model and manage asynchronous workflows. Best of all, `Async` computations are _Lazy_, which means no work will start until you explicitly ask it to! The `Async` module offers: | ||
### [Result](src/Result.ts) | ||
### [Result](src/Result/Result.ts) | ||
@@ -85,3 +85,3 @@ The `Result` module is a simple, predictable, and type-safe way to model the outcome of an operation that can fail. `Result`s come in handy in tons of situations: network calls, parsing unsafe input, DOM updates that may fail to apply, etc. The `Result` module offers: | ||
### [AsyncResult](src/AsyncResult.ts) | ||
### [AsyncResult](src/AsyncResult/AsyncResult.ts) | ||
@@ -95,3 +95,3 @@ The `AsyncResult` module helps you model in a predictable, type-safe way any kind of async operation that can fail. (It's just the `Async` type with a more specific "inner value.") | ||
### [Option](src/Option.ts) | ||
### [Option](src/Option/Option.ts) | ||
@@ -123,3 +123,3 @@ The ubuqituos `Option<T>` type. For those of you who are sick of null reference exceptions and want a way to model optional values that forces you to deal with the possibility of null, while retaining the fluidity of function composition pipelining. This module gives you: | ||
### [Deferred](src/Deferred.ts) & [DeferredResult](src/DeferredResult.ts) | ||
### [Deferred](src/Deferred/Deferred.ts) & [DeferredResult](src/DeferredResult/DeferredResult.ts) | ||
@@ -132,3 +132,3 @@ The `Deferred` and `DeferredResult` types are a kind of analogy to the `Async` and `AsyncResult` types. The `Async*` types model the work itself; the `Deferred*` types model the _state_ of the ongoing async operation. These two types are incredibly useful in Redux reducer functions (or vanilla React `useReducer` hooks) because they can succinctly model exactly and only the valid states of an asynchronous operation. And they do that without "flag soup" of a bunch of loosely related boolean flags that are _implicitly_ related to each other. | ||
### [EqualityComparer](src/EqualityComparer.ts) & [OrderingComparer](src/OrderingComparer.ts) | ||
### [EqualityComparer](src/EqualityComparer/EqualityComparer.ts) & [OrderingComparer](src/OrderingComparer/OrderingComparer.ts) | ||
@@ -149,3 +149,3 @@ These modules make structural equality and decidable ordering of elements in TypeScript much easier. Easily describe how you would like types to be compared using functions like: | ||
### [Map](src/Map.ts) | ||
### [Map](src/Map/Map.ts) | ||
@@ -159,3 +159,3 @@ Work with `Map` data structures in a type-safe and immutable way. Offers helpful utilities like: | ||
### [Nullable](src/Nullable.ts) | ||
### [Nullable](src/Nullable/Nullable.ts) | ||
@@ -169,3 +169,3 @@ Work with types that may be `null | undefined` in a fluid way. The nullish-coalescing `??` and elvis `?.` operators only get you so far, because they require that you use a method-chaining approach. Using function pipelining with the `Nullable` module you can use any function you write with things like: | ||
### [String](src/String.ts) | ||
### [String](src/String/String.ts) | ||
@@ -172,0 +172,0 @@ A bunch of useful functions for working with strings in a functional paradigm. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
232511
63
5207