functype 0.8.38 → 0.8.40

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 (70) hide show
  1. package/README.md +43 -43
  2. package/dist/chunk-FKIJ6NNF.js +1 -0
  3. package/dist/chunk-ISN32ITK.mjs +1 -0
  4. package/dist/collections/index.d.mts +1 -1
  5. package/dist/collections/index.d.ts +1 -1
  6. package/dist/core/task/Task.d.mts +1 -1
  7. package/dist/core/task/Task.d.ts +1 -1
  8. package/dist/core/task/Task.js +1 -1
  9. package/dist/core/task/Task.mjs +1 -1
  10. package/dist/either/Either.d.mts +1 -1
  11. package/dist/either/Either.d.ts +1 -1
  12. package/dist/either/Either.js +1 -1
  13. package/dist/either/Either.mjs +1 -1
  14. package/dist/{index-DqYpT1Od.d.ts → index-D4Mn3DW4.d.ts} +11 -2
  15. package/dist/{index-B5xiGKli.d.mts → index-DBN7nT5K.d.mts} +11 -2
  16. package/dist/index.d.mts +1 -1
  17. package/dist/index.d.ts +1 -1
  18. package/dist/index.js +1 -1
  19. package/dist/index.mjs +1 -1
  20. package/dist/iterable/index.d.mts +1 -1
  21. package/dist/iterable/index.d.ts +1 -1
  22. package/dist/list/List.d.mts +1 -1
  23. package/dist/list/List.d.ts +1 -1
  24. package/dist/list/List.js +1 -1
  25. package/dist/list/List.mjs +1 -1
  26. package/dist/map/Map.d.mts +1 -1
  27. package/dist/map/Map.d.ts +1 -1
  28. package/dist/map/Map.js +1 -1
  29. package/dist/map/Map.mjs +1 -1
  30. package/dist/option/Option.d.mts +1 -1
  31. package/dist/option/Option.d.ts +1 -1
  32. package/dist/option/Option.js +1 -1
  33. package/dist/option/Option.mjs +1 -1
  34. package/dist/set/Set.d.mts +1 -1
  35. package/dist/set/Set.d.ts +1 -1
  36. package/dist/set/Set.js +1 -1
  37. package/dist/set/Set.mjs +1 -1
  38. package/dist/try/Try.d.mts +1 -1
  39. package/dist/try/Try.d.ts +1 -1
  40. package/dist/try/Try.js +1 -1
  41. package/dist/try/Try.mjs +1 -1
  42. package/dist/util/index.d.mts +1 -1
  43. package/dist/util/index.d.ts +1 -1
  44. package/dist/util/index.js +1 -1
  45. package/dist/util/index.mjs +1 -1
  46. package/lib/TaskPromise.d.ts +3 -0
  47. package/lib/collections/index.d.ts +8 -0
  48. package/lib/either/Either.d.ts +52 -0
  49. package/lib/either/EitherT.d.ts +9 -0
  50. package/lib/error/ParseError.d.ts +6 -0
  51. package/lib/functor/index.d.ts +15 -0
  52. package/lib/identity/Identity.d.ts +4 -0
  53. package/lib/index.d.ts +21 -0
  54. package/lib/iterable/Seq.d.ts +31 -0
  55. package/lib/iterable/index.d.ts +22 -0
  56. package/lib/list/List.d.ts +26 -0
  57. package/lib/map/Map.d.ts +17 -0
  58. package/lib/map/shim.d.ts +2 -0
  59. package/lib/option/Option.d.ts +30 -0
  60. package/lib/serializable/Serializable.d.ts +15 -0
  61. package/lib/set/Set.d.ts +15 -0
  62. package/lib/set/shim.d.ts +2 -0
  63. package/lib/try/Try.d.ts +18 -0
  64. package/lib/tuple/Tuple.d.ts +9 -0
  65. package/lib/typeable/Typeable.d.ts +4 -0
  66. package/lib/util/index.d.ts +3 -0
  67. package/lib/util/isIterable.d.ts +1 -0
  68. package/package.json +9 -9
  69. package/dist/chunk-FBHTKYGN.mjs +0 -1
  70. package/dist/chunk-HTBQYXSN.js +0 -1
package/README.md CHANGED
@@ -1,43 +1,43 @@
1
- # functype
2
-
3
- A small functional library for TypeScript inspired by FP, Scala Standard Library, and ZIO
4
-
5
- ![NPM Version](https://img.shields.io/npm/v/functype?link=https%3A%2F%2Fwww.npmjs.com%2Fpackage%2Ffunctype)
6
-
7
- [![Node.js Build](https://github.com/jordanburke/functype/actions/workflows/pnpm-build.yml/badge.svg)](https://github.com/jordanburke/functype/actions/workflows/pnpm-build.yml)
8
-
9
- # Functype - A Functional Library for TypeScript
10
-
11
- Functype is a functional programming library for TypeScript, inspired by FP, Scala's standard library and ZIO. It offers a collection of utilities and abstractions to facilitate functional programming paradigms within TypeScript applications. The library is designed to provide developers with tools that promote immutability, pure functions, and composability, aligning with functional programming principles.
12
-
13
- ## Key Features
14
-
15
- - **Functional Utilities:** Functype includes a variety of functions and combinators that assist in writing functional code, such as `map`, `filter`, and `reduce` operations tailored for TypeScript.
16
-
17
- - **Type Safety:** Leveraging TypeScript's type system, Functype ensures that functional operations are type-safe, reducing runtime errors and enhancing code reliability.
18
-
19
- - **Immutability Support:** The library emphasizes immutable data structures, encouraging developers to write predictable and side-effect-free code.
20
-
21
- - **Type Orientation:** Functype encourages TypeScript developers to adopt functional programming principles through type annotations and type inference.
22
-
23
- - **Composability:** Functype provides a collection of abstractions and utilities for composing complex functional programs.
24
-
25
- ## Installation
26
-
27
- You can install `functype` using any package manager:
28
-
29
- ```bash
30
- npm install functype
31
- ```
32
-
33
- ```bash
34
- pnpm install functype
35
- ```
36
-
37
- ```bash
38
- yarn install functype
39
- ```
40
-
41
- ```bash
42
- bun install functype
43
- ```
1
+ # functype
2
+
3
+ A small functional library for TypeScript inspired by FP, Scala Standard Library, and ZIO
4
+
5
+ ![NPM Version](https://img.shields.io/npm/v/functype?link=https%3A%2F%2Fwww.npmjs.com%2Fpackage%2Ffunctype)
6
+
7
+ [![Node.js Build](https://github.com/jordanburke/functype/actions/workflows/pnpm-build.yml/badge.svg)](https://github.com/jordanburke/functype/actions/workflows/pnpm-build.yml)
8
+
9
+ # Functype - A Functional Library for TypeScript
10
+
11
+ Functype is a functional programming library for TypeScript, inspired by FP, Scala's standard library and ZIO. It offers a collection of utilities and abstractions to facilitate functional programming paradigms within TypeScript applications. The library is designed to provide developers with tools that promote immutability, pure functions, and composability, aligning with functional programming principles.
12
+
13
+ ## Key Features
14
+
15
+ - **Functional Utilities:** Functype includes a variety of functions and combinators that assist in writing functional code, such as `map`, `filter`, and `reduce` operations tailored for TypeScript.
16
+
17
+ - **Type Safety:** Leveraging TypeScript's type system, Functype ensures that functional operations are type-safe, reducing runtime errors and enhancing code reliability.
18
+
19
+ - **Immutability Support:** The library emphasizes immutable data structures, encouraging developers to write predictable and side-effect-free code.
20
+
21
+ - **Type Orientation:** Functype encourages TypeScript developers to adopt functional programming principles through type annotations and type inference.
22
+
23
+ - **Composability:** Functype provides a collection of abstractions and utilities for composing complex functional programs.
24
+
25
+ ## Installation
26
+
27
+ You can install `functype` using any package manager:
28
+
29
+ ```bash
30
+ npm install functype
31
+ ```
32
+
33
+ ```bash
34
+ pnpm install functype
35
+ ```
36
+
37
+ ```bash
38
+ yarn install functype
39
+ ```
40
+
41
+ ```bash
42
+ bun install functype
43
+ ```
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _chunkSQWNJC6Ojs = require('./chunk-SQWNJC6O.js');var _chunk2U34DUZUjs = require('./chunk-2U34DUZU.js');var _chunk5VTXJIR3js = require('./chunk-5VTXJIR3.js');var _chunk3VJERXBPjs = require('./chunk-3VJERXBP.js');var _chunkOXLZ6UIZjs = require('./chunk-OXLZ6UIZ.js');var _safestablestringify = require('safe-stable-stringify'); var _safestablestringify2 = _interopRequireDefault(_safestablestringify);var A=e=>{let t=new (0, _chunk3VJERXBPjs.a)(e),r=u(t),p={...r,add:i=>A([...t,i]),remove:i=>{let o=new (0, _chunk3VJERXBPjs.a)(t);return o.delete(i),A(o)},contains:i=>t.has(i),has:i=>t.has(i),map:i=>A(r.map(i)),flatMap:i=>A(r.flatMap(i)),toList:()=>u(t),toSet:()=>p,toString:()=>`Set(${Array.from(t).toString()})`};return p},E= exports.d =e=>A(e);var f=e=>{let t=Array.from(e||[]),r=o=>f(t.filter(o)),p=o=>y(t.find(o)),i={_tag:"List",[Symbol.iterator]:()=>t[Symbol.iterator](),get size(){return t.length},get length(){return t.length},map:o=>f(t.map(o)),flatMap:o=>f(t.flatMap(T=>Array.from(o(T)))),flatMapAsync:async o=>{let T=await Promise.all(t.map(async d=>await o(d)));return f(T.flatMap(d=>Array.from(d)))},forEach:o=>t.forEach(o),count:o=>t.filter(o).length,exists:o=>t.some(o),filter:r,filterNot:o=>f(t.filter(T=>!o(T))),find:p,get head(){return t[0]},get headOption(){return t.length>0?y(t[0]):c()},get isEmpty(){return t.length===0},toArray:()=>[...t],reduce:o=>t.reduce(o),reduceRight:o=>t.reduceRight(o),foldLeft:o=>T=>t.reduce(T,o),foldRight:o=>T=>t.reduceRight((d,g)=>T(g,d),o),remove:o=>f(t.filter(T=>T!==o)),removeAt:o=>o<0||o>=t.length?i:f([...t.slice(0,o),...t.slice(o+1)]),add:o=>f([...t,o]),get:o=>y(t[o]),concat:o=>f([...t,...o.toArray()]),drop:o=>f(t.slice(o)),dropRight:o=>f(t.slice(0,-o)),dropWhile:o=>f(t.slice(t.findIndex(T=>!o(T)))),flatten:()=>f(t.flatMap(o=>Array.isArray(o)?o:[o])),toList:()=>i,toSet:()=>E(t),toString:()=>`List(${_safestablestringify2.default.call(void 0, t)})`,toValue:()=>({_tag:"List",value:t})};return i},u= exports.e =e=>f(e);var O=e=>({_tag:"Right",value:e,isLeft:()=>!1,isRight:()=>!0,getOrElse:t=>e,getOrThrow:()=>e,map:t=>a(t(e)),mapAsync:t=>t(e).then(r=>a(r)).catch(r=>Promise.resolve(n(r))),merge:t=>t.isLeft()?n(t.value):a([e,t.value]),flatMap:t=>t(e),flatMapAsync:t=>t(e).catch(r=>n(r)),toOption:()=>m(e),toList:()=>u([e]),toString:()=>`Right(${_safestablestringify2.default.call(void 0, e)})`,[Symbol.iterator]:function*(){yield e},yield:function*(){yield e},traverse:t=>{let r=t(e);return r.isLeft()?n(r.value):a([r.value])},lazyMap:function*(t){yield a(t(e))},tap:t=>(t(e),a(e)),tapLeft:t=>a(e),mapLeft:t=>a(e),bimap:(t,r)=>a(r(e)),fold:(t,r)=>r(e),swap:()=>n(e),then:(t,r)=>Promise.resolve(e).then(t,r)}),K=e=>({_tag:"Left",value:e,isLeft:()=>!0,isRight:()=>!1,getOrElse:t=>t,getOrThrow:()=>{throw e},map:t=>n(e),mapAsync:t=>Promise.resolve(n(e)),merge:t=>n(e),flatMap:t=>n(e),flatMapAsync:t=>Promise.resolve(n(e)),toOption:()=>c(),toList:()=>u(),toString:()=>`Left(${_safestablestringify2.default.call(void 0, e)})`,[Symbol.iterator]:function*(){},yield:function*(){},traverse:t=>n(e),lazyMap:function*(t){yield n(e)},tap:t=>n(e),tapLeft:t=>(t(e),n(e)),mapLeft:t=>n(t(e)),bimap:(t,r)=>n(t(e)),fold:(t,r)=>t(e),swap:()=>a(e),then:(t,r)=>Promise.reject(e).then(null,r)}),a= exports.f =e=>O(e),n= exports.g =e=>K(e),ye= exports.h =e=>e.isRight(),de= exports.i =e=>e.isLeft(),Le= exports.j =(e,t)=>{try{return a(e())}catch(r){return n(t(r))}},W= exports.k =e=>O(e);console.assert(W);var D=e=>K(e);console.assert(D);var ce=async(e,t)=>{try{let r=await e();return a(r)}catch(r){return n(t(r))}},H= exports.n ={sequence:e=>{let t=[];for(let r of e){if(r.isLeft())return n(r.value);t.push(r.value)}return a(t)},traverse:(e,t)=>H.sequence(e.map(t)),fromNullable:(e,t)=>e==null?n(t):a(e),fromPredicate:(e,t,r)=>t(e)?a(e):n(r),ap:(e,t)=>e.flatMap(r=>t.map(r)),fromPromise:async(e,t)=>{try{let r=await e;return a(r)}catch(r){return n(t(r))}}};var x=(e,t)=>{let r=_chunk2U34DUZUjs.a.call(void 0, e,t);return{..._chunkSQWNJC6Ojs.a.call(void 0, "AppException"),...n(r)}},U= exports.p =e=>({..._chunkSQWNJC6Ojs.a.call(void 0, "AppResult"),...a(e)});function M(e,t=p=>p,r=()=>{}){try{return U(e())}catch(p){return x(t(p))}finally{r()}}M.success=e=>U(e);M.fail=e=>x(e);async function k(e,t=p=>p,r=async()=>{}){try{let p=await e();return U(p)}catch(p){let i=await t(p);return x(i)}finally{await r()}}k.success=e=>U(e);k.fail=e=>x(e);var L=e=>{let t={values:new (0, _chunk5VTXJIR3js.a)(e)},r=()=>Array.from(t.values.entries()).map(([s,l])=>_chunkOXLZ6UIZjs.a.call(void 0, [s,l])),p=s=>L(new (0, _chunk5VTXJIR3js.a)(t.values).set(s.toArray()[0],s.toArray()[1]).entries()),i=s=>{let l=new (0, _chunk5VTXJIR3js.a)(t.values);return l.delete(s)?L(l.entries()):L(t.values.entries())},o=s=>t.values.get(s[0])===s[1],T=()=>t.values.size,d=s=>L(Array.from(t.values.entries()).map(([l,q])=>[l,s(q)])),g=s=>{let l=L(t.values.entries()).toList();return L(l.flatMap(s).toArray())},F=s=>u(r()).reduce(s),I=s=>u(r()).reduceRight(s),N=s=>l=>u(r()).foldLeft(s)(l),z=s=>l=>u(r()).foldRight(s)(l),C=s=>y(t.values.get(s)),$=(s,l)=>y(t.values.get(s)).getOrElse(l),G=()=>t.values.size===0;return{add:p,remove:i,contains:o,get size(){return T()},map:d,flatMap:g,reduce:F,reduceRight:I,foldLeft:N,foldRight:z,get:C,getOrElse:$,get isEmpty(){return G()},orElse:(s,l)=>y(t.values.get(s)).orElse(l),toList:()=>u(r()),toSet:()=>E(r()),toString:()=>`Map(${r().toString()})`}},Ve= exports.s =e=>L(e);var _=e=>({_tag:"Success",value:e,error:void 0,isSuccess:()=>!0,isFailure:()=>!1,get:()=>e,getOrElse:t=>e,orElse:t=>_(e),orThrow:t=>e,toEither:()=>a(e),map:t=>J(()=>t(e)),flatMap:t=>t(e),toString:()=>`Success(${_safestablestringify2.default.call(void 0, e)})`}),B=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:()=>n(e),map:t=>B(e),flatMap:t=>B(e),toString:()=>`Failure(${_safestablestringify2.default.call(void 0, e)}))`}),J= exports.t =e=>{try{return _(e())}catch(t){return B(t instanceof Error?t:new Error(String(t)))}};var m=e=>({_tag:"Some",value:e,isEmpty:!1,get:()=>e,getOrElse:()=>e,getOrThrow:()=>e,orElse:()=>m(e),orNull:()=>e,map:t=>m(t(e)),filter(t){return t(e)?m(e):R},fold:(t,r)=>r(e),flatMap:t=>t(e),flatMapAsync:async t=>await 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:()=>u([e]),contains:t=>t===e,size:1,toEither:t=>a(e),toString:()=>`Some(${_safestablestringify2.default.call(void 0, e)})`,toValue:()=>({_tag:"Some",value:e})}),R={_tag:"None",value:void 0,isEmpty:!0,get:()=>{throw new Error("Cannot call get() on None")},getOrElse:e=>e,getOrThrow(e){throw e},orElse:e=>e,orNull:()=>null,map:e=>R,filter(e){return R},flatMap:e=>R,flatMapAsync:async e=>R,reduce:()=>{},reduceRight:()=>{},fold:(e,t)=>e(),foldLeft:e=>()=>e,foldRight:e=>()=>e,toList:()=>u([]),contains:()=>!1,size:0,toEither:e=>n(e),toString:()=>"None",toValue:()=>({_tag:"None",value:void 0})},c= exports.b =()=>R,y= exports.c =e=>e!=null?m(e):c();y.from=e=>y(e);y.none=()=>c();exports.a = m; exports.b = c; exports.c = y; exports.d = E; exports.e = u; exports.f = a; exports.g = n; exports.h = ye; exports.i = de; exports.j = Le; exports.k = W; exports.l = D; exports.m = ce; exports.n = H; exports.o = x; exports.p = U; exports.q = M; exports.r = k; exports.s = Ve; exports.t = J;
@@ -0,0 +1 @@
1
+ import{a as b}from"./chunk-JF5YGNCO.mjs";import{a as S}from"./chunk-HD6YYUHO.mjs";import{a as h}from"./chunk-377WQNCB.mjs";import{a as v}from"./chunk-HA5XD5KC.mjs";import{a as V}from"./chunk-2I2NKDFN.mjs";import Q from"safe-stable-stringify";import w from"safe-stable-stringify";import j from"safe-stable-stringify";var A=e=>{let t=new v(e),r=u(t),p={...r,add:i=>A([...t,i]),remove:i=>{let o=new v(t);return o.delete(i),A(o)},contains:i=>t.has(i),has:i=>t.has(i),map:i=>A(r.map(i)),flatMap:i=>A(r.flatMap(i)),toList:()=>u(t),toSet:()=>p,toString:()=>`Set(${Array.from(t).toString()})`};return p},E=e=>A(e);var f=e=>{let t=Array.from(e||[]),r=o=>f(t.filter(o)),p=o=>y(t.find(o)),i={_tag:"List",[Symbol.iterator]:()=>t[Symbol.iterator](),get size(){return t.length},get length(){return t.length},map:o=>f(t.map(o)),flatMap:o=>f(t.flatMap(T=>Array.from(o(T)))),flatMapAsync:async o=>{let T=await Promise.all(t.map(async d=>await o(d)));return f(T.flatMap(d=>Array.from(d)))},forEach:o=>t.forEach(o),count:o=>t.filter(o).length,exists:o=>t.some(o),filter:r,filterNot:o=>f(t.filter(T=>!o(T))),find:p,get head(){return t[0]},get headOption(){return t.length>0?y(t[0]):c()},get isEmpty(){return t.length===0},toArray:()=>[...t],reduce:o=>t.reduce(o),reduceRight:o=>t.reduceRight(o),foldLeft:o=>T=>t.reduce(T,o),foldRight:o=>T=>t.reduceRight((d,g)=>T(g,d),o),remove:o=>f(t.filter(T=>T!==o)),removeAt:o=>o<0||o>=t.length?i:f([...t.slice(0,o),...t.slice(o+1)]),add:o=>f([...t,o]),get:o=>y(t[o]),concat:o=>f([...t,...o.toArray()]),drop:o=>f(t.slice(o)),dropRight:o=>f(t.slice(0,-o)),dropWhile:o=>f(t.slice(t.findIndex(T=>!o(T)))),flatten:()=>f(t.flatMap(o=>Array.isArray(o)?o:[o])),toList:()=>i,toSet:()=>E(t),toString:()=>`List(${j(t)})`,toValue:()=>({_tag:"List",value:t})};return i},u=e=>f(e);var O=e=>({_tag:"Right",value:e,isLeft:()=>!1,isRight:()=>!0,getOrElse:t=>e,getOrThrow:()=>e,map:t=>a(t(e)),mapAsync:t=>t(e).then(r=>a(r)).catch(r=>Promise.resolve(n(r))),merge:t=>t.isLeft()?n(t.value):a([e,t.value]),flatMap:t=>t(e),flatMapAsync:t=>t(e).catch(r=>n(r)),toOption:()=>m(e),toList:()=>u([e]),toString:()=>`Right(${w(e)})`,[Symbol.iterator]:function*(){yield e},yield:function*(){yield e},traverse:t=>{let r=t(e);return r.isLeft()?n(r.value):a([r.value])},lazyMap:function*(t){yield a(t(e))},tap:t=>(t(e),a(e)),tapLeft:t=>a(e),mapLeft:t=>a(e),bimap:(t,r)=>a(r(e)),fold:(t,r)=>r(e),swap:()=>n(e),then:(t,r)=>Promise.resolve(e).then(t,r)}),K=e=>({_tag:"Left",value:e,isLeft:()=>!0,isRight:()=>!1,getOrElse:t=>t,getOrThrow:()=>{throw e},map:t=>n(e),mapAsync:t=>Promise.resolve(n(e)),merge:t=>n(e),flatMap:t=>n(e),flatMapAsync:t=>Promise.resolve(n(e)),toOption:()=>c(),toList:()=>u(),toString:()=>`Left(${w(e)})`,[Symbol.iterator]:function*(){},yield:function*(){},traverse:t=>n(e),lazyMap:function*(t){yield n(e)},tap:t=>n(e),tapLeft:t=>(t(e),n(e)),mapLeft:t=>n(t(e)),bimap:(t,r)=>n(t(e)),fold:(t,r)=>t(e),swap:()=>a(e),then:(t,r)=>Promise.reject(e).then(null,r)}),a=e=>O(e),n=e=>K(e),ye=e=>e.isRight(),de=e=>e.isLeft(),Le=(e,t)=>{try{return a(e())}catch(r){return n(t(r))}},W=e=>O(e);console.assert(W);var D=e=>K(e);console.assert(D);var ce=async(e,t)=>{try{let r=await e();return a(r)}catch(r){return n(t(r))}},H={sequence:e=>{let t=[];for(let r of e){if(r.isLeft())return n(r.value);t.push(r.value)}return a(t)},traverse:(e,t)=>H.sequence(e.map(t)),fromNullable:(e,t)=>e==null?n(t):a(e),fromPredicate:(e,t,r)=>t(e)?a(e):n(r),ap:(e,t)=>e.flatMap(r=>t.map(r)),fromPromise:async(e,t)=>{try{let r=await e;return a(r)}catch(r){return n(t(r))}}};var x=(e,t)=>{let r=S(e,t);return{...b("AppException"),...n(r)}},U=e=>({...b("AppResult"),...a(e)});function M(e,t=p=>p,r=()=>{}){try{return U(e())}catch(p){return x(t(p))}finally{r()}}M.success=e=>U(e);M.fail=e=>x(e);async function k(e,t=p=>p,r=async()=>{}){try{let p=await e();return U(p)}catch(p){let i=await t(p);return x(i)}finally{await r()}}k.success=e=>U(e);k.fail=e=>x(e);var L=e=>{let t={values:new h(e)},r=()=>Array.from(t.values.entries()).map(([s,l])=>V([s,l])),p=s=>L(new h(t.values).set(s.toArray()[0],s.toArray()[1]).entries()),i=s=>{let l=new h(t.values);return l.delete(s)?L(l.entries()):L(t.values.entries())},o=s=>t.values.get(s[0])===s[1],T=()=>t.values.size,d=s=>L(Array.from(t.values.entries()).map(([l,q])=>[l,s(q)])),g=s=>{let l=L(t.values.entries()).toList();return L(l.flatMap(s).toArray())},F=s=>u(r()).reduce(s),I=s=>u(r()).reduceRight(s),N=s=>l=>u(r()).foldLeft(s)(l),z=s=>l=>u(r()).foldRight(s)(l),C=s=>y(t.values.get(s)),$=(s,l)=>y(t.values.get(s)).getOrElse(l),G=()=>t.values.size===0;return{add:p,remove:i,contains:o,get size(){return T()},map:d,flatMap:g,reduce:F,reduceRight:I,foldLeft:N,foldRight:z,get:C,getOrElse:$,get isEmpty(){return G()},orElse:(s,l)=>y(t.values.get(s)).orElse(l),toList:()=>u(r()),toSet:()=>E(r()),toString:()=>`Map(${r().toString()})`}},Ve=e=>L(e);import P from"safe-stable-stringify";var _=e=>({_tag:"Success",value:e,error:void 0,isSuccess:()=>!0,isFailure:()=>!1,get:()=>e,getOrElse:t=>e,orElse:t=>_(e),orThrow:t=>e,toEither:()=>a(e),map:t=>J(()=>t(e)),flatMap:t=>t(e),toString:()=>`Success(${P(e)})`}),B=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:()=>n(e),map:t=>B(e),flatMap:t=>B(e),toString:()=>`Failure(${P(e)}))`}),J=e=>{try{return _(e())}catch(t){return B(t instanceof Error?t:new Error(String(t)))}};var m=e=>({_tag:"Some",value:e,isEmpty:!1,get:()=>e,getOrElse:()=>e,getOrThrow:()=>e,orElse:()=>m(e),orNull:()=>e,map:t=>m(t(e)),filter(t){return t(e)?m(e):R},fold:(t,r)=>r(e),flatMap:t=>t(e),flatMapAsync:async t=>await 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:()=>u([e]),contains:t=>t===e,size:1,toEither:t=>a(e),toString:()=>`Some(${Q(e)})`,toValue:()=>({_tag:"Some",value:e})}),R={_tag:"None",value:void 0,isEmpty:!0,get:()=>{throw new Error("Cannot call get() on None")},getOrElse:e=>e,getOrThrow(e){throw e},orElse:e=>e,orNull:()=>null,map:e=>R,filter(e){return R},flatMap:e=>R,flatMapAsync:async e=>R,reduce:()=>{},reduceRight:()=>{},fold:(e,t)=>e(),foldLeft:e=>()=>e,foldRight:e=>()=>e,toList:()=>u([]),contains:()=>!1,size:0,toEither:e=>n(e),toString:()=>"None",toValue:()=>({_tag:"None",value:void 0})},c=()=>R,y=e=>e!=null?m(e):c();y.from=e=>y(e);y.none=()=>c();export{m as a,c as b,y as c,E as d,u as e,a as f,n as g,ye as h,de as i,Le as j,W as k,D as l,ce as m,H as n,x as o,U as p,M as q,k as r,Ve as s,J as t};
@@ -1,4 +1,4 @@
1
- export { a as Collection, C as Converters } from '../index-B5xiGKli.mjs';
1
+ export { a as Collection, C as Converters } from '../index-DBN7nT5K.mjs';
2
2
  import '../functor/index.mjs';
3
3
  import '../core/base/Base.mjs';
4
4
  import '../core/error/Throwable.mjs';
@@ -1,4 +1,4 @@
1
- export { a as Collection, C as Converters } from '../index-DqYpT1Od.js';
1
+ export { a as Collection, C as Converters } from '../index-D4Mn3DW4.js';
2
2
  import '../functor/index.js';
3
3
  import '../core/base/Base.js';
4
4
  import '../core/error/Throwable.js';
@@ -1,4 +1,4 @@
1
- export { A as AppException, h as AppResult, k as AsyncTask, j as Task } from '../../index-B5xiGKli.mjs';
1
+ export { A as AppException, h as AppResult, k as AsyncTask, j as Task } from '../../index-DBN7nT5K.mjs';
2
2
  import '../error/Throwable.mjs';
3
3
  import '../../functor/index.mjs';
4
4
  import '../base/Base.mjs';
@@ -1,4 +1,4 @@
1
- export { A as AppException, h as AppResult, k as AsyncTask, j as Task } from '../../index-DqYpT1Od.js';
1
+ export { A as AppException, h as AppResult, k as AsyncTask, j as Task } from '../../index-D4Mn3DW4.js';
2
2
  import '../error/Throwable.js';
3
3
  import '../../functor/index.js';
4
4
  import '../base/Base.js';
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkHTBQYXSNjs = require('../../chunk-HTBQYXSN.js');require('../../chunk-OXLZ6UIZ.js');require('../../chunk-SQWNJC6O.js');require('../../chunk-2U34DUZU.js');require('../../chunk-5VTXJIR3.js');require('../../chunk-3VJERXBP.js');require('../../chunk-5O6YELD3.js');require('../../chunk-XORABVON.js');require('../../chunk-K3EKBPQE.js');require('../../chunk-WTWWDZY6.js');exports.AppException = _chunkHTBQYXSNjs.o; exports.AppResult = _chunkHTBQYXSNjs.p; exports.AsyncTask = _chunkHTBQYXSNjs.r; exports.Task = _chunkHTBQYXSNjs.q;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkFKIJ6NNFjs = require('../../chunk-FKIJ6NNF.js');require('../../chunk-SQWNJC6O.js');require('../../chunk-2U34DUZU.js');require('../../chunk-5VTXJIR3.js');require('../../chunk-3VJERXBP.js');require('../../chunk-5O6YELD3.js');require('../../chunk-OXLZ6UIZ.js');require('../../chunk-XORABVON.js');require('../../chunk-K3EKBPQE.js');require('../../chunk-WTWWDZY6.js');exports.AppException = _chunkFKIJ6NNFjs.o; exports.AppResult = _chunkFKIJ6NNFjs.p; exports.AsyncTask = _chunkFKIJ6NNFjs.r; exports.Task = _chunkFKIJ6NNFjs.q;
@@ -1 +1 @@
1
- import{o as a,p as b,q as c,r as d}from"../../chunk-FBHTKYGN.mjs";import"../../chunk-2I2NKDFN.mjs";import"../../chunk-JF5YGNCO.mjs";import"../../chunk-HD6YYUHO.mjs";import"../../chunk-377WQNCB.mjs";import"../../chunk-HA5XD5KC.mjs";import"../../chunk-V7DKESTM.mjs";import"../../chunk-V2J3R5IU.mjs";import"../../chunk-2ML63TYF.mjs";import"../../chunk-4H62YQ42.mjs";export{a as AppException,b as AppResult,d as AsyncTask,c as Task};
1
+ import{o as a,p as b,q as c,r as d}from"../../chunk-ISN32ITK.mjs";import"../../chunk-JF5YGNCO.mjs";import"../../chunk-HD6YYUHO.mjs";import"../../chunk-377WQNCB.mjs";import"../../chunk-HA5XD5KC.mjs";import"../../chunk-V7DKESTM.mjs";import"../../chunk-2I2NKDFN.mjs";import"../../chunk-V2J3R5IU.mjs";import"../../chunk-2ML63TYF.mjs";import"../../chunk-4H62YQ42.mjs";export{a as AppException,b as AppResult,d as AsyncTask,c as Task};
@@ -1,5 +1,5 @@
1
1
  import '../functor/index.mjs';
2
- export { E as Either, c as Left, R as Right, T as TestEither, f as TypeCheckLeft, e as TypeCheckRight, d as isLeft, i as isRight, t as tryCatch, g as tryCatchAsync } from '../index-B5xiGKli.mjs';
2
+ export { E as Either, c as Left, R as Right, T as TestEither, f as TypeCheckLeft, e as TypeCheckRight, d as isLeft, i as isRight, t as tryCatch, g as tryCatchAsync } from '../index-DBN7nT5K.mjs';
3
3
  import '../typeable/Typeable.mjs';
4
4
  import '../core/base/Base.mjs';
5
5
  import '../core/error/Throwable.mjs';
@@ -1,5 +1,5 @@
1
1
  import '../functor/index.js';
2
- export { E as Either, c as Left, R as Right, T as TestEither, f as TypeCheckLeft, e as TypeCheckRight, d as isLeft, i as isRight, t as tryCatch, g as tryCatchAsync } from '../index-DqYpT1Od.js';
2
+ export { E as Either, c as Left, R as Right, T as TestEither, f as TypeCheckLeft, e as TypeCheckRight, d as isLeft, i as isRight, t as tryCatch, g as tryCatchAsync } from '../index-D4Mn3DW4.js';
3
3
  import '../typeable/Typeable.js';
4
4
  import '../core/base/Base.js';
5
5
  import '../core/error/Throwable.js';
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkHTBQYXSNjs = require('../chunk-HTBQYXSN.js');require('../chunk-OXLZ6UIZ.js');require('../chunk-SQWNJC6O.js');require('../chunk-2U34DUZU.js');require('../chunk-5VTXJIR3.js');require('../chunk-3VJERXBP.js');require('../chunk-5O6YELD3.js');require('../chunk-XORABVON.js');require('../chunk-K3EKBPQE.js');require('../chunk-WTWWDZY6.js');exports.Either = _chunkHTBQYXSNjs.n; exports.Left = _chunkHTBQYXSNjs.g; exports.Right = _chunkHTBQYXSNjs.f; exports.TypeCheckLeft = _chunkHTBQYXSNjs.l; exports.TypeCheckRight = _chunkHTBQYXSNjs.k; exports.isLeft = _chunkHTBQYXSNjs.i; exports.isRight = _chunkHTBQYXSNjs.h; exports.tryCatch = _chunkHTBQYXSNjs.j; exports.tryCatchAsync = _chunkHTBQYXSNjs.m;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkFKIJ6NNFjs = require('../chunk-FKIJ6NNF.js');require('../chunk-SQWNJC6O.js');require('../chunk-2U34DUZU.js');require('../chunk-5VTXJIR3.js');require('../chunk-3VJERXBP.js');require('../chunk-5O6YELD3.js');require('../chunk-OXLZ6UIZ.js');require('../chunk-XORABVON.js');require('../chunk-K3EKBPQE.js');require('../chunk-WTWWDZY6.js');exports.Either = _chunkFKIJ6NNFjs.n; exports.Left = _chunkFKIJ6NNFjs.g; exports.Right = _chunkFKIJ6NNFjs.f; exports.TypeCheckLeft = _chunkFKIJ6NNFjs.l; exports.TypeCheckRight = _chunkFKIJ6NNFjs.k; exports.isLeft = _chunkFKIJ6NNFjs.i; exports.isRight = _chunkFKIJ6NNFjs.h; exports.tryCatch = _chunkFKIJ6NNFjs.j; exports.tryCatchAsync = _chunkFKIJ6NNFjs.m;
@@ -1 +1 @@
1
- import{f as a,g as b,h as c,i as d,j as e,k as f,l as g,m as h,n as i}from"../chunk-FBHTKYGN.mjs";import"../chunk-2I2NKDFN.mjs";import"../chunk-JF5YGNCO.mjs";import"../chunk-HD6YYUHO.mjs";import"../chunk-377WQNCB.mjs";import"../chunk-HA5XD5KC.mjs";import"../chunk-V7DKESTM.mjs";import"../chunk-V2J3R5IU.mjs";import"../chunk-2ML63TYF.mjs";import"../chunk-4H62YQ42.mjs";export{i as Either,b as Left,a as Right,g as TypeCheckLeft,f as TypeCheckRight,d as isLeft,c as isRight,e as tryCatch,h as tryCatchAsync};
1
+ import{f as a,g as b,h as c,i as d,j as e,k as f,l as g,m as h,n as i}from"../chunk-ISN32ITK.mjs";import"../chunk-JF5YGNCO.mjs";import"../chunk-HD6YYUHO.mjs";import"../chunk-377WQNCB.mjs";import"../chunk-HA5XD5KC.mjs";import"../chunk-V7DKESTM.mjs";import"../chunk-2I2NKDFN.mjs";import"../chunk-V2J3R5IU.mjs";import"../chunk-2ML63TYF.mjs";import"../chunk-4H62YQ42.mjs";export{i as Either,b as Left,a as Right,g as TypeCheckLeft,f as TypeCheckRight,d as isLeft,c as isRight,e as tryCatch,h as tryCatchAsync};
@@ -90,6 +90,15 @@ type Set<A> = {
90
90
  } & IterableType<A> & Collection<A>;
91
91
  declare const Set: <A>(iterable?: Iterable<A> | IterableType<A>) => Set<A>;
92
92
 
93
+ type TypeGuard<A, B extends A> = (a: A | undefined) => a is B;
94
+ type FilterFn<A> = {
95
+ <B extends A>(p: TypeGuard<A, B>): List<B>;
96
+ (p: (a: A) => boolean): List<A>;
97
+ };
98
+ type FindFn<A> = {
99
+ <B extends A>(p: TypeGuard<A, B>): Option<B>;
100
+ (p: (a: A) => boolean): Option<A>;
101
+ };
93
102
  type List<A> = {
94
103
  readonly length: number;
95
104
  readonly [Symbol.iterator]: () => Iterator<A>;
@@ -99,9 +108,9 @@ type List<A> = {
99
108
  forEach: (f: (a: A) => void) => void;
100
109
  count: (p: (x: A) => boolean) => number;
101
110
  exists: (p: (a: A) => boolean) => boolean;
102
- filter: (p: (a: A) => boolean) => List<A>;
111
+ filter: FilterFn<A>;
103
112
  filterNot: (p: (a: A) => boolean) => List<A>;
104
- find: (p: (a: A) => boolean) => Option<A>;
113
+ find: FindFn<A>;
105
114
  readonly head: A;
106
115
  readonly headOption: Option<A>;
107
116
  readonly isEmpty: boolean;
@@ -90,6 +90,15 @@ type Set<A> = {
90
90
  } & IterableType<A> & Collection<A>;
91
91
  declare const Set: <A>(iterable?: Iterable<A> | IterableType<A>) => Set<A>;
92
92
 
93
+ type TypeGuard<A, B extends A> = (a: A | undefined) => a is B;
94
+ type FilterFn<A> = {
95
+ <B extends A>(p: TypeGuard<A, B>): List<B>;
96
+ (p: (a: A) => boolean): List<A>;
97
+ };
98
+ type FindFn<A> = {
99
+ <B extends A>(p: TypeGuard<A, B>): Option<B>;
100
+ (p: (a: A) => boolean): Option<A>;
101
+ };
93
102
  type List<A> = {
94
103
  readonly length: number;
95
104
  readonly [Symbol.iterator]: () => Iterator<A>;
@@ -99,9 +108,9 @@ type List<A> = {
99
108
  forEach: (f: (a: A) => void) => void;
100
109
  count: (p: (x: A) => boolean) => number;
101
110
  exists: (p: (a: A) => boolean) => boolean;
102
- filter: (p: (a: A) => boolean) => List<A>;
111
+ filter: FilterFn<A>;
103
112
  filterNot: (p: (a: A) => boolean) => List<A>;
104
- find: (p: (a: A) => boolean) => Option<A>;
113
+ find: FindFn<A>;
105
114
  readonly head: A;
106
115
  readonly headOption: Option<A>;
107
116
  readonly isEmpty: boolean;
package/dist/index.d.mts CHANGED
@@ -1,7 +1,7 @@
1
1
  export { AbstractFunctor, ArrayFunctor, ArrayType, AsyncFunctor, Functor, SingleType, Type } from './functor/index.mjs';
2
2
  export { Base } from './core/base/Base.mjs';
3
3
  export { Throwable } from './core/error/Throwable.mjs';
4
- export { A as AppException, h as AppResult, k as AsyncTask, E as Either, I as IterableType, c as Left, L as List, M as Map, N as None, O as Option, R as Right, b as Set, S as Some, j as Task, T as TestEither, m as Traversable, l as Try, f as TypeCheckLeft, e as TypeCheckRight, d as isLeft, i as isRight, t as tryCatch, g as tryCatchAsync } from './index-B5xiGKli.mjs';
4
+ export { A as AppException, h as AppResult, k as AsyncTask, E as Either, I as IterableType, c as Left, L as List, M as Map, N as None, O as Option, R as Right, b as Set, S as Some, j as Task, T as TestEither, m as Traversable, l as Try, f as TypeCheckLeft, e as TypeCheckRight, d as isLeft, i as isRight, t as tryCatch, g as tryCatchAsync } from './index-DBN7nT5K.mjs';
5
5
  export { Identity } from './identity/Identity.mjs';
6
6
  export { Tuple } from './tuple/Tuple.mjs';
7
7
  export { Typeable, UnTag } from './typeable/Typeable.mjs';
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  export { AbstractFunctor, ArrayFunctor, ArrayType, AsyncFunctor, Functor, SingleType, Type } from './functor/index.js';
2
2
  export { Base } from './core/base/Base.js';
3
3
  export { Throwable } from './core/error/Throwable.js';
4
- export { A as AppException, h as AppResult, k as AsyncTask, E as Either, I as IterableType, c as Left, L as List, M as Map, N as None, O as Option, R as Right, b as Set, S as Some, j as Task, T as TestEither, m as Traversable, l as Try, f as TypeCheckLeft, e as TypeCheckRight, d as isLeft, i as isRight, t as tryCatch, g as tryCatchAsync } from './index-DqYpT1Od.js';
4
+ export { A as AppException, h as AppResult, k as AsyncTask, E as Either, I as IterableType, c as Left, L as List, M as Map, N as None, O as Option, R as Right, b as Set, S as Some, j as Task, T as TestEither, m as Traversable, l as Try, f as TypeCheckLeft, e as TypeCheckRight, d as isLeft, i as isRight, t as tryCatch, g as tryCatchAsync } from './index-D4Mn3DW4.js';
5
5
  export { Identity } from './identity/Identity.js';
6
6
  export { Tuple } from './tuple/Tuple.js';
7
7
  export { Typeable, UnTag } from './typeable/Typeable.js';
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkHTBQYXSNjs = require('./chunk-HTBQYXSN.js');var _chunkOXLZ6UIZjs = require('./chunk-OXLZ6UIZ.js');var _chunkSQWNJC6Ojs = require('./chunk-SQWNJC6O.js');var _chunk2U34DUZUjs = require('./chunk-2U34DUZU.js');require('./chunk-5VTXJIR3.js');require('./chunk-3VJERXBP.js');var _chunk5O6YELD3js = require('./chunk-5O6YELD3.js');require('./chunk-XORABVON.js');require('./chunk-K3EKBPQE.js');require('./chunk-WTWWDZY6.js');exports.AppException = _chunkHTBQYXSNjs.o; exports.AppResult = _chunkHTBQYXSNjs.p; exports.AsyncTask = _chunkHTBQYXSNjs.r; exports.Base = _chunkSQWNJC6Ojs.a; exports.Either = _chunkHTBQYXSNjs.n; exports.Left = _chunkHTBQYXSNjs.g; exports.List = _chunkHTBQYXSNjs.e; exports.Map = _chunkHTBQYXSNjs.s; exports.None = _chunkHTBQYXSNjs.b; exports.Option = _chunkHTBQYXSNjs.c; exports.Right = _chunkHTBQYXSNjs.f; exports.Set = _chunkHTBQYXSNjs.d; exports.Some = _chunkHTBQYXSNjs.a; exports.Task = _chunkHTBQYXSNjs.q; exports.Throwable = _chunk2U34DUZUjs.a; exports.Try = _chunkHTBQYXSNjs.t; exports.Tuple = _chunkOXLZ6UIZjs.a; exports.TypeCheckLeft = _chunkHTBQYXSNjs.l; exports.TypeCheckRight = _chunkHTBQYXSNjs.k; exports.Typeable = _chunk5O6YELD3js.a; exports.isLeft = _chunkHTBQYXSNjs.i; exports.isRight = _chunkHTBQYXSNjs.h; exports.tryCatch = _chunkHTBQYXSNjs.j; exports.tryCatchAsync = _chunkHTBQYXSNjs.m;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkFKIJ6NNFjs = require('./chunk-FKIJ6NNF.js');var _chunkSQWNJC6Ojs = require('./chunk-SQWNJC6O.js');var _chunk2U34DUZUjs = require('./chunk-2U34DUZU.js');require('./chunk-5VTXJIR3.js');require('./chunk-3VJERXBP.js');var _chunk5O6YELD3js = require('./chunk-5O6YELD3.js');var _chunkOXLZ6UIZjs = require('./chunk-OXLZ6UIZ.js');require('./chunk-XORABVON.js');require('./chunk-K3EKBPQE.js');require('./chunk-WTWWDZY6.js');exports.AppException = _chunkFKIJ6NNFjs.o; exports.AppResult = _chunkFKIJ6NNFjs.p; exports.AsyncTask = _chunkFKIJ6NNFjs.r; exports.Base = _chunkSQWNJC6Ojs.a; exports.Either = _chunkFKIJ6NNFjs.n; exports.Left = _chunkFKIJ6NNFjs.g; exports.List = _chunkFKIJ6NNFjs.e; exports.Map = _chunkFKIJ6NNFjs.s; exports.None = _chunkFKIJ6NNFjs.b; exports.Option = _chunkFKIJ6NNFjs.c; exports.Right = _chunkFKIJ6NNFjs.f; exports.Set = _chunkFKIJ6NNFjs.d; exports.Some = _chunkFKIJ6NNFjs.a; exports.Task = _chunkFKIJ6NNFjs.q; exports.Throwable = _chunk2U34DUZUjs.a; exports.Try = _chunkFKIJ6NNFjs.t; exports.Tuple = _chunkOXLZ6UIZjs.a; exports.TypeCheckLeft = _chunkFKIJ6NNFjs.l; exports.TypeCheckRight = _chunkFKIJ6NNFjs.k; exports.Typeable = _chunk5O6YELD3js.a; exports.isLeft = _chunkFKIJ6NNFjs.i; exports.isRight = _chunkFKIJ6NNFjs.h; exports.tryCatch = _chunkFKIJ6NNFjs.j; exports.tryCatchAsync = _chunkFKIJ6NNFjs.m;
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{a as d,b as e,c as f,d as g,e as h,f as i,g as j,h as k,i as l,j as m,k as n,l as o,m as p,n as q,o as r,p as s,q as t,r as u,s as w,t as x}from"./chunk-FBHTKYGN.mjs";import{a as v}from"./chunk-2I2NKDFN.mjs";import{a as b}from"./chunk-JF5YGNCO.mjs";import{a as c}from"./chunk-HD6YYUHO.mjs";import"./chunk-377WQNCB.mjs";import"./chunk-HA5XD5KC.mjs";import{a}from"./chunk-V7DKESTM.mjs";import"./chunk-V2J3R5IU.mjs";import"./chunk-2ML63TYF.mjs";import"./chunk-4H62YQ42.mjs";export{r as AppException,s as AppResult,u as AsyncTask,b as Base,q as Either,j as Left,h as List,w as Map,e as None,f as Option,i as Right,g as Set,d as Some,t as Task,c as Throwable,x as Try,v as Tuple,o as TypeCheckLeft,n as TypeCheckRight,a as Typeable,l as isLeft,k as isRight,m as tryCatch,p as tryCatchAsync};
1
+ import{a as d,b as e,c as f,d as g,e as h,f as i,g as j,h as k,i as l,j as m,k as n,l as o,m as p,n as q,o as r,p as s,q as t,r as u,s as w,t as x}from"./chunk-ISN32ITK.mjs";import{a as b}from"./chunk-JF5YGNCO.mjs";import{a as c}from"./chunk-HD6YYUHO.mjs";import"./chunk-377WQNCB.mjs";import"./chunk-HA5XD5KC.mjs";import{a}from"./chunk-V7DKESTM.mjs";import{a as v}from"./chunk-2I2NKDFN.mjs";import"./chunk-V2J3R5IU.mjs";import"./chunk-2ML63TYF.mjs";import"./chunk-4H62YQ42.mjs";export{r as AppException,s as AppResult,u as AsyncTask,b as Base,q as Either,j as Left,h as List,w as Map,e as None,f as Option,i as Right,g as Set,d as Some,t as Task,c as Throwable,x as Try,v as Tuple,o as TypeCheckLeft,n as TypeCheckRight,a as Typeable,l as isLeft,k as isRight,m as tryCatch,p as tryCatchAsync};
@@ -1,5 +1,5 @@
1
1
  import '../functor/index.mjs';
2
- export { I as IterableType } from '../index-B5xiGKli.mjs';
2
+ export { I as IterableType } from '../index-DBN7nT5K.mjs';
3
3
  import '../core/base/Base.mjs';
4
4
  import '../core/error/Throwable.mjs';
5
5
  import '../typeable/Typeable.mjs';
@@ -1,5 +1,5 @@
1
1
  import '../functor/index.js';
2
- export { I as IterableType } from '../index-DqYpT1Od.js';
2
+ export { I as IterableType } from '../index-D4Mn3DW4.js';
3
3
  import '../core/base/Base.js';
4
4
  import '../core/error/Throwable.js';
5
5
  import '../typeable/Typeable.js';
@@ -1,5 +1,5 @@
1
1
  import '../functor/index.mjs';
2
- export { L as List } from '../index-B5xiGKli.mjs';
2
+ export { L as List } from '../index-DBN7nT5K.mjs';
3
3
  import '../typeable/Typeable.mjs';
4
4
  import '../core/base/Base.mjs';
5
5
  import '../core/error/Throwable.mjs';
@@ -1,5 +1,5 @@
1
1
  import '../functor/index.js';
2
- export { L as List } from '../index-DqYpT1Od.js';
2
+ export { L as List } from '../index-D4Mn3DW4.js';
3
3
  import '../typeable/Typeable.js';
4
4
  import '../core/base/Base.js';
5
5
  import '../core/error/Throwable.js';
package/dist/list/List.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkHTBQYXSNjs = require('../chunk-HTBQYXSN.js');require('../chunk-OXLZ6UIZ.js');require('../chunk-SQWNJC6O.js');require('../chunk-2U34DUZU.js');require('../chunk-5VTXJIR3.js');require('../chunk-3VJERXBP.js');require('../chunk-5O6YELD3.js');require('../chunk-XORABVON.js');require('../chunk-K3EKBPQE.js');require('../chunk-WTWWDZY6.js');exports.List = _chunkHTBQYXSNjs.e;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkFKIJ6NNFjs = require('../chunk-FKIJ6NNF.js');require('../chunk-SQWNJC6O.js');require('../chunk-2U34DUZU.js');require('../chunk-5VTXJIR3.js');require('../chunk-3VJERXBP.js');require('../chunk-5O6YELD3.js');require('../chunk-OXLZ6UIZ.js');require('../chunk-XORABVON.js');require('../chunk-K3EKBPQE.js');require('../chunk-WTWWDZY6.js');exports.List = _chunkFKIJ6NNFjs.e;
@@ -1 +1 @@
1
- import{e as a}from"../chunk-FBHTKYGN.mjs";import"../chunk-2I2NKDFN.mjs";import"../chunk-JF5YGNCO.mjs";import"../chunk-HD6YYUHO.mjs";import"../chunk-377WQNCB.mjs";import"../chunk-HA5XD5KC.mjs";import"../chunk-V7DKESTM.mjs";import"../chunk-V2J3R5IU.mjs";import"../chunk-2ML63TYF.mjs";import"../chunk-4H62YQ42.mjs";export{a as List};
1
+ import{e as a}from"../chunk-ISN32ITK.mjs";import"../chunk-JF5YGNCO.mjs";import"../chunk-HD6YYUHO.mjs";import"../chunk-377WQNCB.mjs";import"../chunk-HA5XD5KC.mjs";import"../chunk-V7DKESTM.mjs";import"../chunk-2I2NKDFN.mjs";import"../chunk-V2J3R5IU.mjs";import"../chunk-2ML63TYF.mjs";import"../chunk-4H62YQ42.mjs";export{a as List};
@@ -1,4 +1,4 @@
1
- export { M as Map } from '../index-B5xiGKli.mjs';
1
+ export { M as Map } from '../index-DBN7nT5K.mjs';
2
2
  import '../tuple/Tuple.mjs';
3
3
  import '../functor/index.mjs';
4
4
  import '../core/base/Base.mjs';
package/dist/map/Map.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { M as Map } from '../index-DqYpT1Od.js';
1
+ export { M as Map } from '../index-D4Mn3DW4.js';
2
2
  import '../tuple/Tuple.js';
3
3
  import '../functor/index.js';
4
4
  import '../core/base/Base.js';
package/dist/map/Map.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkHTBQYXSNjs = require('../chunk-HTBQYXSN.js');require('../chunk-OXLZ6UIZ.js');require('../chunk-SQWNJC6O.js');require('../chunk-2U34DUZU.js');require('../chunk-5VTXJIR3.js');require('../chunk-3VJERXBP.js');require('../chunk-5O6YELD3.js');require('../chunk-XORABVON.js');require('../chunk-K3EKBPQE.js');require('../chunk-WTWWDZY6.js');exports.Map = _chunkHTBQYXSNjs.s;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkFKIJ6NNFjs = require('../chunk-FKIJ6NNF.js');require('../chunk-SQWNJC6O.js');require('../chunk-2U34DUZU.js');require('../chunk-5VTXJIR3.js');require('../chunk-3VJERXBP.js');require('../chunk-5O6YELD3.js');require('../chunk-OXLZ6UIZ.js');require('../chunk-XORABVON.js');require('../chunk-K3EKBPQE.js');require('../chunk-WTWWDZY6.js');exports.Map = _chunkFKIJ6NNFjs.s;
package/dist/map/Map.mjs CHANGED
@@ -1 +1 @@
1
- import{s as a}from"../chunk-FBHTKYGN.mjs";import"../chunk-2I2NKDFN.mjs";import"../chunk-JF5YGNCO.mjs";import"../chunk-HD6YYUHO.mjs";import"../chunk-377WQNCB.mjs";import"../chunk-HA5XD5KC.mjs";import"../chunk-V7DKESTM.mjs";import"../chunk-V2J3R5IU.mjs";import"../chunk-2ML63TYF.mjs";import"../chunk-4H62YQ42.mjs";export{a as Map};
1
+ import{s as a}from"../chunk-ISN32ITK.mjs";import"../chunk-JF5YGNCO.mjs";import"../chunk-HD6YYUHO.mjs";import"../chunk-377WQNCB.mjs";import"../chunk-HA5XD5KC.mjs";import"../chunk-V7DKESTM.mjs";import"../chunk-2I2NKDFN.mjs";import"../chunk-V2J3R5IU.mjs";import"../chunk-2ML63TYF.mjs";import"../chunk-4H62YQ42.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-B5xiGKli.mjs';
2
+ export { N as None, O as Option, S as Some } from '../index-DBN7nT5K.mjs';
3
3
  import '../typeable/Typeable.mjs';
4
4
  import '../valuable/Valuable.mjs';
5
5
  import '../core/base/Base.mjs';
@@ -1,5 +1,5 @@
1
1
  import '../functor/index.js';
2
- export { N as None, O as Option, S as Some } from '../index-DqYpT1Od.js';
2
+ export { N as None, O as Option, S as Some } from '../index-D4Mn3DW4.js';
3
3
  import '../typeable/Typeable.js';
4
4
  import '../valuable/Valuable.js';
5
5
  import '../core/base/Base.js';
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkHTBQYXSNjs = require('../chunk-HTBQYXSN.js');require('../chunk-OXLZ6UIZ.js');require('../chunk-SQWNJC6O.js');require('../chunk-2U34DUZU.js');require('../chunk-5VTXJIR3.js');require('../chunk-3VJERXBP.js');require('../chunk-5O6YELD3.js');require('../chunk-XORABVON.js');require('../chunk-K3EKBPQE.js');require('../chunk-WTWWDZY6.js');exports.None = _chunkHTBQYXSNjs.b; exports.Option = _chunkHTBQYXSNjs.c; exports.Some = _chunkHTBQYXSNjs.a;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkFKIJ6NNFjs = require('../chunk-FKIJ6NNF.js');require('../chunk-SQWNJC6O.js');require('../chunk-2U34DUZU.js');require('../chunk-5VTXJIR3.js');require('../chunk-3VJERXBP.js');require('../chunk-5O6YELD3.js');require('../chunk-OXLZ6UIZ.js');require('../chunk-XORABVON.js');require('../chunk-K3EKBPQE.js');require('../chunk-WTWWDZY6.js');exports.None = _chunkFKIJ6NNFjs.b; exports.Option = _chunkFKIJ6NNFjs.c; exports.Some = _chunkFKIJ6NNFjs.a;
@@ -1 +1 @@
1
- import{a,b,c}from"../chunk-FBHTKYGN.mjs";import"../chunk-2I2NKDFN.mjs";import"../chunk-JF5YGNCO.mjs";import"../chunk-HD6YYUHO.mjs";import"../chunk-377WQNCB.mjs";import"../chunk-HA5XD5KC.mjs";import"../chunk-V7DKESTM.mjs";import"../chunk-V2J3R5IU.mjs";import"../chunk-2ML63TYF.mjs";import"../chunk-4H62YQ42.mjs";export{b as None,c as Option,a as Some};
1
+ import{a,b,c}from"../chunk-ISN32ITK.mjs";import"../chunk-JF5YGNCO.mjs";import"../chunk-HD6YYUHO.mjs";import"../chunk-377WQNCB.mjs";import"../chunk-HA5XD5KC.mjs";import"../chunk-V7DKESTM.mjs";import"../chunk-2I2NKDFN.mjs";import"../chunk-V2J3R5IU.mjs";import"../chunk-2ML63TYF.mjs";import"../chunk-4H62YQ42.mjs";export{b as None,c as Option,a as Some};
@@ -1,4 +1,4 @@
1
- export { b as Set } from '../index-B5xiGKli.mjs';
1
+ export { b as Set } from '../index-DBN7nT5K.mjs';
2
2
  import '../functor/index.mjs';
3
3
  import '../core/base/Base.mjs';
4
4
  import '../core/error/Throwable.mjs';
package/dist/set/Set.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { b as Set } from '../index-DqYpT1Od.js';
1
+ export { b as Set } from '../index-D4Mn3DW4.js';
2
2
  import '../functor/index.js';
3
3
  import '../core/base/Base.js';
4
4
  import '../core/error/Throwable.js';
package/dist/set/Set.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkHTBQYXSNjs = require('../chunk-HTBQYXSN.js');require('../chunk-OXLZ6UIZ.js');require('../chunk-SQWNJC6O.js');require('../chunk-2U34DUZU.js');require('../chunk-5VTXJIR3.js');require('../chunk-3VJERXBP.js');require('../chunk-5O6YELD3.js');require('../chunk-XORABVON.js');require('../chunk-K3EKBPQE.js');require('../chunk-WTWWDZY6.js');exports.Set = _chunkHTBQYXSNjs.d;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkFKIJ6NNFjs = require('../chunk-FKIJ6NNF.js');require('../chunk-SQWNJC6O.js');require('../chunk-2U34DUZU.js');require('../chunk-5VTXJIR3.js');require('../chunk-3VJERXBP.js');require('../chunk-5O6YELD3.js');require('../chunk-OXLZ6UIZ.js');require('../chunk-XORABVON.js');require('../chunk-K3EKBPQE.js');require('../chunk-WTWWDZY6.js');exports.Set = _chunkFKIJ6NNFjs.d;
package/dist/set/Set.mjs CHANGED
@@ -1 +1 @@
1
- import{d as a}from"../chunk-FBHTKYGN.mjs";import"../chunk-2I2NKDFN.mjs";import"../chunk-JF5YGNCO.mjs";import"../chunk-HD6YYUHO.mjs";import"../chunk-377WQNCB.mjs";import"../chunk-HA5XD5KC.mjs";import"../chunk-V7DKESTM.mjs";import"../chunk-V2J3R5IU.mjs";import"../chunk-2ML63TYF.mjs";import"../chunk-4H62YQ42.mjs";export{a as Set};
1
+ import{d as a}from"../chunk-ISN32ITK.mjs";import"../chunk-JF5YGNCO.mjs";import"../chunk-HD6YYUHO.mjs";import"../chunk-377WQNCB.mjs";import"../chunk-HA5XD5KC.mjs";import"../chunk-V7DKESTM.mjs";import"../chunk-2I2NKDFN.mjs";import"../chunk-V2J3R5IU.mjs";import"../chunk-2ML63TYF.mjs";import"../chunk-4H62YQ42.mjs";export{a as Set};
@@ -1,4 +1,4 @@
1
- export { l as Try } from '../index-B5xiGKli.mjs';
1
+ export { l as Try } from '../index-DBN7nT5K.mjs';
2
2
  import '../typeable/Typeable.mjs';
3
3
  import '../functor/index.mjs';
4
4
  import '../core/base/Base.mjs';
package/dist/try/Try.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { l as Try } from '../index-DqYpT1Od.js';
1
+ export { l as Try } from '../index-D4Mn3DW4.js';
2
2
  import '../typeable/Typeable.js';
3
3
  import '../functor/index.js';
4
4
  import '../core/base/Base.js';
package/dist/try/Try.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkHTBQYXSNjs = require('../chunk-HTBQYXSN.js');require('../chunk-OXLZ6UIZ.js');require('../chunk-SQWNJC6O.js');require('../chunk-2U34DUZU.js');require('../chunk-5VTXJIR3.js');require('../chunk-3VJERXBP.js');require('../chunk-5O6YELD3.js');require('../chunk-XORABVON.js');require('../chunk-K3EKBPQE.js');require('../chunk-WTWWDZY6.js');exports.Try = _chunkHTBQYXSNjs.t;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkFKIJ6NNFjs = require('../chunk-FKIJ6NNF.js');require('../chunk-SQWNJC6O.js');require('../chunk-2U34DUZU.js');require('../chunk-5VTXJIR3.js');require('../chunk-3VJERXBP.js');require('../chunk-5O6YELD3.js');require('../chunk-OXLZ6UIZ.js');require('../chunk-XORABVON.js');require('../chunk-K3EKBPQE.js');require('../chunk-WTWWDZY6.js');exports.Try = _chunkFKIJ6NNFjs.t;
package/dist/try/Try.mjs CHANGED
@@ -1 +1 @@
1
- import{t as a}from"../chunk-FBHTKYGN.mjs";import"../chunk-2I2NKDFN.mjs";import"../chunk-JF5YGNCO.mjs";import"../chunk-HD6YYUHO.mjs";import"../chunk-377WQNCB.mjs";import"../chunk-HA5XD5KC.mjs";import"../chunk-V7DKESTM.mjs";import"../chunk-V2J3R5IU.mjs";import"../chunk-2ML63TYF.mjs";import"../chunk-4H62YQ42.mjs";export{a as Try};
1
+ import{t as a}from"../chunk-ISN32ITK.mjs";import"../chunk-JF5YGNCO.mjs";import"../chunk-HD6YYUHO.mjs";import"../chunk-377WQNCB.mjs";import"../chunk-HA5XD5KC.mjs";import"../chunk-V7DKESTM.mjs";import"../chunk-2I2NKDFN.mjs";import"../chunk-V2J3R5IU.mjs";import"../chunk-2ML63TYF.mjs";import"../chunk-4H62YQ42.mjs";export{a as Try};
@@ -1,4 +1,4 @@
1
- import { E as Either } from '../index-B5xiGKli.mjs';
1
+ import { E as Either } from '../index-DBN7nT5K.mjs';
2
2
  import { ParseError } from '../error/ParseError.mjs';
3
3
  import '../functor/index.mjs';
4
4
  import '../core/base/Base.mjs';
@@ -1,4 +1,4 @@
1
- import { E as Either } from '../index-DqYpT1Od.js';
1
+ import { E as Either } from '../index-D4Mn3DW4.js';
2
2
  import { ParseError } from '../error/ParseError.js';
3
3
  import '../functor/index.js';
4
4
  import '../core/base/Base.js';
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkE6RS47F7js = require('../chunk-E6RS47F7.js');var _chunkHTBQYXSNjs = require('../chunk-HTBQYXSN.js');require('../chunk-OXLZ6UIZ.js');require('../chunk-SQWNJC6O.js');require('../chunk-2U34DUZU.js');require('../chunk-5VTXJIR3.js');require('../chunk-3VJERXBP.js');require('../chunk-5O6YELD3.js');require('../chunk-XORABVON.js');require('../chunk-K3EKBPQE.js');require('../chunk-WTWWDZY6.js');var a=o=>{let r=parseInt(o,10);return isNaN(r)?_chunkHTBQYXSNjs.g.call(void 0, _chunkE6RS47F7js.a.call(void 0, `${r}`)):_chunkHTBQYXSNjs.f.call(void 0, r)};exports.parseNumber = a;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkE6RS47F7js = require('../chunk-E6RS47F7.js');var _chunkFKIJ6NNFjs = require('../chunk-FKIJ6NNF.js');require('../chunk-SQWNJC6O.js');require('../chunk-2U34DUZU.js');require('../chunk-5VTXJIR3.js');require('../chunk-3VJERXBP.js');require('../chunk-5O6YELD3.js');require('../chunk-OXLZ6UIZ.js');require('../chunk-XORABVON.js');require('../chunk-K3EKBPQE.js');require('../chunk-WTWWDZY6.js');var a=o=>{let r=parseInt(o,10);return isNaN(r)?_chunkFKIJ6NNFjs.g.call(void 0, _chunkE6RS47F7js.a.call(void 0, `${r}`)):_chunkFKIJ6NNFjs.f.call(void 0, r)};exports.parseNumber = a;
@@ -1 +1 @@
1
- import{a as s}from"../chunk-VK5GL6NM.mjs";import{f as e,g as t}from"../chunk-FBHTKYGN.mjs";import"../chunk-2I2NKDFN.mjs";import"../chunk-JF5YGNCO.mjs";import"../chunk-HD6YYUHO.mjs";import"../chunk-377WQNCB.mjs";import"../chunk-HA5XD5KC.mjs";import"../chunk-V7DKESTM.mjs";import"../chunk-V2J3R5IU.mjs";import"../chunk-2ML63TYF.mjs";import"../chunk-4H62YQ42.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{f as e,g as t}from"../chunk-ISN32ITK.mjs";import"../chunk-JF5YGNCO.mjs";import"../chunk-HD6YYUHO.mjs";import"../chunk-377WQNCB.mjs";import"../chunk-HA5XD5KC.mjs";import"../chunk-V7DKESTM.mjs";import"../chunk-2I2NKDFN.mjs";import"../chunk-V2J3R5IU.mjs";import"../chunk-2ML63TYF.mjs";import"../chunk-4H62YQ42.mjs";var a=o=>{let r=parseInt(o,10);return isNaN(r)?t(s(`${r}`)):e(r)};export{a as parseNumber};
@@ -0,0 +1,3 @@
1
+ import { Type } from "../lib";
2
+ import { Functor } from "./functor";
3
+ export type TaskPromise<A extends Type> = Promise<A> & Functor<A>;
@@ -0,0 +1,8 @@
1
+ import { List } from "../list/List";
2
+ import { Set } from "../set/Set";
3
+ export type Converters<A> = {
4
+ toList(): List<A>;
5
+ toSet(): Set<A>;
6
+ toString(): string;
7
+ };
8
+ export type Collection<A> = Converters<A>;
@@ -0,0 +1,52 @@
1
+ import { Functor, Type } from "../functor";
2
+ import { List } from "../list/List";
3
+ import { Option } from "../option/Option";
4
+ import { Typeable } from "../typeable/Typeable";
5
+ export type Either<L extends Type, R extends Type> = {
6
+ readonly _tag: "Left" | "Right";
7
+ value: L | R;
8
+ isLeft: () => boolean;
9
+ isRight: () => boolean;
10
+ getOrElse: (defaultValue: R) => R;
11
+ getOrThrow: () => R;
12
+ map: <U extends Type>(f: (value: R) => U) => Either<L, U>;
13
+ merge: <L1 extends Type, R1 extends Type>(other: Either<L1, R1>) => Either<L | L1, [R, R1]>;
14
+ mapAsync: <U extends Type>(f: (value: R) => Promise<U>) => Promise<Either<L, U>>;
15
+ flatMap: <U extends Type>(f: (value: R) => Either<L, U>) => Either<L, U>;
16
+ flatMapAsync: <U extends Type>(f: (value: R) => Promise<Either<L, U>>) => Promise<Either<L, U>>;
17
+ toOption: () => Option<R>;
18
+ toList: () => List<R>;
19
+ toString: () => string;
20
+ [Symbol.iterator]: () => Iterator<R>;
21
+ yield: () => Generator<R, void, unknown>;
22
+ traverse: <U extends Type>(f: (value: R) => Either<L, U>) => Either<L, U[]>;
23
+ lazyMap: <U extends Type>(f: (value: R) => U) => Generator<Either<L, U>, void, unknown>;
24
+ tap: (f: (value: R) => void) => Either<L, R>;
25
+ tapLeft: (f: (value: L) => void) => Either<L, R>;
26
+ mapLeft: <L2 extends Type>(f: (value: L) => L2) => Either<L2, R>;
27
+ bimap: <L2 extends Type, R2 extends Type>(fl: (value: L) => L2, fr: (value: R) => R2) => Either<L2, R2>;
28
+ fold: <T extends Type>(onLeft: (value: L) => T, onRight: (value: R) => T) => T;
29
+ swap: () => Either<R, L>;
30
+ } & Typeable<"Left" | "Right"> & PromiseLike<R>;
31
+ export type TestEither<L extends Type, R extends Type> = Either<L, R> & Functor<R>;
32
+ export declare const Right: <L extends Type, R extends Type>(value: R) => Either<L, R>;
33
+ export declare const Left: <L extends Type, R extends Type>(value: L) => Either<L, R>;
34
+ export declare const isRight: <L extends Type, R extends Type>(either: Either<L, R>) => either is Either<L, R> & {
35
+ value: R;
36
+ };
37
+ export declare const isLeft: <L extends Type, R extends Type>(either: Either<L, R>) => either is Either<L, R> & {
38
+ value: L;
39
+ };
40
+ export declare const tryCatch: <L extends Type, R extends Type>(f: () => R, onError: (error: unknown) => L) => Either<L, R>;
41
+ export declare const TypeCheckRight: <L extends Type, R extends Type>(value: R) => TestEither<L, R>;
42
+ export declare const TypeCheckLeft: <L extends Type, R extends Type>(value: L) => TestEither<L, R>;
43
+ export declare const tryCatchAsync: <L extends Type, R extends Type>(f: () => Promise<R>, onError: (error: unknown) => L) => Promise<Either<L, R>>;
44
+ export declare const tryCatchSync: <L extends Type, R extends Type>(f: () => R, onError: (error: unknown) => L) => Either<L, R>;
45
+ export declare const Either: {
46
+ sequence: <L extends Type, R extends Type>(eithers: Either<L, R>[]) => Either<L, R[]>;
47
+ traverse: <L extends Type, R extends Type, U extends Type>(arr: R[], f: (value: R) => Either<L, U>) => Either<L, U[]>;
48
+ fromNullable: <L extends Type, R extends Type>(value: R | null | undefined, leftValue: L) => Either<L, R>;
49
+ fromPredicate: <L extends Type, R extends Type>(value: R, predicate: (value: R) => boolean, leftValue: L) => Either<L, R>;
50
+ ap: <L extends Type, R extends Type, U extends Type>(eitherF: Either<L, (value: R) => U>, eitherV: Either<L, R>) => Either<L, U>;
51
+ fromPromise: <L, R>(promise: Promise<R>, onRejected: (reason: unknown) => L) => Promise<Either<L, R>>;
52
+ };
@@ -0,0 +1,9 @@
1
+ import { Either } from "./Either";
2
+ export type EitherT<L, R> = {
3
+ value: Promise<Either<L, R>>;
4
+ map<U>(f: (value: R) => U): EitherT<L, U>;
5
+ flatMap<U>(f: (value: R) => EitherT<L, U>): EitherT<L, U>;
6
+ mapLeft<U>(f: (value: L) => U): EitherT<U, R>;
7
+ fold<U>(onLeft: (error: L) => U, onRight: (value: R) => U): Promise<U>;
8
+ };
9
+ export declare function EitherT<L, R>(value: Promise<Either<L, R>>): EitherT<L, R>;
@@ -0,0 +1,6 @@
1
+ export declare const ParseError: (message?: string) => Error & {
2
+ name: "ParseError";
3
+ };
4
+ export type ParseError = Error & {
5
+ name: "ParseError";
6
+ };
@@ -0,0 +1,15 @@
1
+ export type SingleType = unknown;
2
+ export type ArrayType = SingleType[];
3
+ export type Type = SingleType | ArrayType;
4
+ export type AbstractFunctor<A extends Type> = {
5
+ map(f: (value: A) => Type): AbstractFunctor<Type>;
6
+ flatMap(f: (value: A) => AbstractFunctor<Type>): AbstractFunctor<Type>;
7
+ };
8
+ export type Functor<A extends Type> = AbstractFunctor<A> & {
9
+ map<B extends Type>(f: (value: A) => B): Functor<B>;
10
+ flatMap<B extends Type>(f: (value: A) => Functor<B>): Functor<B>;
11
+ };
12
+ export type ArrayFunctor<A extends ArrayType> = AbstractFunctor<A> & {
13
+ map<U extends ArrayType>(f: (value: A) => U): ArrayFunctor<U>;
14
+ flatMap<U extends ArrayType>(f: (value: A) => ArrayFunctor<U>): ArrayFunctor<U>;
15
+ };
@@ -0,0 +1,4 @@
1
+ export type Identity<T> = {
2
+ id: T;
3
+ isSame?: (other: Identity<T>) => boolean;
4
+ };
package/lib/index.d.ts ADDED
@@ -0,0 +1,21 @@
1
+ import { Functor, Type } from "./functor";
2
+ export type Traversable<A extends Type> = Functor<A> & {
3
+ get size(): number;
4
+ get isEmpty(): boolean;
5
+ contains(value: A): boolean;
6
+ reduce(f: (b: A, a: A) => A): A;
7
+ reduceRight(f: (b: A, a: A) => A): A;
8
+ foldLeft<B>(z: B): (op: (b: B, a: A) => B) => B;
9
+ foldRight<B>(z: B): (op: (a: A, b: B) => B) => B;
10
+ };
11
+ export * from "./either/Either";
12
+ export * from "./functor";
13
+ export * from "./identity/Identity";
14
+ export * from "./iterable";
15
+ export * from "./list/List";
16
+ export * from "./map/Map";
17
+ export * from "./option/Option";
18
+ export * from "./set/Set";
19
+ export * from "./try/Try";
20
+ export * from "./tuple/Tuple";
21
+ export * from "./typeable/Typeable";
@@ -0,0 +1,31 @@
1
+ import { Option } from "../option/Option";
2
+ import { Typeable } from "../typeable/Typeable";
3
+ import { _Iterable_ } from "./index";
4
+ export type Seq<A> = {
5
+ readonly length: number;
6
+ readonly [Symbol.iterator]: () => Iterator<A>;
7
+ map: <B>(f: (a: A) => B) => Seq<B>;
8
+ flatMap: <B>(f: (a: A) => _Iterable_<B>) => Seq<B>;
9
+ forEach: (f: (a: A) => void) => void;
10
+ count: (p: (x: A) => boolean) => number;
11
+ exists: (p: (a: A) => boolean) => boolean;
12
+ filter: (p: (a: A) => boolean) => Seq<A>;
13
+ filterNot: (p: (a: A) => boolean) => Seq<A>;
14
+ find: (p: (a: A) => boolean) => Option<A>;
15
+ readonly head: A;
16
+ readonly headOption: Option<A>;
17
+ readonly isEmpty: boolean;
18
+ readonly size: number;
19
+ toArray: () => A[];
20
+ reduce: (f: (prev: A, curr: A) => A) => A;
21
+ reduceRight: (f: (prev: A, curr: A) => A) => A;
22
+ foldLeft: <B>(z: B) => (op: (b: B, a: A) => B) => B;
23
+ foldRight: <B>(z: B) => (op: (a: A, b: B) => B) => B;
24
+ toString: () => string;
25
+ toValue: () => {
26
+ _tag: string;
27
+ value: A[];
28
+ };
29
+ } & _Iterable_<A> & Typeable<"Seq">;
30
+ export declare const createSeq: <A>(values?: Iterable<A> | _Iterable_<A>) => Seq<A>;
31
+ export declare const Seq: <A>(values?: Iterable<A> | _Iterable_<A>) => Seq<A>;
@@ -0,0 +1,22 @@
1
+ import { Functor, Type } from "../functor";
2
+ import { Option } from "../option/Option";
3
+ export type _Iterable_<A extends Type> = {
4
+ count(p: (x: A) => boolean): number;
5
+ find(p: (a: A) => boolean): Option<A>;
6
+ forEach(f: (a: A) => void): void;
7
+ exists(p: (a: A) => boolean): boolean;
8
+ filter(p: (a: A) => boolean): _Iterable_<A>;
9
+ filterNot(p: (a: A) => boolean): _Iterable_<A>;
10
+ reduce(f: (b: A, a: A) => A): A;
11
+ reduceRight(f: (b: A, a: A) => A): A;
12
+ foldLeft<B>(z: B): (op: (b: B, a: A) => B) => B;
13
+ foldRight<B>(z: B): (op: (a: A, b: B) => B) => B;
14
+ get head(): A;
15
+ get headOption(): Option<A>;
16
+ get isEmpty(): boolean;
17
+ map<B extends Type>(f: (a: A) => B): _Iterable_<B>;
18
+ flatMap<B extends Type>(f: (a: A) => _Iterable_<B> | Iterable<B>): _Iterable_<B>;
19
+ get size(): number;
20
+ toArray(): readonly A[];
21
+ } & Functor<A>;
22
+ export { Seq } from "./Seq";
@@ -0,0 +1,26 @@
1
+ import { Collection } from "../collections";
2
+ import { _Iterable_, Seq } from "../iterable";
3
+ import { Option } from "../option/Option";
4
+ import { Set } from "../set/Set";
5
+ import { Typeable } from "../typeable/Typeable";
6
+ export type List<A> = {
7
+ add: (item: A) => List<A>;
8
+ map: <B>(f: (a: A) => B) => List<B>;
9
+ flatMap: <B>(f: (a: A) => _Iterable_<B>) => List<B>;
10
+ remove: (value: A) => List<A>;
11
+ contains: (value: A) => boolean;
12
+ removeAt: (index: number) => List<A>;
13
+ get: (index: number) => Option<A>;
14
+ concat: (other: List<A>) => List<A>;
15
+ toList: () => List<A>;
16
+ toSet: () => Set<A>;
17
+ toString: () => string;
18
+ toValue: () => {
19
+ _tag: string;
20
+ value: A[];
21
+ };
22
+ } & Seq<A> & Typeable<"List">;
23
+ type InternalList<A> = List<A> & ArrayLike<A> & _Iterable_<A> & Collection<A>;
24
+ export declare const List: <A>(values?: Iterable<A> | _Iterable_<A>) => List<A>;
25
+ export declare const TestList: <A>(values?: Iterable<A> | _Iterable_<A>) => InternalList<A>;
26
+ export {};
@@ -0,0 +1,17 @@
1
+ import { Collection } from "../collections";
2
+ import { Traversable } from "../index";
3
+ import { _Iterable_ } from "../iterable";
4
+ import { Option } from "../option/Option";
5
+ import { Tuple } from "../tuple/Tuple";
6
+ type SafeTraversable<K, V> = Omit<Traversable<Tuple<[K, V]>>, "map" | "flatMap">;
7
+ export type Map<K, V> = {
8
+ add(item: Tuple<[K, V]>): Map<K, V>;
9
+ remove(value: K): Map<K, V>;
10
+ map<U>(f: (value: V) => U): Map<K, U>;
11
+ flatMap<K2, V2>(f: (entry: Tuple<[K, V]>) => _Iterable_<[K2, V2]>): Map<K2, V2>;
12
+ get(key: K): Option<V>;
13
+ getOrElse(key: K, defaultValue: V): V;
14
+ orElse(key: K, alternative: Option<V>): Option<V>;
15
+ } & SafeTraversable<K, V> & Collection<Tuple<[K, V]>>;
16
+ export declare const Map: <K, V>(entries?: readonly (readonly [K, V])[] | IterableIterator<[K, V]> | null) => Map<K, V>;
17
+ export {};
@@ -0,0 +1,2 @@
1
+ export type IESMap<K, V> = Map<K, V>;
2
+ export declare const ESMap: MapConstructor;
@@ -0,0 +1,30 @@
1
+ import { Functor, Type } from "../functor";
2
+ import { Either, List, Traversable } from "../index";
3
+ import { Typeable } from "../typeable/Typeable";
4
+ export type Option<T extends Type> = {
5
+ readonly _tag: "Some" | "None";
6
+ readonly value: T | undefined;
7
+ isEmpty: boolean;
8
+ get(): T;
9
+ getOrElse(defaultValue: T): T;
10
+ orElse(alternative: Option<T>): Option<T>;
11
+ map<U extends Type>(f: (value: T) => U): Option<U>;
12
+ filter(predicate: (value: T) => boolean): Option<T>;
13
+ flatMap<U extends Type>(f: (value: T) => Option<U>): Option<U>;
14
+ reduce<U>(f: (acc: U, value: T) => U): U;
15
+ reduceRight<U>(f: (acc: U, value: T) => U): U;
16
+ foldLeft<B>(z: B): (op: (b: B, a: T) => B) => B;
17
+ foldRight<B>(z: B): (op: (a: T, b: B) => B) => B;
18
+ toList(): List<T>;
19
+ contains(value: T): boolean;
20
+ size: number;
21
+ toEither<E>(left: E): Either<E, T>;
22
+ toString(): string;
23
+ toValue(): {
24
+ _tag: "Some" | "None";
25
+ value: T;
26
+ };
27
+ } & (Traversable<T> & Functor<T> & Typeable<"Some" | "None">);
28
+ export declare const Some: <T extends Type>(value: T) => Option<T>;
29
+ export declare const None: <T extends Type>() => Option<T>;
30
+ export declare const Option: <T extends Type>(value: T | null | undefined) => Option<T>;
@@ -0,0 +1,15 @@
1
+ export type SerializableTypes = "json" | "yaml";
2
+ type SerializationMethods<T> = {
3
+ json: {
4
+ toJSON(): string;
5
+ fromJSON(json: string): T;
6
+ };
7
+ yaml: {
8
+ toYAML(): string;
9
+ fromYAML(yaml: string): T;
10
+ };
11
+ };
12
+ export type Serializable<STypes extends SerializableTypes[], T> = T & (STypes extends [] ? NonNullable<unknown> : STypes extends [infer First, ...infer Rest] ? First extends keyof SerializationMethods<T> ? SerializationMethods<T>[First] & Serializable<Rest extends SerializableTypes[] ? Rest : [], T> : never : never);
13
+ export type SupportedSerializationTypes<T> = T extends Serializable<infer Types, never> ? Types : never;
14
+ export declare function createSerializable<STypes extends SerializableTypes[], T>(obj: T, serializationMethods: Pick<SerializationMethods<T>, STypes[number]>): Serializable<STypes, T>;
15
+ export {};
@@ -0,0 +1,15 @@
1
+ import { Collection } from "../collections";
2
+ import { _Iterable_ } from "../iterable";
3
+ import { List } from "../list/List";
4
+ export type Set<A> = {
5
+ add: (value: A) => Set<A>;
6
+ remove: (value: A) => Set<A>;
7
+ contains: (value: A) => boolean;
8
+ has: (value: A) => boolean;
9
+ map: <B>(f: (a: A) => B) => Set<B>;
10
+ flatMap: <B>(f: (a: A) => _Iterable_<B>) => Set<B>;
11
+ toList: () => List<A>;
12
+ toSet: () => Set<A>;
13
+ toString: () => string;
14
+ } & _Iterable_<A> & Collection<A>;
15
+ export declare const Set: <A>(iterable?: Iterable<A> | _Iterable_<A>) => Set<A>;
@@ -0,0 +1,2 @@
1
+ export type IESSet<T> = Set<T>;
2
+ export declare const ESSet: SetConstructor;
@@ -0,0 +1,18 @@
1
+ import { Either } from "../either/Either";
2
+ import { Typeable } from "../typeable/Typeable";
3
+ export type Try<T> = {
4
+ readonly _tag: "Success" | "Failure";
5
+ readonly value: T | undefined;
6
+ readonly error: Error | undefined;
7
+ isSuccess: () => boolean;
8
+ isFailure: () => boolean;
9
+ get: () => T;
10
+ getOrElse: (defaultValue: T) => T;
11
+ orElse: (alternative: Try<T>) => Try<T>;
12
+ orThrow: (error: Error) => T;
13
+ toEither: () => Either<Error, T>;
14
+ map: <U>(f: (value: T) => U) => Try<U>;
15
+ flatMap: <U>(f: (value: T) => Try<U>) => Try<U>;
16
+ toString: () => string;
17
+ } & Typeable<"Success" | "Failure">;
18
+ export declare const Try: <T>(f: () => T) => Try<T>;
@@ -0,0 +1,9 @@
1
+ import { ArrayFunctor, ArrayType } from "../functor";
2
+ export type Tuple<T extends ArrayType> = {
3
+ get<K extends number>(index: K): T[K];
4
+ map<U extends ArrayType>(f: (value: T) => U): Tuple<U>;
5
+ flatMap<U extends ArrayType>(f: (value: T) => Tuple<U>): Tuple<U>;
6
+ toArray(): T;
7
+ [Symbol.iterator](): Iterator<T[number]>;
8
+ } & ArrayFunctor<T>;
9
+ export declare const Tuple: <T extends ArrayType>(values: T) => Tuple<T>;
@@ -0,0 +1,4 @@
1
+ export declare function Typeable(type: string): {
2
+ readonly _tag: string;
3
+ };
4
+ export type Typeable<T extends string> = ReturnType<typeof Typeable>;
@@ -0,0 +1,3 @@
1
+ import { Either } from "../either/Either";
2
+ import { ParseError } from "../error/ParseError";
3
+ export declare const parseNumber: (input: string) => Either<ParseError, number>;
@@ -0,0 +1 @@
1
+ export declare const isIterable: <T>(value: unknown) => value is Iterable<T>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "functype",
3
- "version": "0.8.38",
3
+ "version": "0.8.40",
4
4
  "description": "A smallish functional library for TypeScript",
5
5
  "author": "jordan.burke@gmail.com",
6
6
  "license": "MIT",
@@ -11,27 +11,27 @@
11
11
  "homepage": "https://github.com/jordanburke/functype#readme",
12
12
  "url": "https://github.com/jordanburke/functype",
13
13
  "devDependencies": {
14
- "@eslint/compat": "^1.2.3",
14
+ "@eslint/compat": "^1.2.4",
15
15
  "@eslint/eslintrc": "^3.2.0",
16
- "@eslint/js": "^9.16.0",
16
+ "@eslint/js": "^9.17.0",
17
17
  "@types/jest": "29.5.14",
18
- "@types/node": "^22.10.1",
19
- "@typescript-eslint/eslint-plugin": "^8.17.0",
20
- "@typescript-eslint/parser": "^8.17.0",
18
+ "@types/node": "^22.10.2",
19
+ "@typescript-eslint/eslint-plugin": "^8.18.1",
20
+ "@typescript-eslint/parser": "^8.18.1",
21
21
  "cross-env": "^7.0.3",
22
- "eslint": "^9.16.0",
22
+ "eslint": "^9.17.0",
23
23
  "eslint-config-prettier": "^9.1.0",
24
24
  "eslint-plugin-import": "^2.31.0",
25
25
  "eslint-plugin-prettier": "^5.2.1",
26
26
  "eslint-plugin-simple-import-sort": "^12.1.1",
27
- "globals": "^15.13.0",
27
+ "globals": "^15.14.0",
28
28
  "jest": "^29.7.0",
29
29
  "prettier": "^3.4.2",
30
30
  "rimraf": "^6.0.1",
31
31
  "ts-jest": "^29.2.5",
32
32
  "ts-node": "^10.9.2",
33
33
  "tsup": "^8.3.5",
34
- "typescript": "5.6.3"
34
+ "typescript": "5.7.2"
35
35
  },
36
36
  "main": "./dist/index.js",
37
37
  "module": "./dist/index.mjs",
@@ -1 +0,0 @@
1
- import{a as B}from"./chunk-2I2NKDFN.mjs";import{a as U}from"./chunk-JF5YGNCO.mjs";import{a as v}from"./chunk-HD6YYUHO.mjs";import{a as R}from"./chunk-377WQNCB.mjs";import{a as g}from"./chunk-HA5XD5KC.mjs";import Q from"safe-stable-stringify";import S from"safe-stable-stringify";import j from"safe-stable-stringify";var m=e=>{let t=new g(e),r=l(t),o={...r,add:n=>m([...t,n]),remove:n=>{let f=new g(t);return f.delete(n),m(f)},contains:n=>t.has(n),has:n=>t.has(n),map:n=>m(r.map(n)),flatMap:n=>m(r.flatMap(n)),toList:()=>l(t),toSet:()=>o,toString:()=>`Set(${Array.from(t).toString()})`};return o},h=e=>m(e);var T=e=>{let t=Array.from(e||[]),r={_tag:"List",[Symbol.iterator]:()=>t[Symbol.iterator](),get size(){return t.length},get length(){return t.length},map:o=>T(t.map(o)),flatMap:o=>T(t.flatMap(n=>Array.from(o(n)))),flatMapAsync:async o=>{let n=await Promise.all(t.map(async f=>await o(f)));return T(n.flatMap(f=>Array.from(f)))},forEach:o=>t.forEach(o),count:o=>t.filter(o).length,exists:o=>t.some(o),filter:o=>T(t.filter(o)),filterNot:o=>T(t.filter(n=>!o(n))),find:o=>u(t.find(o)),get head(){return t[0]},get headOption(){return t.length>0?u(t[0]):L()},get isEmpty(){return t.length===0},toArray:()=>[...t],reduce:o=>t.reduce(o),reduceRight:o=>t.reduceRight(o),foldLeft:o=>n=>t.reduce(n,o),foldRight:o=>n=>t.reduceRight((f,x)=>n(x,f),o),remove:o=>T(t.filter(n=>n!==o)),removeAt:o=>T(t.slice(0,o).concat(t.slice(o+1))),add:o=>T([...t,o]),get:o=>u(t[o]),concat:o=>T([...t,...o.toArray()]),drop:o=>T(t.slice(o)),dropRight:o=>T(t.slice(0,-o)),dropWhile:o=>T(t.slice(t.findIndex(n=>!o(n)))),flatten:()=>T(t.flatMap(o=>Array.isArray(o)?o:[o])),toList:()=>r,toSet:()=>h(t),toString:()=>`List(${j(t)})`,toValue:()=>({_tag:"List",value:t})};return r},l=e=>T(e);var V=e=>({_tag:"Right",value:e,isLeft:()=>!1,isRight:()=>!0,getOrElse:t=>e,getOrThrow:()=>e,map:t=>i(t(e)),mapAsync:t=>t(e).then(r=>i(r)).catch(r=>Promise.resolve(s(r))),merge:t=>t.isLeft()?s(t.value):i([e,t.value]),flatMap:t=>t(e),flatMapAsync:t=>t(e).catch(r=>s(r)),toOption:()=>d(e),toList:()=>l([e]),toString:()=>`Right(${S(e)})`,[Symbol.iterator]:function*(){yield e},yield:function*(){yield e},traverse:t=>{let r=t(e);return r.isLeft()?s(r.value):i([r.value])},lazyMap:function*(t){yield i(t(e))},tap:t=>(t(e),i(e)),tapLeft:t=>i(e),mapLeft:t=>i(e),bimap:(t,r)=>i(r(e)),fold:(t,r)=>r(e),swap:()=>s(e),then:(t,r)=>Promise.resolve(e).then(t,r)}),w=e=>({_tag:"Left",value:e,isLeft:()=>!0,isRight:()=>!1,getOrElse:t=>t,getOrThrow:()=>{throw e},map:t=>s(e),mapAsync:t=>Promise.resolve(s(e)),merge:t=>s(e),flatMap:t=>s(e),flatMapAsync:t=>Promise.resolve(s(e)),toOption:()=>L(),toList:()=>l(),toString:()=>`Left(${S(e)})`,[Symbol.iterator]:function*(){},yield:function*(){},traverse:t=>s(e),lazyMap:function*(t){yield s(e)},tap:t=>s(e),tapLeft:t=>(t(e),s(e)),mapLeft:t=>s(t(e)),bimap:(t,r)=>s(t(e)),fold:(t,r)=>t(e),swap:()=>i(e),then:(t,r)=>Promise.reject(e).then(null,r)}),i=e=>V(e),s=e=>w(e),ye=e=>e.isRight(),Le=e=>e.isLeft(),de=(e,t)=>{try{return i(e())}catch(r){return s(t(r))}},W=e=>V(e);console.assert(W);var D=e=>w(e);console.assert(D);var ce=async(e,t)=>{try{let r=await e();return i(r)}catch(r){return s(t(r))}},H={sequence:e=>{let t=[];for(let r of e){if(r.isLeft())return s(r.value);t.push(r.value)}return i(t)},traverse:(e,t)=>H.sequence(e.map(t)),fromNullable:(e,t)=>e==null?s(t):i(e),fromPredicate:(e,t,r)=>t(e)?i(e):s(r),ap:(e,t)=>e.flatMap(r=>t.map(r)),fromPromise:async(e,t)=>{try{let r=await e;return i(r)}catch(r){return s(t(r))}}};var A=(e,t)=>{let r=v(e,t);return{...U("AppException"),...s(r)}},E=e=>({...U("AppResult"),...i(e)});function O(e,t=o=>o,r=()=>{}){try{return E(e())}catch(o){return A(t(o))}finally{r()}}O.success=e=>E(e);O.fail=e=>A(e);async function K(e,t=o=>o,r=async()=>{}){try{let o=await e();return E(o)}catch(o){let n=await t(o);return A(n)}finally{await r()}}K.success=e=>E(e);K.fail=e=>A(e);var y=e=>{let t={values:new R(e)},r=()=>Array.from(t.values.entries()).map(([a,p])=>B([a,p])),o=a=>y(new R(t.values).set(a.toArray()[0],a.toArray()[1]).entries()),n=a=>{let p=new R(t.values);return p.delete(a)?y(p.entries()):y(t.values.entries())},f=a=>t.values.get(a[0])===a[1],x=()=>t.values.size,P=a=>y(Array.from(t.values.entries()).map(([p,G])=>[p,a(G)])),_=a=>{let p=y(t.values.entries()).toList();return y(p.flatMap(a).toArray())},I=a=>l(r()).reduce(a),F=a=>l(r()).reduceRight(a),N=a=>p=>l(r()).foldLeft(a)(p),z=a=>p=>l(r()).foldRight(a)(p),C=a=>u(t.values.get(a)),$=(a,p)=>u(t.values.get(a)).getOrElse(p),q=()=>t.values.size===0;return{add:o,remove:n,contains:f,get size(){return x()},map:P,flatMap:_,reduce:I,reduceRight:F,foldLeft:N,foldRight:z,get:C,getOrElse:$,get isEmpty(){return q()},orElse:(a,p)=>u(t.values.get(a)).orElse(p),toList:()=>l(r()),toSet:()=>h(r()),toString:()=>`Map(${r().toString()})`}},Ve=e=>y(e);import M from"safe-stable-stringify";var k=e=>({_tag:"Success",value:e,error:void 0,isSuccess:()=>!0,isFailure:()=>!1,get:()=>e,getOrElse:t=>e,orElse:t=>k(e),orThrow:t=>e,toEither:()=>i(e),map:t=>J(()=>t(e)),flatMap:t=>t(e),toString:()=>`Success(${M(e)})`}),b=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:()=>s(e),map:t=>b(e),flatMap:t=>b(e),toString:()=>`Failure(${M(e)}))`}),J=e=>{try{return k(e())}catch(t){return b(t instanceof Error?t:new Error(String(t)))}};var d=e=>({_tag:"Some",value:e,isEmpty:!1,get:()=>e,getOrElse:()=>e,getOrThrow:()=>e,orElse:()=>d(e),orNull:()=>e,map:t=>d(t(e)),filter(t){return t(e)?d(e):c},fold:(t,r)=>r(e),flatMap:t=>t(e),flatMapAsync:async t=>await 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=>i(e),toString:()=>`Some(${Q(e)})`,toValue:()=>({_tag:"Some",value:e})}),c={_tag:"None",value:void 0,isEmpty:!0,get:()=>{throw new Error("Cannot call get() on None")},getOrElse:e=>e,getOrThrow(e){throw e},orElse:e=>e,orNull:()=>null,map:e=>c,filter(e){return c},flatMap:e=>c,flatMapAsync:async e=>c,reduce:()=>{},reduceRight:()=>{},fold:(e,t)=>e(),foldLeft:e=>()=>e,foldRight:e=>()=>e,toList:()=>l([]),contains:()=>!1,size:0,toEither:e=>s(e),toString:()=>"None",toValue:()=>({_tag:"None",value:void 0})},L=()=>c,u=e=>e!=null?d(e):L();u.from=e=>u(e);u.none=()=>L();export{d as a,L as b,u as c,h as d,l as e,i as f,s as g,ye as h,Le as i,de as j,W as k,D as l,ce as m,H as n,A as o,E as p,O as q,K as r,Ve as s,J as t};
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _chunkOXLZ6UIZjs = require('./chunk-OXLZ6UIZ.js');var _chunkSQWNJC6Ojs = require('./chunk-SQWNJC6O.js');var _chunk2U34DUZUjs = require('./chunk-2U34DUZU.js');var _chunk5VTXJIR3js = require('./chunk-5VTXJIR3.js');var _chunk3VJERXBPjs = require('./chunk-3VJERXBP.js');var _safestablestringify = require('safe-stable-stringify'); var _safestablestringify2 = _interopRequireDefault(_safestablestringify);var m=e=>{let t=new (0, _chunk3VJERXBPjs.a)(e),r=l(t),o={...r,add:n=>m([...t,n]),remove:n=>{let f=new (0, _chunk3VJERXBPjs.a)(t);return f.delete(n),m(f)},contains:n=>t.has(n),has:n=>t.has(n),map:n=>m(r.map(n)),flatMap:n=>m(r.flatMap(n)),toList:()=>l(t),toSet:()=>o,toString:()=>`Set(${Array.from(t).toString()})`};return o},h= exports.d =e=>m(e);var T=e=>{let t=Array.from(e||[]),r={_tag:"List",[Symbol.iterator]:()=>t[Symbol.iterator](),get size(){return t.length},get length(){return t.length},map:o=>T(t.map(o)),flatMap:o=>T(t.flatMap(n=>Array.from(o(n)))),flatMapAsync:async o=>{let n=await Promise.all(t.map(async f=>await o(f)));return T(n.flatMap(f=>Array.from(f)))},forEach:o=>t.forEach(o),count:o=>t.filter(o).length,exists:o=>t.some(o),filter:o=>T(t.filter(o)),filterNot:o=>T(t.filter(n=>!o(n))),find:o=>u(t.find(o)),get head(){return t[0]},get headOption(){return t.length>0?u(t[0]):L()},get isEmpty(){return t.length===0},toArray:()=>[...t],reduce:o=>t.reduce(o),reduceRight:o=>t.reduceRight(o),foldLeft:o=>n=>t.reduce(n,o),foldRight:o=>n=>t.reduceRight((f,x)=>n(x,f),o),remove:o=>T(t.filter(n=>n!==o)),removeAt:o=>T(t.slice(0,o).concat(t.slice(o+1))),add:o=>T([...t,o]),get:o=>u(t[o]),concat:o=>T([...t,...o.toArray()]),drop:o=>T(t.slice(o)),dropRight:o=>T(t.slice(0,-o)),dropWhile:o=>T(t.slice(t.findIndex(n=>!o(n)))),flatten:()=>T(t.flatMap(o=>Array.isArray(o)?o:[o])),toList:()=>r,toSet:()=>h(t),toString:()=>`List(${_safestablestringify2.default.call(void 0, t)})`,toValue:()=>({_tag:"List",value:t})};return r},l= exports.e =e=>T(e);var V=e=>({_tag:"Right",value:e,isLeft:()=>!1,isRight:()=>!0,getOrElse:t=>e,getOrThrow:()=>e,map:t=>i(t(e)),mapAsync:t=>t(e).then(r=>i(r)).catch(r=>Promise.resolve(s(r))),merge:t=>t.isLeft()?s(t.value):i([e,t.value]),flatMap:t=>t(e),flatMapAsync:t=>t(e).catch(r=>s(r)),toOption:()=>d(e),toList:()=>l([e]),toString:()=>`Right(${_safestablestringify2.default.call(void 0, e)})`,[Symbol.iterator]:function*(){yield e},yield:function*(){yield e},traverse:t=>{let r=t(e);return r.isLeft()?s(r.value):i([r.value])},lazyMap:function*(t){yield i(t(e))},tap:t=>(t(e),i(e)),tapLeft:t=>i(e),mapLeft:t=>i(e),bimap:(t,r)=>i(r(e)),fold:(t,r)=>r(e),swap:()=>s(e),then:(t,r)=>Promise.resolve(e).then(t,r)}),w=e=>({_tag:"Left",value:e,isLeft:()=>!0,isRight:()=>!1,getOrElse:t=>t,getOrThrow:()=>{throw e},map:t=>s(e),mapAsync:t=>Promise.resolve(s(e)),merge:t=>s(e),flatMap:t=>s(e),flatMapAsync:t=>Promise.resolve(s(e)),toOption:()=>L(),toList:()=>l(),toString:()=>`Left(${_safestablestringify2.default.call(void 0, e)})`,[Symbol.iterator]:function*(){},yield:function*(){},traverse:t=>s(e),lazyMap:function*(t){yield s(e)},tap:t=>s(e),tapLeft:t=>(t(e),s(e)),mapLeft:t=>s(t(e)),bimap:(t,r)=>s(t(e)),fold:(t,r)=>t(e),swap:()=>i(e),then:(t,r)=>Promise.reject(e).then(null,r)}),i= exports.f =e=>V(e),s= exports.g =e=>w(e),ye= exports.h =e=>e.isRight(),Le= exports.i =e=>e.isLeft(),de= exports.j =(e,t)=>{try{return i(e())}catch(r){return s(t(r))}},W= exports.k =e=>V(e);console.assert(W);var D=e=>w(e);console.assert(D);var ce=async(e,t)=>{try{let r=await e();return i(r)}catch(r){return s(t(r))}},H= exports.n ={sequence:e=>{let t=[];for(let r of e){if(r.isLeft())return s(r.value);t.push(r.value)}return i(t)},traverse:(e,t)=>H.sequence(e.map(t)),fromNullable:(e,t)=>e==null?s(t):i(e),fromPredicate:(e,t,r)=>t(e)?i(e):s(r),ap:(e,t)=>e.flatMap(r=>t.map(r)),fromPromise:async(e,t)=>{try{let r=await e;return i(r)}catch(r){return s(t(r))}}};var A=(e,t)=>{let r=_chunk2U34DUZUjs.a.call(void 0, e,t);return{..._chunkSQWNJC6Ojs.a.call(void 0, "AppException"),...s(r)}},E= exports.p =e=>({..._chunkSQWNJC6Ojs.a.call(void 0, "AppResult"),...i(e)});function O(e,t=o=>o,r=()=>{}){try{return E(e())}catch(o){return A(t(o))}finally{r()}}O.success=e=>E(e);O.fail=e=>A(e);async function K(e,t=o=>o,r=async()=>{}){try{let o=await e();return E(o)}catch(o){let n=await t(o);return A(n)}finally{await r()}}K.success=e=>E(e);K.fail=e=>A(e);var y=e=>{let t={values:new (0, _chunk5VTXJIR3js.a)(e)},r=()=>Array.from(t.values.entries()).map(([a,p])=>_chunkOXLZ6UIZjs.a.call(void 0, [a,p])),o=a=>y(new (0, _chunk5VTXJIR3js.a)(t.values).set(a.toArray()[0],a.toArray()[1]).entries()),n=a=>{let p=new (0, _chunk5VTXJIR3js.a)(t.values);return p.delete(a)?y(p.entries()):y(t.values.entries())},f=a=>t.values.get(a[0])===a[1],x=()=>t.values.size,P=a=>y(Array.from(t.values.entries()).map(([p,G])=>[p,a(G)])),_=a=>{let p=y(t.values.entries()).toList();return y(p.flatMap(a).toArray())},I=a=>l(r()).reduce(a),F=a=>l(r()).reduceRight(a),N=a=>p=>l(r()).foldLeft(a)(p),z=a=>p=>l(r()).foldRight(a)(p),C=a=>u(t.values.get(a)),$=(a,p)=>u(t.values.get(a)).getOrElse(p),q=()=>t.values.size===0;return{add:o,remove:n,contains:f,get size(){return x()},map:P,flatMap:_,reduce:I,reduceRight:F,foldLeft:N,foldRight:z,get:C,getOrElse:$,get isEmpty(){return q()},orElse:(a,p)=>u(t.values.get(a)).orElse(p),toList:()=>l(r()),toSet:()=>h(r()),toString:()=>`Map(${r().toString()})`}},Ve= exports.s =e=>y(e);var k=e=>({_tag:"Success",value:e,error:void 0,isSuccess:()=>!0,isFailure:()=>!1,get:()=>e,getOrElse:t=>e,orElse:t=>k(e),orThrow:t=>e,toEither:()=>i(e),map:t=>J(()=>t(e)),flatMap:t=>t(e),toString:()=>`Success(${_safestablestringify2.default.call(void 0, e)})`}),b=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:()=>s(e),map:t=>b(e),flatMap:t=>b(e),toString:()=>`Failure(${_safestablestringify2.default.call(void 0, e)}))`}),J= exports.t =e=>{try{return k(e())}catch(t){return b(t instanceof Error?t:new Error(String(t)))}};var d=e=>({_tag:"Some",value:e,isEmpty:!1,get:()=>e,getOrElse:()=>e,getOrThrow:()=>e,orElse:()=>d(e),orNull:()=>e,map:t=>d(t(e)),filter(t){return t(e)?d(e):c},fold:(t,r)=>r(e),flatMap:t=>t(e),flatMapAsync:async t=>await 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=>i(e),toString:()=>`Some(${_safestablestringify2.default.call(void 0, e)})`,toValue:()=>({_tag:"Some",value:e})}),c={_tag:"None",value:void 0,isEmpty:!0,get:()=>{throw new Error("Cannot call get() on None")},getOrElse:e=>e,getOrThrow(e){throw e},orElse:e=>e,orNull:()=>null,map:e=>c,filter(e){return c},flatMap:e=>c,flatMapAsync:async e=>c,reduce:()=>{},reduceRight:()=>{},fold:(e,t)=>e(),foldLeft:e=>()=>e,foldRight:e=>()=>e,toList:()=>l([]),contains:()=>!1,size:0,toEither:e=>s(e),toString:()=>"None",toValue:()=>({_tag:"None",value:void 0})},L= exports.b =()=>c,u= exports.c =e=>e!=null?d(e):L();u.from=e=>u(e);u.none=()=>L();exports.a = d; exports.b = L; exports.c = u; exports.d = h; exports.e = l; exports.f = i; exports.g = s; exports.h = ye; exports.i = Le; exports.j = de; exports.k = W; exports.l = D; exports.m = ce; exports.n = H; exports.o = A; exports.p = E; exports.q = O; exports.r = K; exports.s = Ve; exports.t = J;