functype 0.8.7 → 0.8.8

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.
Files changed (50) hide show
  1. package/dist/chunk-4JXKOGY4.mjs +1 -0
  2. package/dist/chunk-YWNQJQON.js +1 -0
  3. package/dist/collections/index.d.mts +1 -1
  4. package/dist/collections/index.d.ts +1 -1
  5. package/dist/either/Either.d.mts +1 -1
  6. package/dist/either/Either.d.ts +1 -1
  7. package/dist/either/Either.js +1 -1
  8. package/dist/either/Either.mjs +1 -1
  9. package/dist/{index-DUzgmWat.d.mts → index-BClvlOd9.d.mts} +5 -1
  10. package/dist/{index-C_T4wCVA.d.ts → index-CCr9-bb6.d.ts} +5 -1
  11. package/dist/index.d.mts +1 -1
  12. package/dist/index.d.ts +1 -1
  13. package/dist/index.js +1 -1
  14. package/dist/index.mjs +1 -1
  15. package/dist/iterable/Seq.d.mts +1 -1
  16. package/dist/iterable/Seq.d.ts +1 -1
  17. package/dist/iterable/Seq.js +1 -1
  18. package/dist/iterable/Seq.mjs +1 -1
  19. package/dist/iterable/index.d.mts +1 -1
  20. package/dist/iterable/index.d.ts +1 -1
  21. package/dist/iterable/index.js +1 -1
  22. package/dist/iterable/index.mjs +1 -1
  23. package/dist/list/List.d.mts +1 -1
  24. package/dist/list/List.d.ts +1 -1
  25. package/dist/list/List.js +1 -1
  26. package/dist/list/List.mjs +1 -1
  27. package/dist/map/Map.d.mts +1 -1
  28. package/dist/map/Map.d.ts +1 -1
  29. package/dist/map/Map.js +1 -1
  30. package/dist/map/Map.mjs +1 -1
  31. package/dist/option/Option.d.mts +1 -1
  32. package/dist/option/Option.d.ts +1 -1
  33. package/dist/option/Option.js +1 -1
  34. package/dist/option/Option.mjs +1 -1
  35. package/dist/set/Set.d.mts +1 -1
  36. package/dist/set/Set.d.ts +1 -1
  37. package/dist/set/Set.js +1 -1
  38. package/dist/set/Set.mjs +1 -1
  39. package/dist/try/Try.d.mts +1 -1
  40. package/dist/try/Try.d.ts +1 -1
  41. package/dist/try/Try.js +1 -1
  42. package/dist/try/Try.mjs +1 -1
  43. package/dist/util/index.d.mts +1 -1
  44. package/dist/util/index.d.ts +1 -1
  45. package/dist/util/index.js +1 -1
  46. package/dist/util/index.mjs +1 -1
  47. package/lib/either/Either.d.ts +4 -0
  48. package/package.json +1 -1
  49. package/dist/chunk-ENNA2JEU.js +0 -1
  50. package/dist/chunk-UVJF4QMH.mjs +0 -1
@@ -0,0 +1 @@
1
+ import{a as O}from"./chunk-2I2NKDFN.mjs";import{a as h}from"./chunk-RRAIFS3D.mjs";import{a as E}from"./chunk-377WQNCB.mjs";import{a as B}from"./chunk-HA5XD5KC.mjs";var d=e=>{let t=h(e)?e:e instanceof Object&&"toArray"in e?e.toArray():[],r=Array.from(t);return{[Symbol.iterator]:()=>r[Symbol.iterator](),get length(){return r.length},map:o=>d(r.map(o)),flatMap:o=>d(r.flatMap(i=>o(i).toArray())),forEach:o=>r.forEach(o),count:o=>r.filter(o).length,exists:o=>r.some(o),filter:o=>d(r.filter(o)),filterNot:o=>d(r.filter(i=>!o(i))),find:o=>f(r.find(o)),get head(){return r[0]},get headOption(){return r.length>0?f(r[0]):y()},get isEmpty(){return r.length===0},get size(){return r.length},toArray:()=>[...r],reduce:o=>r.reduce(o),reduceRight:o=>r.reduceRight(o),foldLeft:o=>i=>r.reduce(i,o),foldRight:o=>i=>r.reduceRight((a,p)=>i(p,a),o),valueOf:()=>({values:r})}},l=e=>d(e);var g=e=>{let t=h(e)?new B(e):new B(e?.toArray()??[]),r=l(t),o={...r,add:i=>g([...t,i]),remove:i=>{let a=new B(t);return a.delete(i),g(a)},contains:i=>t.has(i),has:i=>t.has(i),map:i=>g(r.map(i)),flatMap:i=>g(r.flatMap(i)),toList:()=>A(t),toSet:()=>o,toString:()=>`Set(${Array.from(t).toString()})`};return o},S=e=>g(e);var c=e=>{function t(a){return a!=null&&typeof a[Symbol.iterator]=="function"}let r=Array.isArray(e)?e:t(e)?Array.from(e):[],o=l(r),i={...o,length:r.length,map:a=>c(r.map(a)),flatMap:a=>c(o.flatMap(a)),remove:a=>{let p=r.indexOf(a);return i.removeAt(p)},contains:a=>r.includes(a),add:a=>c([...r,a]),removeAt:a=>a<0||a>=r.length?i:c([...r.slice(0,a),...r.slice(a+1)]),get:a=>f(r[a]),concat:a=>c([...r,...a.toArray()]),toList:()=>i,toSet:()=>S(r),toString:()=>`List(${r.toString()})`};return new Proxy(i,{get(a,p){return typeof p=="symbol"||isNaN(Number(p))?a[p]:a.get(Number(p))}})},A=e=>c(e);var U=e=>({_tag:"Right",value:e,isLeft:()=>!1,isRight:()=>!0,getOrElse:t=>e,map:t=>U(t(e)),mapAsync:async t=>{let r=await t(e);return U(r)},flatMap:t=>t(e),flatMapAsync:async t=>await t(e),toOption:()=>L(e),toList:()=>A([e]),valueOf:()=>({_tag:"Right",value:e}),toString:()=>`Right(${JSON.stringify(e)})`}),b=e=>({_tag:"Left",value:e,isLeft:()=>!0,isRight:()=>!1,getOrElse:t=>t,map:t=>b(e),mapAsync:async t=>b(e),flatMap:t=>b(e),flatMapAsync:async t=>b(e),toOption:()=>y(),toList:()=>A(),valueOf:()=>({_tag:"Left",value:e}),toString:()=>`Left(${JSON.stringify(e)})`}),m=e=>U(e),T=e=>b(e),Ae=e=>e.isRight(),ue=e=>e.isLeft(),ce=(e,t)=>{try{return m(e())}catch(r){return T(t(r))}},me=async(e,t)=>{try{let r=await e();return m(r)}catch(r){return T(t(r))}};var u=e=>{let t={values:new E(e)},r=()=>Array.from(t.values.entries()).map(([n,s])=>O([n,s])),o=n=>u(new E(t.values).set(n.toArray()[0],n.toArray()[1]).entries()),i=n=>{let s=new E(t.values);return s.delete(n)?u(s.entries()):u(t.values.entries())},a=n=>t.values.get(n[0])===n[1],p=()=>t.values.size,v=n=>u(Array.from(t.values.entries()).map(([s,q])=>[s,n(q)])),V=n=>{let s=u(t.values.entries()).toList();return u(s.flatMap(n).toArray())},K=n=>l(r()).reduce(n),I=n=>l(r()).reduceRight(n),M=n=>s=>l(r()).foldLeft(n)(s),w=n=>s=>l(r()).foldRight(n)(s),N=n=>f(t.values.get(n)),z=(n,s)=>f(t.values.get(n)).getOrElse(s),F=()=>t.values.size===0;return{add:o,remove:i,contains:a,get size(){return p()},map:v,flatMap:V,reduce:K,reduceRight:I,foldLeft:M,foldRight:w,get:N,getOrElse:z,get isEmpty(){return F()},orElse:(n,s)=>f(t.values.get(n)).orElse(s),toList:()=>A(r()),toSet:()=>S(r()),toString:()=>`Map(${r().toString()})`}},Se=e=>u(e);var x=e=>({_tag:"Success",value:e,error:void 0,isSuccess:()=>!0,isFailure:()=>!1,get:()=>e,getOrElse:t=>e,orElse:t=>x(e),orThrow:t=>e,toEither:()=>m(e),map:t=>P(()=>t(e)),flatMap:t=>t(e),valueOf:()=>({_tag:"Success",value:e}),toString:()=>`Success(${JSON.stringify(e)})`}),_=e=>({_tag:"Failure",value:void 0,error:e,isSuccess:()=>!1,isFailure:()=>!0,get:()=>{throw e},getOrElse:t=>t,orElse:t=>t,orThrow:t=>{throw t},toEither:()=>T(e),map:t=>_(e),flatMap:t=>_(e),valueOf:()=>({_tag:"Failure",error:e}),toString:()=>`Failure(${e.message})`}),P=e=>{try{return x(e())}catch(t){return _(t instanceof Error?t:new Error(String(t)))}};var L=e=>({_tag:"Some",value:e,isEmpty:!1,get:()=>e,getOrElse:()=>e,orElse:()=>L(e),map:t=>L(t(e)),flatMap:t=>t(e),reduce:t=>t(void 0,e),reduceRight:t=>t(void 0,e),foldLeft:t=>r=>r(t,e),foldRight:t=>r=>r(e,t),toList:()=>l([e]),contains:t=>t===e,size:1,toEither:t=>m(e),toString:()=>`Some(${JSON.stringify(e)})`,valueOf:()=>({_tag:"Some",value:e})}),R={_tag:"None",value:void 0,isEmpty:!0,get:()=>{throw new Error("Cannot call get() on None")},getOrElse:e=>e,orElse:e=>e,map:e=>R,flatMap:e=>R,reduce:()=>{},reduceRight:()=>{},foldLeft:e=>()=>e,foldRight:e=>()=>e,toList:()=>l([]),contains:()=>!1,size:0,toEither:e=>T(e),toString:()=>"None",valueOf:()=>({_tag:"None"})},y=()=>R,f=e=>e!=null?L(e):y();export{L as a,y as b,f as c,d,l as e,S as f,A as g,m as h,T as i,Ae as j,ue as k,ce as l,me as m,Se as n,P as o};
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunkOXLZ6UIZjs = require('./chunk-OXLZ6UIZ.js');var _chunkBNNK42JCjs = require('./chunk-BNNK42JC.js');var _chunk5VTXJIR3js = require('./chunk-5VTXJIR3.js');var _chunk3VJERXBPjs = require('./chunk-3VJERXBP.js');var d=e=>{let t=_chunkBNNK42JCjs.a.call(void 0, e)?e:e instanceof Object&&"toArray"in e?e.toArray():[],r=Array.from(t);return{[Symbol.iterator]:()=>r[Symbol.iterator](),get length(){return r.length},map:o=>d(r.map(o)),flatMap:o=>d(r.flatMap(i=>o(i).toArray())),forEach:o=>r.forEach(o),count:o=>r.filter(o).length,exists:o=>r.some(o),filter:o=>d(r.filter(o)),filterNot:o=>d(r.filter(i=>!o(i))),find:o=>f(r.find(o)),get head(){return r[0]},get headOption(){return r.length>0?f(r[0]):y()},get isEmpty(){return r.length===0},get size(){return r.length},toArray:()=>[...r],reduce:o=>r.reduce(o),reduceRight:o=>r.reduceRight(o),foldLeft:o=>i=>r.reduce(i,o),foldRight:o=>i=>r.reduceRight((a,p)=>i(p,a),o),valueOf:()=>({values:r})}},l= exports.e =e=>d(e);var g=e=>{let t=_chunkBNNK42JCjs.a.call(void 0, e)?new (0, _chunk3VJERXBPjs.a)(e):new (0, _chunk3VJERXBPjs.a)(_nullishCoalesce(_optionalChain([e, 'optionalAccess', _2 => _2.toArray, 'call', _3 => _3()]), () => ([]))),r=l(t),o={...r,add:i=>g([...t,i]),remove:i=>{let a=new (0, _chunk3VJERXBPjs.a)(t);return a.delete(i),g(a)},contains:i=>t.has(i),has:i=>t.has(i),map:i=>g(r.map(i)),flatMap:i=>g(r.flatMap(i)),toList:()=>A(t),toSet:()=>o,toString:()=>`Set(${Array.from(t).toString()})`};return o},S= exports.f =e=>g(e);var c=e=>{function t(a){return a!=null&&typeof a[Symbol.iterator]=="function"}let r=Array.isArray(e)?e:t(e)?Array.from(e):[],o=l(r),i={...o,length:r.length,map:a=>c(r.map(a)),flatMap:a=>c(o.flatMap(a)),remove:a=>{let p=r.indexOf(a);return i.removeAt(p)},contains:a=>r.includes(a),add:a=>c([...r,a]),removeAt:a=>a<0||a>=r.length?i:c([...r.slice(0,a),...r.slice(a+1)]),get:a=>f(r[a]),concat:a=>c([...r,...a.toArray()]),toList:()=>i,toSet:()=>S(r),toString:()=>`List(${r.toString()})`};return new Proxy(i,{get(a,p){return typeof p=="symbol"||isNaN(Number(p))?a[p]:a.get(Number(p))}})},A= exports.g =e=>c(e);var U=e=>({_tag:"Right",value:e,isLeft:()=>!1,isRight:()=>!0,getOrElse:t=>e,map:t=>U(t(e)),mapAsync:async t=>{let r=await t(e);return U(r)},flatMap:t=>t(e),flatMapAsync:async t=>await t(e),toOption:()=>L(e),toList:()=>A([e]),valueOf:()=>({_tag:"Right",value:e}),toString:()=>`Right(${JSON.stringify(e)})`}),b=e=>({_tag:"Left",value:e,isLeft:()=>!0,isRight:()=>!1,getOrElse:t=>t,map:t=>b(e),mapAsync:async t=>b(e),flatMap:t=>b(e),flatMapAsync:async t=>b(e),toOption:()=>y(),toList:()=>A(),valueOf:()=>({_tag:"Left",value:e}),toString:()=>`Left(${JSON.stringify(e)})`}),m= exports.h =e=>U(e),T= exports.i =e=>b(e),Ae= exports.j =e=>e.isRight(),ue= exports.k =e=>e.isLeft(),ce= exports.l =(e,t)=>{try{return m(e())}catch(r){return T(t(r))}},me= exports.m =async(e,t)=>{try{let r=await e();return m(r)}catch(r){return T(t(r))}};var u=e=>{let t={values:new (0, _chunk5VTXJIR3js.a)(e)},r=()=>Array.from(t.values.entries()).map(([n,s])=>_chunkOXLZ6UIZjs.a.call(void 0, [n,s])),o=n=>u(new (0, _chunk5VTXJIR3js.a)(t.values).set(n.toArray()[0],n.toArray()[1]).entries()),i=n=>{let s=new (0, _chunk5VTXJIR3js.a)(t.values);return s.delete(n)?u(s.entries()):u(t.values.entries())},a=n=>t.values.get(n[0])===n[1],p=()=>t.values.size,v=n=>u(Array.from(t.values.entries()).map(([s,q])=>[s,n(q)])),V=n=>{let s=u(t.values.entries()).toList();return u(s.flatMap(n).toArray())},K=n=>l(r()).reduce(n),I=n=>l(r()).reduceRight(n),M=n=>s=>l(r()).foldLeft(n)(s),w=n=>s=>l(r()).foldRight(n)(s),N=n=>f(t.values.get(n)),z=(n,s)=>f(t.values.get(n)).getOrElse(s),F=()=>t.values.size===0;return{add:o,remove:i,contains:a,get size(){return p()},map:v,flatMap:V,reduce:K,reduceRight:I,foldLeft:M,foldRight:w,get:N,getOrElse:z,get isEmpty(){return F()},orElse:(n,s)=>f(t.values.get(n)).orElse(s),toList:()=>A(r()),toSet:()=>S(r()),toString:()=>`Map(${r().toString()})`}},Se= exports.n =e=>u(e);var x=e=>({_tag:"Success",value:e,error:void 0,isSuccess:()=>!0,isFailure:()=>!1,get:()=>e,getOrElse:t=>e,orElse:t=>x(e),orThrow:t=>e,toEither:()=>m(e),map:t=>P(()=>t(e)),flatMap:t=>t(e),valueOf:()=>({_tag:"Success",value:e}),toString:()=>`Success(${JSON.stringify(e)})`}),_=e=>({_tag:"Failure",value:void 0,error:e,isSuccess:()=>!1,isFailure:()=>!0,get:()=>{throw e},getOrElse:t=>t,orElse:t=>t,orThrow:t=>{throw t},toEither:()=>T(e),map:t=>_(e),flatMap:t=>_(e),valueOf:()=>({_tag:"Failure",error:e}),toString:()=>`Failure(${e.message})`}),P= exports.o =e=>{try{return x(e())}catch(t){return _(t instanceof Error?t:new Error(String(t)))}};var L=e=>({_tag:"Some",value:e,isEmpty:!1,get:()=>e,getOrElse:()=>e,orElse:()=>L(e),map:t=>L(t(e)),flatMap:t=>t(e),reduce:t=>t(void 0,e),reduceRight:t=>t(void 0,e),foldLeft:t=>r=>r(t,e),foldRight:t=>r=>r(e,t),toList:()=>l([e]),contains:t=>t===e,size:1,toEither:t=>m(e),toString:()=>`Some(${JSON.stringify(e)})`,valueOf:()=>({_tag:"Some",value:e})}),R={_tag:"None",value:void 0,isEmpty:!0,get:()=>{throw new Error("Cannot call get() on None")},getOrElse:e=>e,orElse:e=>e,map:e=>R,flatMap:e=>R,reduce:()=>{},reduceRight:()=>{},foldLeft:e=>()=>e,foldRight:e=>()=>e,toList:()=>l([]),contains:()=>!1,size:0,toEither:e=>T(e),toString:()=>"None",valueOf:()=>({_tag:"None"})},y= exports.b =()=>R,f= exports.c =e=>e!=null?L(e):y();exports.a = L; exports.b = y; exports.c = f; exports.d = d; exports.e = l; exports.f = S; exports.g = A; exports.h = m; exports.i = T; exports.j = Ae; exports.k = ue; exports.l = ce; exports.m = me; exports.n = Se; exports.o = P;
@@ -1,4 +1,4 @@
1
- export { d as Collection, C as Converters } from '../index-DUzgmWat.mjs';
1
+ export { d as Collection, C as Converters } from '../index-BClvlOd9.mjs';
2
2
  import '../functor/index.mjs';
3
3
  import '../identity/Identity.mjs';
4
4
  import '../tuple/Tuple.mjs';
@@ -1,4 +1,4 @@
1
- export { d as Collection, C as Converters } from '../index-C_T4wCVA.js';
1
+ export { d as Collection, C as Converters } from '../index-CCr9-bb6.js';
2
2
  import '../functor/index.js';
3
3
  import '../identity/Identity.js';
4
4
  import '../tuple/Tuple.js';
@@ -1,5 +1,5 @@
1
1
  import '../functor/index.mjs';
2
- export { E as Either, e as Left, R as Right, f as isLeft, i as isRight, t as tryCatch } from '../index-DUzgmWat.mjs';
2
+ export { E as Either, e as Left, R as Right, f as isLeft, i as isRight, t as tryCatch, g as tryCatchAsync } from '../index-BClvlOd9.mjs';
3
3
  import '../typeable/Typeable.mjs';
4
4
  import '../identity/Identity.mjs';
5
5
  import '../tuple/Tuple.mjs';
@@ -1,5 +1,5 @@
1
1
  import '../functor/index.js';
2
- export { E as Either, e as Left, R as Right, f as isLeft, i as isRight, t as tryCatch } from '../index-C_T4wCVA.js';
2
+ export { E as Either, e as Left, R as Right, f as isLeft, i as isRight, t as tryCatch, g as tryCatchAsync } from '../index-CCr9-bb6.js';
3
3
  import '../typeable/Typeable.js';
4
4
  import '../identity/Identity.js';
5
5
  import '../tuple/Tuple.js';
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkENNA2JEUjs = require('../chunk-ENNA2JEU.js');require('../chunk-OXLZ6UIZ.js');require('../chunk-5O6YELD3.js');require('../chunk-BNNK42JC.js');require('../chunk-5VTXJIR3.js');require('../chunk-3VJERXBP.js');require('../chunk-XORABVON.js');require('../chunk-K3EKBPQE.js');exports.Left = _chunkENNA2JEUjs.i; exports.Right = _chunkENNA2JEUjs.h; exports.isLeft = _chunkENNA2JEUjs.k; exports.isRight = _chunkENNA2JEUjs.j; exports.tryCatch = _chunkENNA2JEUjs.l;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkYWNQJQONjs = require('../chunk-YWNQJQON.js');require('../chunk-OXLZ6UIZ.js');require('../chunk-5O6YELD3.js');require('../chunk-BNNK42JC.js');require('../chunk-5VTXJIR3.js');require('../chunk-3VJERXBP.js');require('../chunk-XORABVON.js');require('../chunk-K3EKBPQE.js');exports.Left = _chunkYWNQJQONjs.i; exports.Right = _chunkYWNQJQONjs.h; exports.isLeft = _chunkYWNQJQONjs.k; exports.isRight = _chunkYWNQJQONjs.j; exports.tryCatch = _chunkYWNQJQONjs.l; exports.tryCatchAsync = _chunkYWNQJQONjs.m;
@@ -1 +1 @@
1
- import{h as a,i as b,j as c,k as d,l as e}from"../chunk-UVJF4QMH.mjs";import"../chunk-2I2NKDFN.mjs";import"../chunk-V7DKESTM.mjs";import"../chunk-RRAIFS3D.mjs";import"../chunk-377WQNCB.mjs";import"../chunk-HA5XD5KC.mjs";import"../chunk-V2J3R5IU.mjs";import"../chunk-2ML63TYF.mjs";export{b as Left,a as Right,d as isLeft,c as isRight,e as tryCatch};
1
+ import{h as a,i as b,j as c,k as d,l as e,m as f}from"../chunk-4JXKOGY4.mjs";import"../chunk-2I2NKDFN.mjs";import"../chunk-V7DKESTM.mjs";import"../chunk-RRAIFS3D.mjs";import"../chunk-377WQNCB.mjs";import"../chunk-HA5XD5KC.mjs";import"../chunk-V2J3R5IU.mjs";import"../chunk-2ML63TYF.mjs";export{b as Left,a as Right,d as isLeft,c as isRight,e as tryCatch,f as tryCatchAsync};
@@ -120,8 +120,11 @@ type Either<L extends Type, R extends Type> = {
120
120
  value: L | R;
121
121
  isLeft: () => boolean;
122
122
  isRight: () => boolean;
123
+ getOrElse: (value: R) => R;
123
124
  map: <U extends Type>(f: (value: R) => U) => Either<L, U>;
125
+ mapAsync: <U extends Type>(f: (value: R) => Promise<U>) => Promise<Either<L, U>>;
124
126
  flatMap: <U extends Type>(f: (value: R) => Either<L, U>) => Either<L, U>;
127
+ flatMapAsync: <U extends Type>(f: (value: R) => Promise<Either<L, U>>) => Promise<Either<L, U>>;
125
128
  toOption: () => Option<R>;
126
129
  toList: () => List<R>;
127
130
  valueOf: () => {
@@ -139,6 +142,7 @@ declare const isLeft: <L, R>(either: Either<L, R>) => either is Either<L, R> & {
139
142
  value: L;
140
143
  };
141
144
  declare const tryCatch: <L, R>(f: () => R, onError: (error: unknown) => L) => Either<L, R>;
145
+ declare const tryCatchAsync: <L, R>(f: () => Promise<R>, onError: (error: unknown) => L) => Promise<Either<L, R>>;
142
146
 
143
147
  type SafeTraversable<K, V> = Omit<Traversable<Tuple<[K, V]>>, "map" | "flatMap">;
144
148
  type Map<K, V> = {
@@ -184,4 +188,4 @@ type Traversable<A extends Type> = Functor<A> & {
184
188
  foldRight<B>(z: B): (op: (a: A, b: B) => B) => B;
185
189
  };
186
190
 
187
- export { type Converters as C, type Either as E, List as L, Map as M, None as N, Option as O, Right as R, Some as S, Try as T, type _Iterable_ as _, Seq as a, Set as b, createSeq as c, type Collection as d, Left as e, isLeft as f, type Traversable as g, isRight as i, tryCatch as t };
191
+ export { type Converters as C, type Either as E, List as L, Map as M, None as N, Option as O, Right as R, Some as S, Try as T, type _Iterable_ as _, Seq as a, Set as b, createSeq as c, type Collection as d, Left as e, isLeft as f, tryCatchAsync as g, type Traversable as h, isRight as i, tryCatch as t };
@@ -120,8 +120,11 @@ type Either<L extends Type, R extends Type> = {
120
120
  value: L | R;
121
121
  isLeft: () => boolean;
122
122
  isRight: () => boolean;
123
+ getOrElse: (value: R) => R;
123
124
  map: <U extends Type>(f: (value: R) => U) => Either<L, U>;
125
+ mapAsync: <U extends Type>(f: (value: R) => Promise<U>) => Promise<Either<L, U>>;
124
126
  flatMap: <U extends Type>(f: (value: R) => Either<L, U>) => Either<L, U>;
127
+ flatMapAsync: <U extends Type>(f: (value: R) => Promise<Either<L, U>>) => Promise<Either<L, U>>;
125
128
  toOption: () => Option<R>;
126
129
  toList: () => List<R>;
127
130
  valueOf: () => {
@@ -139,6 +142,7 @@ declare const isLeft: <L, R>(either: Either<L, R>) => either is Either<L, R> & {
139
142
  value: L;
140
143
  };
141
144
  declare const tryCatch: <L, R>(f: () => R, onError: (error: unknown) => L) => Either<L, R>;
145
+ declare const tryCatchAsync: <L, R>(f: () => Promise<R>, onError: (error: unknown) => L) => Promise<Either<L, R>>;
142
146
 
143
147
  type SafeTraversable<K, V> = Omit<Traversable<Tuple<[K, V]>>, "map" | "flatMap">;
144
148
  type Map<K, V> = {
@@ -184,4 +188,4 @@ type Traversable<A extends Type> = Functor<A> & {
184
188
  foldRight<B>(z: B): (op: (a: A, b: B) => B) => B;
185
189
  };
186
190
 
187
- export { type Converters as C, type Either as E, List as L, Map as M, None as N, Option as O, Right as R, Some as S, Try as T, type _Iterable_ as _, Seq as a, Set as b, createSeq as c, type Collection as d, Left as e, isLeft as f, type Traversable as g, isRight as i, tryCatch as t };
191
+ export { type Converters as C, type Either as E, List as L, Map as M, None as N, Option as O, Right as R, Some as S, Try as T, type _Iterable_ as _, Seq as a, Set as b, createSeq as c, type Collection as d, Left as e, isLeft as f, tryCatchAsync as g, type Traversable as h, isRight as i, tryCatch as t };
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { AbstractFunctor, ArrayFunctor, ArrayType, Functor, SingleType, Type } from './functor/index.mjs';
2
- export { E as Either, e as Left, L as List, M as Map, N as None, O as Option, R as Right, a as Seq, b as Set, S as Some, g as Traversable, T as Try, _ as _Iterable_, f as isLeft, i as isRight, t as tryCatch } from './index-DUzgmWat.mjs';
2
+ export { E as Either, e as Left, L as List, M as Map, N as None, O as Option, R as Right, a as Seq, b as Set, S as Some, h as Traversable, T as Try, _ as _Iterable_, f as isLeft, i as isRight, t as tryCatch, g as tryCatchAsync } from './index-BClvlOd9.mjs';
3
3
  export { Identity } from './identity/Identity.mjs';
4
4
  export { Tuple } from './tuple/Tuple.mjs';
5
5
  export { Typeable } from './typeable/Typeable.mjs';
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { AbstractFunctor, ArrayFunctor, ArrayType, Functor, SingleType, Type } from './functor/index.js';
2
- export { E as Either, e as Left, L as List, M as Map, N as None, O as Option, R as Right, a as Seq, b as Set, S as Some, g as Traversable, T as Try, _ as _Iterable_, f as isLeft, i as isRight, t as tryCatch } from './index-C_T4wCVA.js';
2
+ export { E as Either, e as Left, L as List, M as Map, N as None, O as Option, R as Right, a as Seq, b as Set, S as Some, h as Traversable, T as Try, _ as _Iterable_, f as isLeft, i as isRight, t as tryCatch, g as tryCatchAsync } from './index-CCr9-bb6.js';
3
3
  export { Identity } from './identity/Identity.js';
4
4
  export { Tuple } from './tuple/Tuple.js';
5
5
  export { Typeable } from './typeable/Typeable.js';
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkENNA2JEUjs = require('./chunk-ENNA2JEU.js');var _chunkOXLZ6UIZjs = require('./chunk-OXLZ6UIZ.js');var _chunk5O6YELD3js = require('./chunk-5O6YELD3.js');require('./chunk-BNNK42JC.js');require('./chunk-5VTXJIR3.js');require('./chunk-3VJERXBP.js');require('./chunk-XORABVON.js');require('./chunk-K3EKBPQE.js');exports.Left = _chunkENNA2JEUjs.i; exports.List = _chunkENNA2JEUjs.g; exports.Map = _chunkENNA2JEUjs.m; exports.None = _chunkENNA2JEUjs.b; exports.Option = _chunkENNA2JEUjs.c; exports.Right = _chunkENNA2JEUjs.h; exports.Seq = _chunkENNA2JEUjs.e; exports.Set = _chunkENNA2JEUjs.f; exports.Some = _chunkENNA2JEUjs.a; exports.Try = _chunkENNA2JEUjs.n; exports.Tuple = _chunkOXLZ6UIZjs.a; exports.Typeable = _chunk5O6YELD3js.a; exports.isLeft = _chunkENNA2JEUjs.k; exports.isRight = _chunkENNA2JEUjs.j; exports.tryCatch = _chunkENNA2JEUjs.l;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkYWNQJQONjs = require('./chunk-YWNQJQON.js');var _chunkOXLZ6UIZjs = require('./chunk-OXLZ6UIZ.js');var _chunk5O6YELD3js = require('./chunk-5O6YELD3.js');require('./chunk-BNNK42JC.js');require('./chunk-5VTXJIR3.js');require('./chunk-3VJERXBP.js');require('./chunk-XORABVON.js');require('./chunk-K3EKBPQE.js');exports.Left = _chunkYWNQJQONjs.i; exports.List = _chunkYWNQJQONjs.g; exports.Map = _chunkYWNQJQONjs.n; exports.None = _chunkYWNQJQONjs.b; exports.Option = _chunkYWNQJQONjs.c; exports.Right = _chunkYWNQJQONjs.h; exports.Seq = _chunkYWNQJQONjs.e; exports.Set = _chunkYWNQJQONjs.f; exports.Some = _chunkYWNQJQONjs.a; exports.Try = _chunkYWNQJQONjs.o; exports.Tuple = _chunkOXLZ6UIZjs.a; exports.Typeable = _chunk5O6YELD3js.a; exports.isLeft = _chunkYWNQJQONjs.k; exports.isRight = _chunkYWNQJQONjs.j; exports.tryCatch = _chunkYWNQJQONjs.l; exports.tryCatchAsync = _chunkYWNQJQONjs.m;
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{a,b,c,e as d,f as e,g as f,h as g,i as h,j as i,k as j,l as k,m,n}from"./chunk-UVJF4QMH.mjs";import{a as l}from"./chunk-2I2NKDFN.mjs";import{a as o}from"./chunk-V7DKESTM.mjs";import"./chunk-RRAIFS3D.mjs";import"./chunk-377WQNCB.mjs";import"./chunk-HA5XD5KC.mjs";import"./chunk-V2J3R5IU.mjs";import"./chunk-2ML63TYF.mjs";export{h as Left,f as List,m as Map,b as None,c as Option,g as Right,d as Seq,e as Set,a as Some,n as Try,l as Tuple,o as Typeable,j as isLeft,i as isRight,k as tryCatch};
1
+ import{a,b,c,e as d,f as e,g as f,h as g,i as h,j as i,k as j,l as k,m as l,n,o}from"./chunk-4JXKOGY4.mjs";import{a as m}from"./chunk-2I2NKDFN.mjs";import{a as p}from"./chunk-V7DKESTM.mjs";import"./chunk-RRAIFS3D.mjs";import"./chunk-377WQNCB.mjs";import"./chunk-HA5XD5KC.mjs";import"./chunk-V2J3R5IU.mjs";import"./chunk-2ML63TYF.mjs";export{h as Left,f as List,n as Map,b as None,c as Option,g as Right,d as Seq,e as Set,a as Some,o as Try,m as Tuple,p as Typeable,j as isLeft,i as isRight,k as tryCatch,l as tryCatchAsync};
@@ -1,4 +1,4 @@
1
- export { a as Seq, c as createSeq } from '../index-DUzgmWat.mjs';
1
+ export { a as Seq, c as createSeq } from '../index-BClvlOd9.mjs';
2
2
  import '../functor/index.mjs';
3
3
  import '../identity/Identity.mjs';
4
4
  import '../tuple/Tuple.mjs';
@@ -1,4 +1,4 @@
1
- export { a as Seq, c as createSeq } from '../index-C_T4wCVA.js';
1
+ export { a as Seq, c as createSeq } from '../index-CCr9-bb6.js';
2
2
  import '../functor/index.js';
3
3
  import '../identity/Identity.js';
4
4
  import '../tuple/Tuple.js';
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkENNA2JEUjs = require('../chunk-ENNA2JEU.js');require('../chunk-OXLZ6UIZ.js');require('../chunk-5O6YELD3.js');require('../chunk-BNNK42JC.js');require('../chunk-5VTXJIR3.js');require('../chunk-3VJERXBP.js');require('../chunk-XORABVON.js');require('../chunk-K3EKBPQE.js');exports.Seq = _chunkENNA2JEUjs.e; exports.createSeq = _chunkENNA2JEUjs.d;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkYWNQJQONjs = require('../chunk-YWNQJQON.js');require('../chunk-OXLZ6UIZ.js');require('../chunk-5O6YELD3.js');require('../chunk-BNNK42JC.js');require('../chunk-5VTXJIR3.js');require('../chunk-3VJERXBP.js');require('../chunk-XORABVON.js');require('../chunk-K3EKBPQE.js');exports.Seq = _chunkYWNQJQONjs.e; exports.createSeq = _chunkYWNQJQONjs.d;
@@ -1 +1 @@
1
- import{d as a,e as b}from"../chunk-UVJF4QMH.mjs";import"../chunk-2I2NKDFN.mjs";import"../chunk-V7DKESTM.mjs";import"../chunk-RRAIFS3D.mjs";import"../chunk-377WQNCB.mjs";import"../chunk-HA5XD5KC.mjs";import"../chunk-V2J3R5IU.mjs";import"../chunk-2ML63TYF.mjs";export{b as Seq,a as createSeq};
1
+ import{d as a,e as b}from"../chunk-4JXKOGY4.mjs";import"../chunk-2I2NKDFN.mjs";import"../chunk-V7DKESTM.mjs";import"../chunk-RRAIFS3D.mjs";import"../chunk-377WQNCB.mjs";import"../chunk-HA5XD5KC.mjs";import"../chunk-V2J3R5IU.mjs";import"../chunk-2ML63TYF.mjs";export{b as Seq,a as createSeq};
@@ -1,5 +1,5 @@
1
1
  import '../functor/index.mjs';
2
- export { a as Seq, _ as _Iterable_ } from '../index-DUzgmWat.mjs';
2
+ export { a as Seq, _ as _Iterable_ } from '../index-BClvlOd9.mjs';
3
3
  import '../identity/Identity.mjs';
4
4
  import '../tuple/Tuple.mjs';
5
5
  import '../typeable/Typeable.mjs';
@@ -1,5 +1,5 @@
1
1
  import '../functor/index.js';
2
- export { a as Seq, _ as _Iterable_ } from '../index-C_T4wCVA.js';
2
+ export { a as Seq, _ as _Iterable_ } from '../index-CCr9-bb6.js';
3
3
  import '../identity/Identity.js';
4
4
  import '../tuple/Tuple.js';
5
5
  import '../typeable/Typeable.js';
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkENNA2JEUjs = require('../chunk-ENNA2JEU.js');require('../chunk-OXLZ6UIZ.js');require('../chunk-5O6YELD3.js');require('../chunk-BNNK42JC.js');require('../chunk-5VTXJIR3.js');require('../chunk-3VJERXBP.js');require('../chunk-XORABVON.js');require('../chunk-K3EKBPQE.js');exports.Seq = _chunkENNA2JEUjs.e;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkYWNQJQONjs = require('../chunk-YWNQJQON.js');require('../chunk-OXLZ6UIZ.js');require('../chunk-5O6YELD3.js');require('../chunk-BNNK42JC.js');require('../chunk-5VTXJIR3.js');require('../chunk-3VJERXBP.js');require('../chunk-XORABVON.js');require('../chunk-K3EKBPQE.js');exports.Seq = _chunkYWNQJQONjs.e;
@@ -1 +1 @@
1
- import{e as a}from"../chunk-UVJF4QMH.mjs";import"../chunk-2I2NKDFN.mjs";import"../chunk-V7DKESTM.mjs";import"../chunk-RRAIFS3D.mjs";import"../chunk-377WQNCB.mjs";import"../chunk-HA5XD5KC.mjs";import"../chunk-V2J3R5IU.mjs";import"../chunk-2ML63TYF.mjs";export{a as Seq};
1
+ import{e as a}from"../chunk-4JXKOGY4.mjs";import"../chunk-2I2NKDFN.mjs";import"../chunk-V7DKESTM.mjs";import"../chunk-RRAIFS3D.mjs";import"../chunk-377WQNCB.mjs";import"../chunk-HA5XD5KC.mjs";import"../chunk-V2J3R5IU.mjs";import"../chunk-2ML63TYF.mjs";export{a as Seq};
@@ -1,4 +1,4 @@
1
- export { L as List } from '../index-DUzgmWat.mjs';
1
+ export { L as List } from '../index-BClvlOd9.mjs';
2
2
  import '../functor/index.mjs';
3
3
  import '../identity/Identity.mjs';
4
4
  import '../tuple/Tuple.mjs';
@@ -1,4 +1,4 @@
1
- export { L as List } from '../index-C_T4wCVA.js';
1
+ export { L as List } from '../index-CCr9-bb6.js';
2
2
  import '../functor/index.js';
3
3
  import '../identity/Identity.js';
4
4
  import '../tuple/Tuple.js';
package/dist/list/List.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkENNA2JEUjs = require('../chunk-ENNA2JEU.js');require('../chunk-OXLZ6UIZ.js');require('../chunk-5O6YELD3.js');require('../chunk-BNNK42JC.js');require('../chunk-5VTXJIR3.js');require('../chunk-3VJERXBP.js');require('../chunk-XORABVON.js');require('../chunk-K3EKBPQE.js');exports.List = _chunkENNA2JEUjs.g;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkYWNQJQONjs = require('../chunk-YWNQJQON.js');require('../chunk-OXLZ6UIZ.js');require('../chunk-5O6YELD3.js');require('../chunk-BNNK42JC.js');require('../chunk-5VTXJIR3.js');require('../chunk-3VJERXBP.js');require('../chunk-XORABVON.js');require('../chunk-K3EKBPQE.js');exports.List = _chunkYWNQJQONjs.g;
@@ -1 +1 @@
1
- import{g as a}from"../chunk-UVJF4QMH.mjs";import"../chunk-2I2NKDFN.mjs";import"../chunk-V7DKESTM.mjs";import"../chunk-RRAIFS3D.mjs";import"../chunk-377WQNCB.mjs";import"../chunk-HA5XD5KC.mjs";import"../chunk-V2J3R5IU.mjs";import"../chunk-2ML63TYF.mjs";export{a as List};
1
+ import{g as a}from"../chunk-4JXKOGY4.mjs";import"../chunk-2I2NKDFN.mjs";import"../chunk-V7DKESTM.mjs";import"../chunk-RRAIFS3D.mjs";import"../chunk-377WQNCB.mjs";import"../chunk-HA5XD5KC.mjs";import"../chunk-V2J3R5IU.mjs";import"../chunk-2ML63TYF.mjs";export{a as List};
@@ -1,4 +1,4 @@
1
- export { M as Map } from '../index-DUzgmWat.mjs';
1
+ export { M as Map } from '../index-BClvlOd9.mjs';
2
2
  import '../tuple/Tuple.mjs';
3
3
  import '../functor/index.mjs';
4
4
  import '../identity/Identity.mjs';
package/dist/map/Map.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { M as Map } from '../index-C_T4wCVA.js';
1
+ export { M as Map } from '../index-CCr9-bb6.js';
2
2
  import '../tuple/Tuple.js';
3
3
  import '../functor/index.js';
4
4
  import '../identity/Identity.js';
package/dist/map/Map.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkENNA2JEUjs = require('../chunk-ENNA2JEU.js');require('../chunk-OXLZ6UIZ.js');require('../chunk-5O6YELD3.js');require('../chunk-BNNK42JC.js');require('../chunk-5VTXJIR3.js');require('../chunk-3VJERXBP.js');require('../chunk-XORABVON.js');require('../chunk-K3EKBPQE.js');exports.Map = _chunkENNA2JEUjs.m;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkYWNQJQONjs = require('../chunk-YWNQJQON.js');require('../chunk-OXLZ6UIZ.js');require('../chunk-5O6YELD3.js');require('../chunk-BNNK42JC.js');require('../chunk-5VTXJIR3.js');require('../chunk-3VJERXBP.js');require('../chunk-XORABVON.js');require('../chunk-K3EKBPQE.js');exports.Map = _chunkYWNQJQONjs.n;
package/dist/map/Map.mjs CHANGED
@@ -1 +1 @@
1
- import{m as a}from"../chunk-UVJF4QMH.mjs";import"../chunk-2I2NKDFN.mjs";import"../chunk-V7DKESTM.mjs";import"../chunk-RRAIFS3D.mjs";import"../chunk-377WQNCB.mjs";import"../chunk-HA5XD5KC.mjs";import"../chunk-V2J3R5IU.mjs";import"../chunk-2ML63TYF.mjs";export{a as Map};
1
+ import{n as a}from"../chunk-4JXKOGY4.mjs";import"../chunk-2I2NKDFN.mjs";import"../chunk-V7DKESTM.mjs";import"../chunk-RRAIFS3D.mjs";import"../chunk-377WQNCB.mjs";import"../chunk-HA5XD5KC.mjs";import"../chunk-V2J3R5IU.mjs";import"../chunk-2ML63TYF.mjs";export{a as Map};
@@ -1,5 +1,5 @@
1
1
  import '../functor/index.mjs';
2
- export { N as None, O as Option, S as Some } from '../index-DUzgmWat.mjs';
2
+ export { N as None, O as Option, S as Some } from '../index-BClvlOd9.mjs';
3
3
  import '../typeable/Typeable.mjs';
4
4
  import '../identity/Identity.mjs';
5
5
  import '../tuple/Tuple.mjs';
@@ -1,5 +1,5 @@
1
1
  import '../functor/index.js';
2
- export { N as None, O as Option, S as Some } from '../index-C_T4wCVA.js';
2
+ export { N as None, O as Option, S as Some } from '../index-CCr9-bb6.js';
3
3
  import '../typeable/Typeable.js';
4
4
  import '../identity/Identity.js';
5
5
  import '../tuple/Tuple.js';
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkENNA2JEUjs = require('../chunk-ENNA2JEU.js');require('../chunk-OXLZ6UIZ.js');require('../chunk-5O6YELD3.js');require('../chunk-BNNK42JC.js');require('../chunk-5VTXJIR3.js');require('../chunk-3VJERXBP.js');require('../chunk-XORABVON.js');require('../chunk-K3EKBPQE.js');exports.None = _chunkENNA2JEUjs.b; exports.Option = _chunkENNA2JEUjs.c; exports.Some = _chunkENNA2JEUjs.a;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkYWNQJQONjs = require('../chunk-YWNQJQON.js');require('../chunk-OXLZ6UIZ.js');require('../chunk-5O6YELD3.js');require('../chunk-BNNK42JC.js');require('../chunk-5VTXJIR3.js');require('../chunk-3VJERXBP.js');require('../chunk-XORABVON.js');require('../chunk-K3EKBPQE.js');exports.None = _chunkYWNQJQONjs.b; exports.Option = _chunkYWNQJQONjs.c; exports.Some = _chunkYWNQJQONjs.a;
@@ -1 +1 @@
1
- import{a,b,c}from"../chunk-UVJF4QMH.mjs";import"../chunk-2I2NKDFN.mjs";import"../chunk-V7DKESTM.mjs";import"../chunk-RRAIFS3D.mjs";import"../chunk-377WQNCB.mjs";import"../chunk-HA5XD5KC.mjs";import"../chunk-V2J3R5IU.mjs";import"../chunk-2ML63TYF.mjs";export{b as None,c as Option,a as Some};
1
+ import{a,b,c}from"../chunk-4JXKOGY4.mjs";import"../chunk-2I2NKDFN.mjs";import"../chunk-V7DKESTM.mjs";import"../chunk-RRAIFS3D.mjs";import"../chunk-377WQNCB.mjs";import"../chunk-HA5XD5KC.mjs";import"../chunk-V2J3R5IU.mjs";import"../chunk-2ML63TYF.mjs";export{b as None,c as Option,a as Some};
@@ -1,4 +1,4 @@
1
- export { b as Set } from '../index-DUzgmWat.mjs';
1
+ export { b as Set } from '../index-BClvlOd9.mjs';
2
2
  import '../functor/index.mjs';
3
3
  import '../identity/Identity.mjs';
4
4
  import '../tuple/Tuple.mjs';
package/dist/set/Set.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { b as Set } from '../index-C_T4wCVA.js';
1
+ export { b as Set } from '../index-CCr9-bb6.js';
2
2
  import '../functor/index.js';
3
3
  import '../identity/Identity.js';
4
4
  import '../tuple/Tuple.js';
package/dist/set/Set.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkENNA2JEUjs = require('../chunk-ENNA2JEU.js');require('../chunk-OXLZ6UIZ.js');require('../chunk-5O6YELD3.js');require('../chunk-BNNK42JC.js');require('../chunk-5VTXJIR3.js');require('../chunk-3VJERXBP.js');require('../chunk-XORABVON.js');require('../chunk-K3EKBPQE.js');exports.Set = _chunkENNA2JEUjs.f;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkYWNQJQONjs = require('../chunk-YWNQJQON.js');require('../chunk-OXLZ6UIZ.js');require('../chunk-5O6YELD3.js');require('../chunk-BNNK42JC.js');require('../chunk-5VTXJIR3.js');require('../chunk-3VJERXBP.js');require('../chunk-XORABVON.js');require('../chunk-K3EKBPQE.js');exports.Set = _chunkYWNQJQONjs.f;
package/dist/set/Set.mjs CHANGED
@@ -1 +1 @@
1
- import{f as a}from"../chunk-UVJF4QMH.mjs";import"../chunk-2I2NKDFN.mjs";import"../chunk-V7DKESTM.mjs";import"../chunk-RRAIFS3D.mjs";import"../chunk-377WQNCB.mjs";import"../chunk-HA5XD5KC.mjs";import"../chunk-V2J3R5IU.mjs";import"../chunk-2ML63TYF.mjs";export{a as Set};
1
+ import{f as a}from"../chunk-4JXKOGY4.mjs";import"../chunk-2I2NKDFN.mjs";import"../chunk-V7DKESTM.mjs";import"../chunk-RRAIFS3D.mjs";import"../chunk-377WQNCB.mjs";import"../chunk-HA5XD5KC.mjs";import"../chunk-V2J3R5IU.mjs";import"../chunk-2ML63TYF.mjs";export{a as Set};
@@ -1,4 +1,4 @@
1
- export { T as Try } from '../index-DUzgmWat.mjs';
1
+ export { T as Try } from '../index-BClvlOd9.mjs';
2
2
  import '../typeable/Typeable.mjs';
3
3
  import '../functor/index.mjs';
4
4
  import '../identity/Identity.mjs';
package/dist/try/Try.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { T as Try } from '../index-C_T4wCVA.js';
1
+ export { T as Try } from '../index-CCr9-bb6.js';
2
2
  import '../typeable/Typeable.js';
3
3
  import '../functor/index.js';
4
4
  import '../identity/Identity.js';
package/dist/try/Try.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkENNA2JEUjs = require('../chunk-ENNA2JEU.js');require('../chunk-OXLZ6UIZ.js');require('../chunk-5O6YELD3.js');require('../chunk-BNNK42JC.js');require('../chunk-5VTXJIR3.js');require('../chunk-3VJERXBP.js');require('../chunk-XORABVON.js');require('../chunk-K3EKBPQE.js');exports.Try = _chunkENNA2JEUjs.n;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkYWNQJQONjs = require('../chunk-YWNQJQON.js');require('../chunk-OXLZ6UIZ.js');require('../chunk-5O6YELD3.js');require('../chunk-BNNK42JC.js');require('../chunk-5VTXJIR3.js');require('../chunk-3VJERXBP.js');require('../chunk-XORABVON.js');require('../chunk-K3EKBPQE.js');exports.Try = _chunkYWNQJQONjs.o;
package/dist/try/Try.mjs CHANGED
@@ -1 +1 @@
1
- import{n as a}from"../chunk-UVJF4QMH.mjs";import"../chunk-2I2NKDFN.mjs";import"../chunk-V7DKESTM.mjs";import"../chunk-RRAIFS3D.mjs";import"../chunk-377WQNCB.mjs";import"../chunk-HA5XD5KC.mjs";import"../chunk-V2J3R5IU.mjs";import"../chunk-2ML63TYF.mjs";export{a as Try};
1
+ import{o as a}from"../chunk-4JXKOGY4.mjs";import"../chunk-2I2NKDFN.mjs";import"../chunk-V7DKESTM.mjs";import"../chunk-RRAIFS3D.mjs";import"../chunk-377WQNCB.mjs";import"../chunk-HA5XD5KC.mjs";import"../chunk-V2J3R5IU.mjs";import"../chunk-2ML63TYF.mjs";export{a as Try};
@@ -1,4 +1,4 @@
1
- import { E as Either } from '../index-DUzgmWat.mjs';
1
+ import { E as Either } from '../index-BClvlOd9.mjs';
2
2
  import { ParseError } from '../error/ParseError.mjs';
3
3
  import '../functor/index.mjs';
4
4
  import '../identity/Identity.mjs';
@@ -1,4 +1,4 @@
1
- import { E as Either } from '../index-C_T4wCVA.js';
1
+ import { E as Either } from '../index-CCr9-bb6.js';
2
2
  import { ParseError } from '../error/ParseError.js';
3
3
  import '../functor/index.js';
4
4
  import '../identity/Identity.js';
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkE6RS47F7js = require('../chunk-E6RS47F7.js');var _chunkENNA2JEUjs = require('../chunk-ENNA2JEU.js');require('../chunk-OXLZ6UIZ.js');require('../chunk-5O6YELD3.js');require('../chunk-BNNK42JC.js');require('../chunk-5VTXJIR3.js');require('../chunk-3VJERXBP.js');require('../chunk-XORABVON.js');require('../chunk-K3EKBPQE.js');var a=o=>{let r=parseInt(o,10);return isNaN(r)?_chunkENNA2JEUjs.i.call(void 0, _chunkE6RS47F7js.a.call(void 0, `${r}`)):_chunkENNA2JEUjs.h.call(void 0, r)};exports.parseNumber = a;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkE6RS47F7js = require('../chunk-E6RS47F7.js');var _chunkYWNQJQONjs = require('../chunk-YWNQJQON.js');require('../chunk-OXLZ6UIZ.js');require('../chunk-5O6YELD3.js');require('../chunk-BNNK42JC.js');require('../chunk-5VTXJIR3.js');require('../chunk-3VJERXBP.js');require('../chunk-XORABVON.js');require('../chunk-K3EKBPQE.js');var a=o=>{let r=parseInt(o,10);return isNaN(r)?_chunkYWNQJQONjs.i.call(void 0, _chunkE6RS47F7js.a.call(void 0, `${r}`)):_chunkYWNQJQONjs.h.call(void 0, r)};exports.parseNumber = a;
@@ -1 +1 @@
1
- import{a as s}from"../chunk-VK5GL6NM.mjs";import{h as e,i as t}from"../chunk-UVJF4QMH.mjs";import"../chunk-2I2NKDFN.mjs";import"../chunk-V7DKESTM.mjs";import"../chunk-RRAIFS3D.mjs";import"../chunk-377WQNCB.mjs";import"../chunk-HA5XD5KC.mjs";import"../chunk-V2J3R5IU.mjs";import"../chunk-2ML63TYF.mjs";var a=o=>{let r=parseInt(o,10);return isNaN(r)?t(s(`${r}`)):e(r)};export{a as parseNumber};
1
+ import{a as s}from"../chunk-VK5GL6NM.mjs";import{h as e,i as t}from"../chunk-4JXKOGY4.mjs";import"../chunk-2I2NKDFN.mjs";import"../chunk-V7DKESTM.mjs";import"../chunk-RRAIFS3D.mjs";import"../chunk-377WQNCB.mjs";import"../chunk-HA5XD5KC.mjs";import"../chunk-V2J3R5IU.mjs";import"../chunk-2ML63TYF.mjs";var a=o=>{let r=parseInt(o,10);return isNaN(r)?t(s(`${r}`)):e(r)};export{a as parseNumber};
@@ -7,8 +7,11 @@ export type Either<L extends Type, R extends Type> = {
7
7
  value: L | R;
8
8
  isLeft: () => boolean;
9
9
  isRight: () => boolean;
10
+ getOrElse: (value: R) => R;
10
11
  map: <U extends Type>(f: (value: R) => U) => Either<L, U>;
12
+ mapAsync: <U extends Type>(f: (value: R) => Promise<U>) => Promise<Either<L, U>>;
11
13
  flatMap: <U extends Type>(f: (value: R) => Either<L, U>) => Either<L, U>;
14
+ flatMapAsync: <U extends Type>(f: (value: R) => Promise<Either<L, U>>) => Promise<Either<L, U>>;
12
15
  toOption: () => Option<R>;
13
16
  toList: () => List<R>;
14
17
  valueOf: () => {
@@ -26,3 +29,4 @@ export declare const isLeft: <L, R>(either: Either<L, R>) => either is Either<L,
26
29
  value: L;
27
30
  };
28
31
  export declare const tryCatch: <L, R>(f: () => R, onError: (error: unknown) => L) => Either<L, R>;
32
+ export declare const tryCatchAsync: <L, R>(f: () => Promise<R>, onError: (error: unknown) => L) => Promise<Either<L, R>>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "functype",
3
- "version": "0.8.7",
3
+ "version": "0.8.8",
4
4
  "description": "A smallish functional library for TypeScript",
5
5
  "author": "jordan.burke@gmail.com",
6
6
  "license": "MIT",
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunkOXLZ6UIZjs = require('./chunk-OXLZ6UIZ.js');var _chunkBNNK42JCjs = require('./chunk-BNNK42JC.js');var _chunk5VTXJIR3js = require('./chunk-5VTXJIR3.js');var _chunk3VJERXBPjs = require('./chunk-3VJERXBP.js');var m=e=>{let t=_chunkBNNK42JCjs.a.call(void 0, e)?e:e instanceof Object&&"toArray"in e?e.toArray():[],r=Array.from(t);return{[Symbol.iterator]:()=>r[Symbol.iterator](),get length(){return r.length},map:o=>m(r.map(o)),flatMap:o=>m(r.flatMap(i=>o(i).toArray())),forEach:o=>r.forEach(o),count:o=>r.filter(o).length,exists:o=>r.some(o),filter:o=>m(r.filter(o)),filterNot:o=>m(r.filter(i=>!o(i))),find:o=>f(r.find(o)),get head(){return r[0]},get headOption(){return r.length>0?f(r[0]):T()},get isEmpty(){return r.length===0},get size(){return r.length},toArray:()=>[...r],reduce:o=>r.reduce(o),reduceRight:o=>r.reduceRight(o),foldLeft:o=>i=>r.reduce(i,o),foldRight:o=>i=>r.reduceRight((a,p)=>i(p,a),o),valueOf:()=>({values:r})}},s= exports.e =e=>m(e);var d=e=>{let t=_chunkBNNK42JCjs.a.call(void 0, e)?new (0, _chunk3VJERXBPjs.a)(e):new (0, _chunk3VJERXBPjs.a)(_nullishCoalesce(_optionalChain([e, 'optionalAccess', _2 => _2.toArray, 'call', _3 => _3()]), () => ([]))),r=s(t),o={...r,add:i=>d([...t,i]),remove:i=>{let a=new (0, _chunk3VJERXBPjs.a)(t);return a.delete(i),d(a)},contains:i=>t.has(i),has:i=>t.has(i),map:i=>d(r.map(i)),flatMap:i=>d(r.flatMap(i)),toList:()=>A(t),toSet:()=>o,toString:()=>`Set(${Array.from(t).toString()})`};return o},S= exports.f =e=>d(e);var c=e=>{function t(a){return a!=null&&typeof a[Symbol.iterator]=="function"}let r=Array.isArray(e)?e:t(e)?Array.from(e):[],o=s(r),i={...o,length:r.length,map:a=>c(r.map(a)),flatMap:a=>c(o.flatMap(a)),remove:a=>{let p=r.indexOf(a);return i.removeAt(p)},contains:a=>r.includes(a),add:a=>c([...r,a]),removeAt:a=>a<0||a>=r.length?i:c([...r.slice(0,a),...r.slice(a+1)]),get:a=>f(r[a]),concat:a=>c([...r,...a.toArray()]),toList:()=>i,toSet:()=>S(r),toString:()=>`List(${r.toString()})`};return new Proxy(i,{get(a,p){return typeof p=="symbol"||isNaN(Number(p))?a[p]:a.get(Number(p))}})},A= exports.g =e=>c(e);var U=e=>({_tag:"Right",value:e,isLeft:()=>!1,isRight:()=>!0,map:t=>U(t(e)),flatMap:t=>t(e),toOption:()=>g(e),toList:()=>A([e]),valueOf:()=>({_tag:"Right",value:e}),toString:()=>`Right(${JSON.stringify(e)})`}),E=e=>({_tag:"Left",value:e,isLeft:()=>!0,isRight:()=>!1,map:t=>E(e),flatMap:t=>E(e),toOption:()=>T(),toList:()=>A(),valueOf:()=>({_tag:"Left",value:e}),toString:()=>`Left(${JSON.stringify(e)})`}),b= exports.h =e=>U(e),y= exports.i =e=>E(e),Ae= exports.j =e=>e.isRight(),ue= exports.k =e=>e.isLeft(),ce= exports.l =(e,t)=>{try{return b(e())}catch(r){return y(t(r))}};var u=e=>{let t={values:new (0, _chunk5VTXJIR3js.a)(e)},r=()=>Array.from(t.values.entries()).map(([n,l])=>_chunkOXLZ6UIZjs.a.call(void 0, [n,l])),o=n=>u(new (0, _chunk5VTXJIR3js.a)(t.values).set(n.toArray()[0],n.toArray()[1]).entries()),i=n=>{let l=new (0, _chunk5VTXJIR3js.a)(t.values);return l.delete(n)?u(l.entries()):u(t.values.entries())},a=n=>t.values.get(n[0])===n[1],p=()=>t.values.size,x=n=>u(Array.from(t.values.entries()).map(([l,q])=>[l,n(q)])),V=n=>{let l=u(t.values.entries()).toList();return u(l.flatMap(n).toArray())},K=n=>s(r()).reduce(n),I=n=>s(r()).reduceRight(n),M=n=>l=>s(r()).foldLeft(n)(l),N=n=>l=>s(r()).foldRight(n)(l),w=n=>f(t.values.get(n)),z=(n,l)=>f(t.values.get(n)).getOrElse(l),F=()=>t.values.size===0;return{add:o,remove:i,contains:a,get size(){return p()},map:x,flatMap:V,reduce:K,reduceRight:I,foldLeft:M,foldRight:N,get:w,getOrElse:z,get isEmpty(){return F()},orElse:(n,l)=>f(t.values.get(n)).orElse(l),toList:()=>A(r()),toSet:()=>S(r()),toString:()=>`Map(${r().toString()})`}},Se= exports.m =e=>u(e);var v=e=>({_tag:"Success",value:e,error:void 0,isSuccess:()=>!0,isFailure:()=>!1,get:()=>e,getOrElse:t=>e,orElse:t=>v(e),orThrow:t=>e,toEither:()=>b(e),map:t=>C(()=>t(e)),flatMap:t=>t(e),valueOf:()=>({_tag:"Success",value:e}),toString:()=>`Success(${JSON.stringify(e)})`}),_=e=>({_tag:"Failure",value:void 0,error:e,isSuccess:()=>!1,isFailure:()=>!0,get:()=>{throw e},getOrElse:t=>t,orElse:t=>t,orThrow:t=>{throw t},toEither:()=>y(e),map:t=>_(e),flatMap:t=>_(e),valueOf:()=>({_tag:"Failure",error:e}),toString:()=>`Failure(${e.message})`}),C= exports.n =e=>{try{return v(e())}catch(t){return _(t instanceof Error?t:new Error(String(t)))}};var g=e=>({_tag:"Some",value:e,isEmpty:!1,get:()=>e,getOrElse:()=>e,orElse:()=>g(e),map:t=>g(t(e)),flatMap:t=>t(e),reduce:t=>t(void 0,e),reduceRight:t=>t(void 0,e),foldLeft:t=>r=>r(t,e),foldRight:t=>r=>r(e,t),toList:()=>s([e]),contains:t=>t===e,size:1,toEither:t=>b(e),toString:()=>`Some(${JSON.stringify(e)})`,valueOf:()=>({_tag:"Some",value:e})}),R={_tag:"None",value:void 0,isEmpty:!0,get:()=>{throw new Error("Cannot call get() on None")},getOrElse:e=>e,orElse:e=>e,map:()=>R,flatMap:()=>R,reduce:()=>{},reduceRight:()=>{},foldLeft:e=>()=>e,foldRight:e=>()=>e,toList:()=>s([]),contains:()=>!1,size:0,toEither:e=>y(e),toString:()=>"None",valueOf:()=>({_tag:"None"})},T= exports.b =()=>R,f= exports.c =e=>e!=null?g(e):T();exports.a = g; exports.b = T; exports.c = f; exports.d = m; exports.e = s; exports.f = S; exports.g = A; exports.h = b; exports.i = y; exports.j = Ae; exports.k = ue; exports.l = ce; exports.m = Se; exports.n = C;
@@ -1 +0,0 @@
1
- import{a as O}from"./chunk-2I2NKDFN.mjs";import{a as B}from"./chunk-RRAIFS3D.mjs";import{a as h}from"./chunk-377WQNCB.mjs";import{a as L}from"./chunk-HA5XD5KC.mjs";var m=e=>{let t=B(e)?e:e instanceof Object&&"toArray"in e?e.toArray():[],r=Array.from(t);return{[Symbol.iterator]:()=>r[Symbol.iterator](),get length(){return r.length},map:o=>m(r.map(o)),flatMap:o=>m(r.flatMap(i=>o(i).toArray())),forEach:o=>r.forEach(o),count:o=>r.filter(o).length,exists:o=>r.some(o),filter:o=>m(r.filter(o)),filterNot:o=>m(r.filter(i=>!o(i))),find:o=>f(r.find(o)),get head(){return r[0]},get headOption(){return r.length>0?f(r[0]):T()},get isEmpty(){return r.length===0},get size(){return r.length},toArray:()=>[...r],reduce:o=>r.reduce(o),reduceRight:o=>r.reduceRight(o),foldLeft:o=>i=>r.reduce(i,o),foldRight:o=>i=>r.reduceRight((a,p)=>i(p,a),o),valueOf:()=>({values:r})}},s=e=>m(e);var d=e=>{let t=B(e)?new L(e):new L(e?.toArray()??[]),r=s(t),o={...r,add:i=>d([...t,i]),remove:i=>{let a=new L(t);return a.delete(i),d(a)},contains:i=>t.has(i),has:i=>t.has(i),map:i=>d(r.map(i)),flatMap:i=>d(r.flatMap(i)),toList:()=>A(t),toSet:()=>o,toString:()=>`Set(${Array.from(t).toString()})`};return o},S=e=>d(e);var c=e=>{function t(a){return a!=null&&typeof a[Symbol.iterator]=="function"}let r=Array.isArray(e)?e:t(e)?Array.from(e):[],o=s(r),i={...o,length:r.length,map:a=>c(r.map(a)),flatMap:a=>c(o.flatMap(a)),remove:a=>{let p=r.indexOf(a);return i.removeAt(p)},contains:a=>r.includes(a),add:a=>c([...r,a]),removeAt:a=>a<0||a>=r.length?i:c([...r.slice(0,a),...r.slice(a+1)]),get:a=>f(r[a]),concat:a=>c([...r,...a.toArray()]),toList:()=>i,toSet:()=>S(r),toString:()=>`List(${r.toString()})`};return new Proxy(i,{get(a,p){return typeof p=="symbol"||isNaN(Number(p))?a[p]:a.get(Number(p))}})},A=e=>c(e);var U=e=>({_tag:"Right",value:e,isLeft:()=>!1,isRight:()=>!0,map:t=>U(t(e)),flatMap:t=>t(e),toOption:()=>g(e),toList:()=>A([e]),valueOf:()=>({_tag:"Right",value:e}),toString:()=>`Right(${JSON.stringify(e)})`}),E=e=>({_tag:"Left",value:e,isLeft:()=>!0,isRight:()=>!1,map:t=>E(e),flatMap:t=>E(e),toOption:()=>T(),toList:()=>A(),valueOf:()=>({_tag:"Left",value:e}),toString:()=>`Left(${JSON.stringify(e)})`}),b=e=>U(e),y=e=>E(e),Ae=e=>e.isRight(),ue=e=>e.isLeft(),ce=(e,t)=>{try{return b(e())}catch(r){return y(t(r))}};var u=e=>{let t={values:new h(e)},r=()=>Array.from(t.values.entries()).map(([n,l])=>O([n,l])),o=n=>u(new h(t.values).set(n.toArray()[0],n.toArray()[1]).entries()),i=n=>{let l=new h(t.values);return l.delete(n)?u(l.entries()):u(t.values.entries())},a=n=>t.values.get(n[0])===n[1],p=()=>t.values.size,x=n=>u(Array.from(t.values.entries()).map(([l,q])=>[l,n(q)])),V=n=>{let l=u(t.values.entries()).toList();return u(l.flatMap(n).toArray())},K=n=>s(r()).reduce(n),I=n=>s(r()).reduceRight(n),M=n=>l=>s(r()).foldLeft(n)(l),N=n=>l=>s(r()).foldRight(n)(l),w=n=>f(t.values.get(n)),z=(n,l)=>f(t.values.get(n)).getOrElse(l),F=()=>t.values.size===0;return{add:o,remove:i,contains:a,get size(){return p()},map:x,flatMap:V,reduce:K,reduceRight:I,foldLeft:M,foldRight:N,get:w,getOrElse:z,get isEmpty(){return F()},orElse:(n,l)=>f(t.values.get(n)).orElse(l),toList:()=>A(r()),toSet:()=>S(r()),toString:()=>`Map(${r().toString()})`}},Se=e=>u(e);var v=e=>({_tag:"Success",value:e,error:void 0,isSuccess:()=>!0,isFailure:()=>!1,get:()=>e,getOrElse:t=>e,orElse:t=>v(e),orThrow:t=>e,toEither:()=>b(e),map:t=>C(()=>t(e)),flatMap:t=>t(e),valueOf:()=>({_tag:"Success",value:e}),toString:()=>`Success(${JSON.stringify(e)})`}),_=e=>({_tag:"Failure",value:void 0,error:e,isSuccess:()=>!1,isFailure:()=>!0,get:()=>{throw e},getOrElse:t=>t,orElse:t=>t,orThrow:t=>{throw t},toEither:()=>y(e),map:t=>_(e),flatMap:t=>_(e),valueOf:()=>({_tag:"Failure",error:e}),toString:()=>`Failure(${e.message})`}),C=e=>{try{return v(e())}catch(t){return _(t instanceof Error?t:new Error(String(t)))}};var g=e=>({_tag:"Some",value:e,isEmpty:!1,get:()=>e,getOrElse:()=>e,orElse:()=>g(e),map:t=>g(t(e)),flatMap:t=>t(e),reduce:t=>t(void 0,e),reduceRight:t=>t(void 0,e),foldLeft:t=>r=>r(t,e),foldRight:t=>r=>r(e,t),toList:()=>s([e]),contains:t=>t===e,size:1,toEither:t=>b(e),toString:()=>`Some(${JSON.stringify(e)})`,valueOf:()=>({_tag:"Some",value:e})}),R={_tag:"None",value:void 0,isEmpty:!0,get:()=>{throw new Error("Cannot call get() on None")},getOrElse:e=>e,orElse:e=>e,map:()=>R,flatMap:()=>R,reduce:()=>{},reduceRight:()=>{},foldLeft:e=>()=>e,foldRight:e=>()=>e,toList:()=>s([]),contains:()=>!1,size:0,toEither:e=>y(e),toString:()=>"None",valueOf:()=>({_tag:"None"})},T=()=>R,f=e=>e!=null?g(e):T();export{g as a,T as b,f as c,m as d,s as e,S as f,A as g,b as h,y as i,Ae as j,ue as k,ce as l,Se as m,C as n};