functype 0.8.35 → 0.8.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +43 -43
- package/dist/chunk-4H62YQ42.mjs +0 -0
- package/dist/chunk-BOSMSYRM.mjs +1 -0
- package/dist/chunk-KJV27YM3.js +1 -0
- package/dist/chunk-WTWWDZY6.js +1 -0
- package/dist/collections/index.d.mts +1 -1
- package/dist/collections/index.d.ts +1 -1
- package/dist/core/task/Task.d.mts +1 -1
- package/dist/core/task/Task.d.ts +1 -1
- package/dist/core/task/Task.js +1 -1
- package/dist/core/task/Task.mjs +1 -1
- package/dist/either/Either.d.mts +1 -1
- package/dist/either/Either.d.ts +1 -1
- package/dist/either/Either.js +1 -1
- package/dist/either/Either.mjs +1 -1
- package/dist/functor/index.d.mts +4 -1
- package/dist/functor/index.d.ts +4 -1
- package/dist/{index-B6k3GVAd.d.ts → index-1xz2kaxi.d.ts} +53 -59
- package/dist/{index-Cwkc_dEO.d.mts → index-DvBKFQoa.d.mts} +53 -59
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/iterable/index.d.mts +1 -1
- package/dist/iterable/index.d.ts +1 -1
- package/dist/iterable/index.js +1 -1
- package/dist/iterable/index.mjs +1 -1
- package/dist/list/List.d.mts +2 -2
- package/dist/list/List.d.ts +2 -2
- package/dist/list/List.js +1 -1
- package/dist/list/List.mjs +1 -1
- package/dist/map/Map.d.mts +1 -1
- package/dist/map/Map.d.ts +1 -1
- package/dist/map/Map.js +1 -1
- package/dist/map/Map.mjs +1 -1
- package/dist/option/Option.d.mts +1 -1
- package/dist/option/Option.d.ts +1 -1
- package/dist/option/Option.js +1 -1
- package/dist/option/Option.mjs +1 -1
- package/dist/set/Set.d.mts +1 -1
- package/dist/set/Set.d.ts +1 -1
- package/dist/set/Set.js +1 -1
- package/dist/set/Set.mjs +1 -1
- package/dist/try/Try.d.mts +1 -1
- package/dist/try/Try.d.ts +1 -1
- package/dist/try/Try.js +1 -1
- package/dist/try/Try.mjs +1 -1
- package/dist/typeable/Typeable.d.mts +5 -4
- package/dist/typeable/Typeable.d.ts +5 -4
- package/dist/util/index.d.mts +1 -1
- package/dist/util/index.d.ts +1 -1
- package/dist/util/index.js +1 -1
- package/dist/util/index.mjs +1 -1
- package/dist/util/isIterable.js +1 -1
- package/dist/util/isIterable.mjs +1 -1
- package/package.json +10 -10
- package/dist/chunk-52OPFRS2.js +0 -1
- package/dist/chunk-BNNK42JC.js +0 -1
- package/dist/chunk-QBAH7SOA.mjs +0 -1
- package/dist/chunk-RRAIFS3D.mjs +0 -1
- package/dist/iterable/Seq.d.mts +0 -8
- package/dist/iterable/Seq.d.ts +0 -8
- package/dist/iterable/Seq.js +0 -1
- package/dist/iterable/Seq.mjs +0 -1
- package/lib/TaskPromise.d.ts +0 -3
- package/lib/collections/index.d.ts +0 -8
- package/lib/either/Either.d.ts +0 -52
- package/lib/either/EitherT.d.ts +0 -9
- package/lib/error/ParseError.d.ts +0 -6
- package/lib/functor/index.d.ts +0 -15
- package/lib/identity/Identity.d.ts +0 -4
- package/lib/index.d.ts +0 -21
- package/lib/iterable/Seq.d.ts +0 -31
- package/lib/iterable/index.d.ts +0 -22
- package/lib/list/List.d.ts +0 -26
- package/lib/map/Map.d.ts +0 -17
- package/lib/map/shim.d.ts +0 -2
- package/lib/option/Option.d.ts +0 -30
- package/lib/serializable/Serializable.d.ts +0 -15
- package/lib/set/Set.d.ts +0 -15
- package/lib/set/shim.d.ts +0 -2
- package/lib/try/Try.d.ts +0 -18
- package/lib/tuple/Tuple.d.ts +0 -9
- package/lib/typeable/Typeable.d.ts +0 -4
- package/lib/util/index.d.ts +0 -3
- package/lib/util/isIterable.d.ts +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
|
-

|
|
6
|
-
|
|
7
|
-
[](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
|
+

|
|
6
|
+
|
|
7
|
+
[](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
|
+
```
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
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{a as B}from"./chunk-2I2NKDFN.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:s=>m([...t,s]),remove:s=>{let f=new g(t);return f.delete(s),m(f)},contains:s=>t.has(s),has:s=>t.has(s),map:s=>m(r.map(s)),flatMap:s=>m(r.flatMap(s)),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(s=>Array.from(o(s)))),flatMapAsync:async o=>{let s=await Promise.all(t.map(async f=>await o(f)));return T(s.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(s=>!o(s))),find:o=>u(t.find(o)),get head(){return t[0]},get headOption(){return t.length>0?u(t[0]):y()},get isEmpty(){return t.length===0},toArray:()=>[...t],reduce:o=>t.reduce(o),reduceRight:o=>t.reduceRight(o),foldLeft:o=>s=>t.reduce(s,o),foldRight:o=>s=>t.reduceRight((f,x)=>s(x,f),o),remove:o=>T(t.filter(s=>s!==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(s=>!o(s)))),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(n(r))),merge:t=>t.isLeft()?n(t.value):i([e,t.value]),flatMap:t=>t(e),flatMapAsync:t=>t(e).catch(r=>n(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()?n(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:()=>n(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=>n(e),mapAsync:t=>Promise.resolve(n(e)),merge:t=>n(e),flatMap:t=>n(e),flatMapAsync:t=>Promise.resolve(n(e)),toOption:()=>y(),toList:()=>l(),toString:()=>`Left(${S(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:()=>i(e),then:(t,r)=>Promise.reject(e).then(null,r)}),i=e=>V(e),n=e=>w(e),Le=e=>e.isRight(),ye=e=>e.isLeft(),de=(e,t)=>{try{return i(e())}catch(r){return n(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 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 i(t)},traverse:(e,t)=>H.sequence(e.map(t)),fromNullable:(e,t)=>e==null?n(t):i(e),fromPredicate:(e,t,r)=>t(e)?i(e):n(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 n(t(r))}}};var A=(e,t)=>{let r=v(e,t);return{...U("AppException"),...n(r)}},E=e=>({...U("AppResult"),...i(e)});function O(e,t=r=>r){try{return E(e())}catch(r){return A(t(r))}}O.success=e=>E(e);O.fail=e=>A(e);async function K(e,t=r=>r){try{let r=await e();return E(r)}catch(r){let o=await t(r);return A(o)}}K.success=e=>E(e);K.fail=e=>A(e);var L=e=>{let t={values:new R(e)},r=()=>Array.from(t.values.entries()).map(([a,p])=>B([a,p])),o=a=>L(new R(t.values).set(a.toArray()[0],a.toArray()[1]).entries()),s=a=>{let p=new R(t.values);return p.delete(a)?L(p.entries()):L(t.values.entries())},f=a=>t.values.get(a[0])===a[1],x=()=>t.values.size,P=a=>L(Array.from(t.values.entries()).map(([p,G])=>[p,a(G)])),_=a=>{let p=L(t.values.entries()).toList();return L(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:s,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=>L(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:()=>n(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=>n(e),toString:()=>"None",toValue:()=>({_tag:"None",value:void 0})},y=()=>c,u=e=>e!=null?d(e):y();u.from=e=>u(e);u.none=()=>y();export{d as a,y as b,u as c,h as d,l as e,i as f,n as g,Le as h,ye 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};
|
|
@@ -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 m=e=>{let t=new (0, _chunk3VJERXBPjs.a)(e),r=l(t),o={...r,add:s=>m([...t,s]),remove:s=>{let f=new (0, _chunk3VJERXBPjs.a)(t);return f.delete(s),m(f)},contains:s=>t.has(s),has:s=>t.has(s),map:s=>m(r.map(s)),flatMap:s=>m(r.flatMap(s)),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(s=>Array.from(o(s)))),flatMapAsync:async o=>{let s=await Promise.all(t.map(async f=>await o(f)));return T(s.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(s=>!o(s))),find:o=>u(t.find(o)),get head(){return t[0]},get headOption(){return t.length>0?u(t[0]):y()},get isEmpty(){return t.length===0},toArray:()=>[...t],reduce:o=>t.reduce(o),reduceRight:o=>t.reduceRight(o),foldLeft:o=>s=>t.reduce(s,o),foldRight:o=>s=>t.reduceRight((f,x)=>s(x,f),o),remove:o=>T(t.filter(s=>s!==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(s=>!o(s)))),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(n(r))),merge:t=>t.isLeft()?n(t.value):i([e,t.value]),flatMap:t=>t(e),flatMapAsync:t=>t(e).catch(r=>n(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()?n(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:()=>n(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=>n(e),mapAsync:t=>Promise.resolve(n(e)),merge:t=>n(e),flatMap:t=>n(e),flatMapAsync:t=>Promise.resolve(n(e)),toOption:()=>y(),toList:()=>l(),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:()=>i(e),then:(t,r)=>Promise.reject(e).then(null,r)}),i= exports.f =e=>V(e),n= exports.g =e=>w(e),Le= exports.h =e=>e.isRight(),ye= exports.i =e=>e.isLeft(),de= exports.j =(e,t)=>{try{return i(e())}catch(r){return n(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 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 i(t)},traverse:(e,t)=>H.sequence(e.map(t)),fromNullable:(e,t)=>e==null?n(t):i(e),fromPredicate:(e,t,r)=>t(e)?i(e):n(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 n(t(r))}}};var A=(e,t)=>{let r=_chunk2U34DUZUjs.a.call(void 0, e,t);return{..._chunkSQWNJC6Ojs.a.call(void 0, "AppException"),...n(r)}},E= exports.p =e=>({..._chunkSQWNJC6Ojs.a.call(void 0, "AppResult"),...i(e)});function O(e,t=r=>r){try{return E(e())}catch(r){return A(t(r))}}O.success=e=>E(e);O.fail=e=>A(e);async function K(e,t=r=>r){try{let r=await e();return E(r)}catch(r){let o=await t(r);return A(o)}}K.success=e=>E(e);K.fail=e=>A(e);var L=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=>L(new (0, _chunk5VTXJIR3js.a)(t.values).set(a.toArray()[0],a.toArray()[1]).entries()),s=a=>{let p=new (0, _chunk5VTXJIR3js.a)(t.values);return p.delete(a)?L(p.entries()):L(t.values.entries())},f=a=>t.values.get(a[0])===a[1],x=()=>t.values.size,P=a=>L(Array.from(t.values.entries()).map(([p,G])=>[p,a(G)])),_=a=>{let p=L(t.values.entries()).toList();return L(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:s,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=>L(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:()=>n(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=>n(e),toString:()=>"None",toValue:()=>({_tag:"None",value:void 0})},y= exports.b =()=>c,u= exports.c =e=>e!=null?d(e):y();u.from=e=>u(e);u.none=()=>y();exports.a = d; exports.b = y; exports.c = u; exports.d = h; exports.e = l; exports.f = i; exports.g = n; exports.h = Le; exports.i = ye; 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;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { A as AppException,
|
|
1
|
+
export { A as AppException, h as AppResult, k as AsyncTask, j as Task } from '../../index-DvBKFQoa.mjs';
|
|
2
2
|
import '../error/Throwable.mjs';
|
|
3
3
|
import '../../functor/index.mjs';
|
|
4
4
|
import '../base/Base.mjs';
|
package/dist/core/task/Task.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { A as AppException,
|
|
1
|
+
export { A as AppException, h as AppResult, k as AsyncTask, j as Task } from '../../index-1xz2kaxi.js';
|
|
2
2
|
import '../error/Throwable.js';
|
|
3
3
|
import '../../functor/index.js';
|
|
4
4
|
import '../base/Base.js';
|
package/dist/core/task/Task.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkKJV27YM3js = require('../../chunk-KJV27YM3.js');require('../../chunk-SQWNJC6O.js');require('../../chunk-2U34DUZU.js');require('../../chunk-5VTXJIR3.js');require('../../chunk-3VJERXBP.js');require('../../chunk-OXLZ6UIZ.js');require('../../chunk-5O6YELD3.js');require('../../chunk-XORABVON.js');require('../../chunk-K3EKBPQE.js');require('../../chunk-WTWWDZY6.js');exports.AppException = _chunkKJV27YM3js.o; exports.AppResult = _chunkKJV27YM3js.p; exports.AsyncTask = _chunkKJV27YM3js.r; exports.Task = _chunkKJV27YM3js.q;
|
package/dist/core/task/Task.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{o as a,p as b,q as c,r as d}from"../../chunk-BOSMSYRM.mjs";import"../../chunk-JF5YGNCO.mjs";import"../../chunk-HD6YYUHO.mjs";import"../../chunk-377WQNCB.mjs";import"../../chunk-HA5XD5KC.mjs";import"../../chunk-2I2NKDFN.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};
|
package/dist/either/Either.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import '../functor/index.mjs';
|
|
2
|
-
export { E as Either,
|
|
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-DvBKFQoa.mjs';
|
|
3
3
|
import '../typeable/Typeable.mjs';
|
|
4
4
|
import '../core/base/Base.mjs';
|
|
5
5
|
import '../core/error/Throwable.mjs';
|
package/dist/either/Either.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import '../functor/index.js';
|
|
2
|
-
export { E as Either,
|
|
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-1xz2kaxi.js';
|
|
3
3
|
import '../typeable/Typeable.js';
|
|
4
4
|
import '../core/base/Base.js';
|
|
5
5
|
import '../core/error/Throwable.js';
|
package/dist/either/Either.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkKJV27YM3js = require('../chunk-KJV27YM3.js');require('../chunk-SQWNJC6O.js');require('../chunk-2U34DUZU.js');require('../chunk-5VTXJIR3.js');require('../chunk-3VJERXBP.js');require('../chunk-OXLZ6UIZ.js');require('../chunk-5O6YELD3.js');require('../chunk-XORABVON.js');require('../chunk-K3EKBPQE.js');require('../chunk-WTWWDZY6.js');exports.Either = _chunkKJV27YM3js.n; exports.Left = _chunkKJV27YM3js.g; exports.Right = _chunkKJV27YM3js.f; exports.TypeCheckLeft = _chunkKJV27YM3js.l; exports.TypeCheckRight = _chunkKJV27YM3js.k; exports.isLeft = _chunkKJV27YM3js.i; exports.isRight = _chunkKJV27YM3js.h; exports.tryCatch = _chunkKJV27YM3js.j; exports.tryCatchAsync = _chunkKJV27YM3js.m;
|
package/dist/either/Either.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
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-BOSMSYRM.mjs";import"../chunk-JF5YGNCO.mjs";import"../chunk-HD6YYUHO.mjs";import"../chunk-377WQNCB.mjs";import"../chunk-HA5XD5KC.mjs";import"../chunk-2I2NKDFN.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};
|
package/dist/functor/index.d.mts
CHANGED
|
@@ -9,9 +9,12 @@ type Functor<A extends Type> = AbstractFunctor<A> & {
|
|
|
9
9
|
map<B extends Type>(f: (value: A) => B): Functor<B>;
|
|
10
10
|
flatMap<B extends Type>(f: (value: A) => Functor<B>): Functor<B>;
|
|
11
11
|
};
|
|
12
|
+
type AsyncFunctor<A extends Type> = {
|
|
13
|
+
flatMapAsync(f: (value: A) => PromiseLike<AsyncFunctor<A>>): PromiseLike<AsyncFunctor<A>>;
|
|
14
|
+
};
|
|
12
15
|
type ArrayFunctor<A extends ArrayType> = AbstractFunctor<A> & {
|
|
13
16
|
map<U extends ArrayType>(f: (value: A) => U): ArrayFunctor<U>;
|
|
14
17
|
flatMap<U extends ArrayType>(f: (value: A) => ArrayFunctor<U>): ArrayFunctor<U>;
|
|
15
18
|
};
|
|
16
19
|
|
|
17
|
-
export type { AbstractFunctor, ArrayFunctor, ArrayType, Functor, SingleType, Type };
|
|
20
|
+
export type { AbstractFunctor, ArrayFunctor, ArrayType, AsyncFunctor, Functor, SingleType, Type };
|
package/dist/functor/index.d.ts
CHANGED
|
@@ -9,9 +9,12 @@ type Functor<A extends Type> = AbstractFunctor<A> & {
|
|
|
9
9
|
map<B extends Type>(f: (value: A) => B): Functor<B>;
|
|
10
10
|
flatMap<B extends Type>(f: (value: A) => Functor<B>): Functor<B>;
|
|
11
11
|
};
|
|
12
|
+
type AsyncFunctor<A extends Type> = {
|
|
13
|
+
flatMapAsync(f: (value: A) => PromiseLike<AsyncFunctor<A>>): PromiseLike<AsyncFunctor<A>>;
|
|
14
|
+
};
|
|
12
15
|
type ArrayFunctor<A extends ArrayType> = AbstractFunctor<A> & {
|
|
13
16
|
map<U extends ArrayType>(f: (value: A) => U): ArrayFunctor<U>;
|
|
14
17
|
flatMap<U extends ArrayType>(f: (value: A) => ArrayFunctor<U>): ArrayFunctor<U>;
|
|
15
18
|
};
|
|
16
19
|
|
|
17
|
-
export type { AbstractFunctor, ArrayFunctor, ArrayType, Functor, SingleType, Type };
|
|
20
|
+
export type { AbstractFunctor, ArrayFunctor, ArrayType, AsyncFunctor, Functor, SingleType, Type };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Type, Functor } from './functor/index.js';
|
|
1
|
+
import { Type, Functor, AsyncFunctor } from './functor/index.js';
|
|
2
2
|
import './core/base/Base.js';
|
|
3
3
|
import { Throwable } from './core/error/Throwable.js';
|
|
4
4
|
import './identity/Identity.js';
|
|
@@ -16,10 +16,11 @@ type Option<T extends Type> = {
|
|
|
16
16
|
getOrElse(defaultValue: T): T;
|
|
17
17
|
getOrThrow(error: Error): T;
|
|
18
18
|
orElse(alternative: Option<T>): Option<T>;
|
|
19
|
-
|
|
19
|
+
orNull(): T | null;
|
|
20
20
|
map<U extends Type>(f: (value: T) => U): Option<U>;
|
|
21
21
|
filter(predicate: (value: T) => boolean): Option<T>;
|
|
22
22
|
flatMap<U extends Type>(f: (value: T) => Option<U>): Option<U>;
|
|
23
|
+
flatMapAsync<U extends Type>(f: (value: T) => Promise<Option<U>>): Promise<Option<U>>;
|
|
23
24
|
reduce<U>(f: (acc: U, value: T) => U): U;
|
|
24
25
|
reduceRight<U>(f: (acc: U, value: T) => U): U;
|
|
25
26
|
fold<U>(onNone: () => U, onSome: (value: T) => U): U;
|
|
@@ -34,49 +35,24 @@ type Option<T extends Type> = {
|
|
|
34
35
|
_tag: "Some" | "None";
|
|
35
36
|
value: T;
|
|
36
37
|
};
|
|
37
|
-
} & (Traversable<T> & Functor<T> & Typeable<"Some" | "None"> & Valuable<T>);
|
|
38
|
+
} & (Traversable<T> & Functor<T> & Typeable<"Some" | "None"> & Valuable<T> & AsyncFunctor<T>);
|
|
38
39
|
declare const Option: {
|
|
39
40
|
<T extends Type>(value: T | null | undefined): Option<T>;
|
|
40
41
|
from<T>(value: T): Option<T>;
|
|
41
42
|
none<T>(): Option<T>;
|
|
42
43
|
};
|
|
43
44
|
|
|
44
|
-
|
|
45
|
-
type Seq<A> = {
|
|
46
|
-
readonly length: number;
|
|
47
|
-
readonly [Symbol.iterator]: () => Iterator<A>;
|
|
48
|
-
map: <B>(f: (a: A) => B) => Seq<B>;
|
|
49
|
-
flatMap: <B>(f: (a: A) => _Iterable_<B>) => Seq<B>;
|
|
50
|
-
forEach: (f: (a: A) => void) => void;
|
|
51
|
-
count: (p: (x: A) => boolean) => number;
|
|
52
|
-
exists: (p: (a: A) => boolean) => boolean;
|
|
53
|
-
filter: (p: (a: A) => boolean) => Seq<A>;
|
|
54
|
-
filterNot: (p: (a: A) => boolean) => Seq<A>;
|
|
55
|
-
find: (p: (a: A) => boolean) => Option<A>;
|
|
56
|
-
readonly head: A;
|
|
57
|
-
readonly headOption: Option<A>;
|
|
58
|
-
readonly isEmpty: boolean;
|
|
59
|
-
readonly size: number;
|
|
60
|
-
toArray: () => A[];
|
|
61
|
-
reduce: (f: (prev: A, curr: A) => A) => A;
|
|
62
|
-
reduceRight: (f: (prev: A, curr: A) => A) => A;
|
|
63
|
-
foldLeft: <B>(z: B) => (op: (b: B, a: A) => B) => B;
|
|
64
|
-
foldRight: <B>(z: B) => (op: (a: A, b: B) => B) => B;
|
|
65
|
-
toString: () => string;
|
|
66
|
-
toValue: () => {
|
|
67
|
-
_tag: string;
|
|
68
|
-
value: A[];
|
|
69
|
-
};
|
|
70
|
-
} & _Iterable_<A> & Typeable<"Seq">;
|
|
71
|
-
declare const Seq: <A>(values?: Iterable<A> | _Iterable_<A>) => Seq<A>;
|
|
72
|
-
|
|
73
|
-
type _Iterable_<A extends Type> = {
|
|
45
|
+
type IterableType<A extends Type> = {
|
|
74
46
|
count(p: (x: A) => boolean): number;
|
|
75
47
|
find(p: (a: A) => boolean): Option<A>;
|
|
76
48
|
forEach(f: (a: A) => void): void;
|
|
49
|
+
drop(n: number): IterableType<A>;
|
|
50
|
+
dropRight(n: number): IterableType<A>;
|
|
51
|
+
dropWhile(p: (a: A) => boolean): IterableType<A>;
|
|
77
52
|
exists(p: (a: A) => boolean): boolean;
|
|
78
|
-
filter(p: (a: A) => boolean):
|
|
79
|
-
filterNot(p: (a: A) => boolean):
|
|
53
|
+
filter(p: (a: A) => boolean): IterableType<A>;
|
|
54
|
+
filterNot(p: (a: A) => boolean): IterableType<A>;
|
|
55
|
+
flatten<B>(): IterableType<B>;
|
|
80
56
|
reduce(f: (b: A, a: A) => A): A;
|
|
81
57
|
reduceRight(f: (b: A, a: A) => A): A;
|
|
82
58
|
foldLeft<B>(z: B): (op: (b: B, a: A) => B) => B;
|
|
@@ -84,11 +60,22 @@ type _Iterable_<A extends Type> = {
|
|
|
84
60
|
get head(): A;
|
|
85
61
|
get headOption(): Option<A>;
|
|
86
62
|
get isEmpty(): boolean;
|
|
87
|
-
map<B extends Type>(f: (a: A) => B):
|
|
88
|
-
flatMap<B extends Type>(f: (a: A) =>
|
|
63
|
+
map<B extends Type>(f: (a: A) => B): IterableType<B>;
|
|
64
|
+
flatMap<B extends Type>(f: (a: A) => IterableType<B>): IterableType<B>;
|
|
89
65
|
get size(): number;
|
|
90
66
|
toArray(): readonly A[];
|
|
91
|
-
|
|
67
|
+
toValue: () => {
|
|
68
|
+
_tag: string;
|
|
69
|
+
value: A[];
|
|
70
|
+
};
|
|
71
|
+
} & Iterable<A> & Functor<A> & AsyncFunctor<A>;
|
|
72
|
+
|
|
73
|
+
type Converters<A> = {
|
|
74
|
+
toList(): List<A>;
|
|
75
|
+
toSet(): Set<A>;
|
|
76
|
+
toString(): string;
|
|
77
|
+
};
|
|
78
|
+
type Collection<A> = Converters<A>;
|
|
92
79
|
|
|
93
80
|
type Set<A> = {
|
|
94
81
|
add: (value: A) => Set<A>;
|
|
@@ -96,28 +83,36 @@ type Set<A> = {
|
|
|
96
83
|
contains: (value: A) => boolean;
|
|
97
84
|
has: (value: A) => boolean;
|
|
98
85
|
map: <B>(f: (a: A) => B) => Set<B>;
|
|
99
|
-
flatMap: <B>(f: (a: A) =>
|
|
86
|
+
flatMap: <B>(f: (a: A) => IterableType<B>) => Set<B>;
|
|
100
87
|
toList: () => List<A>;
|
|
101
88
|
toSet: () => Set<A>;
|
|
102
89
|
toString: () => string;
|
|
103
|
-
} &
|
|
104
|
-
declare const Set: <A>(iterable?: Iterable<A> |
|
|
105
|
-
|
|
106
|
-
type Converters<A> = {
|
|
107
|
-
toList(): List<A>;
|
|
108
|
-
toSet(): Set<A>;
|
|
109
|
-
toString(): string;
|
|
110
|
-
};
|
|
111
|
-
type Collection<A> = Converters<A>;
|
|
90
|
+
} & IterableType<A> & Collection<A>;
|
|
91
|
+
declare const Set: <A>(iterable?: Iterable<A> | IterableType<A>) => Set<A>;
|
|
112
92
|
|
|
113
|
-
type InternalList<A> = List<A> & ArrayLike<A> & _Iterable_<A> & Collection<A>;
|
|
114
93
|
type List<A> = {
|
|
115
|
-
|
|
94
|
+
readonly length: number;
|
|
95
|
+
readonly [Symbol.iterator]: () => Iterator<A>;
|
|
116
96
|
map: <B>(f: (a: A) => B) => List<B>;
|
|
117
|
-
flatMap: <B>(f: (a: A) =>
|
|
97
|
+
flatMap: <B>(f: (a: A) => IterableType<B>) => List<B>;
|
|
98
|
+
flatMapAsync: <B>(f: (a: A) => PromiseLike<IterableType<B>>) => PromiseLike<List<B>>;
|
|
99
|
+
forEach: (f: (a: A) => void) => void;
|
|
100
|
+
count: (p: (x: A) => boolean) => number;
|
|
101
|
+
exists: (p: (a: A) => boolean) => boolean;
|
|
102
|
+
filter: (p: (a: A) => boolean) => List<A>;
|
|
103
|
+
filterNot: (p: (a: A) => boolean) => List<A>;
|
|
104
|
+
find: (p: (a: A) => boolean) => Option<A>;
|
|
105
|
+
readonly head: A;
|
|
106
|
+
readonly headOption: Option<A>;
|
|
107
|
+
readonly isEmpty: boolean;
|
|
108
|
+
toArray: () => A[];
|
|
109
|
+
reduce: (f: (prev: A, curr: A) => A) => A;
|
|
110
|
+
reduceRight: (f: (prev: A, curr: A) => A) => A;
|
|
111
|
+
foldLeft: <B>(z: B) => (op: (b: B, a: A) => B) => B;
|
|
112
|
+
foldRight: <B>(z: B) => (op: (a: A, b: B) => B) => B;
|
|
118
113
|
remove: (value: A) => List<A>;
|
|
119
|
-
contains: (value: A) => boolean;
|
|
120
114
|
removeAt: (index: number) => List<A>;
|
|
115
|
+
add: (item: A) => List<A>;
|
|
121
116
|
get: (index: number) => Option<A>;
|
|
122
117
|
concat: (other: List<A>) => List<A>;
|
|
123
118
|
toList: () => List<A>;
|
|
@@ -127,11 +122,10 @@ type List<A> = {
|
|
|
127
122
|
_tag: string;
|
|
128
123
|
value: A[];
|
|
129
124
|
};
|
|
130
|
-
} &
|
|
131
|
-
declare const List: <A>(values?: Iterable<A>
|
|
132
|
-
declare const TestList: <A>(values?: Iterable<A> | _Iterable_<A>) => InternalList<A>;
|
|
125
|
+
} & IterableType<A> & Typeable<"List"> & AsyncFunctor<A>;
|
|
126
|
+
declare const List: <A>(values?: Iterable<A>) => List<A>;
|
|
133
127
|
|
|
134
|
-
type TestEither<L extends Type, R extends Type> = Either<L, R> & Functor<R>;
|
|
128
|
+
type TestEither<L extends Type, R extends Type> = Either<L, R> & Functor<R> & AsyncFunctor<R>;
|
|
135
129
|
declare const Right: <L extends Type, R extends Type>(value: R) => Either<L, R>;
|
|
136
130
|
declare const Left: <L extends Type, R extends Type>(value: L) => Either<L, R>;
|
|
137
131
|
declare const isRight: <L extends Type, R extends Type>(either: Either<L, R>) => either is Either<L, R> & {
|
|
@@ -169,7 +163,7 @@ type Either<L extends Type, R extends Type> = {
|
|
|
169
163
|
bimap: <L2 extends Type, R2 extends Type>(fl: (value: L) => L2, fr: (value: R) => R2) => Either<L2, R2>;
|
|
170
164
|
fold: <T extends Type>(onLeft: (value: L) => T, onRight: (value: R) => T) => T;
|
|
171
165
|
swap: () => Either<R, L>;
|
|
172
|
-
} & Typeable<"Left" | "Right"> & PromiseLike<R>;
|
|
166
|
+
} & Typeable<"Left" | "Right"> & PromiseLike<R> & AsyncFunctor<R>;
|
|
173
167
|
declare const Either: {
|
|
174
168
|
sequence: <L extends Type, R extends Type>(eithers: Either<L, R>[]) => Either<L, R[]>;
|
|
175
169
|
traverse: <L extends Type, R extends Type, U extends Type>(arr: R[], f: (value: R) => Either<L, U>) => Either<L, U[]>;
|
|
@@ -207,7 +201,7 @@ type Map<K, V> = {
|
|
|
207
201
|
add(item: Tuple<[K, V]>): Map<K, V>;
|
|
208
202
|
remove(value: K): Map<K, V>;
|
|
209
203
|
map<U>(f: (value: V) => U): Map<K, U>;
|
|
210
|
-
flatMap<K2, V2>(f: (entry: Tuple<[K, V]>) =>
|
|
204
|
+
flatMap<K2, V2>(f: (entry: Tuple<[K, V]>) => IterableType<[K2, V2]>): Map<K2, V2>;
|
|
211
205
|
get(key: K): Option<V>;
|
|
212
206
|
getOrElse(key: K, defaultValue: V): V;
|
|
213
207
|
orElse(key: K, alternative: Option<V>): Option<V>;
|
|
@@ -241,4 +235,4 @@ type Traversable<A extends Type> = Functor<A> & {
|
|
|
241
235
|
foldRight<B>(z: B): (op: (a: A, b: B) => B) => B;
|
|
242
236
|
};
|
|
243
237
|
|
|
244
|
-
export { AppException as A, type Converters as C, Either as E, List as L, Map as M, None as N, Option as O, Right as R, Some as S,
|
|
238
|
+
export { AppException as A, type Converters as C, Either as E, type IterableType as I, List as L, Map as M, None as N, Option as O, Right as R, Some as S, type TestEither as T, type Collection as a, Set as b, Left as c, isLeft as d, TypeCheckRight as e, TypeCheckLeft as f, tryCatchAsync as g, AppResult as h, isRight as i, Task as j, AsyncTask as k, Try as l, type Traversable as m, tryCatch as t };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Type, Functor } from './functor/index.mjs';
|
|
1
|
+
import { Type, Functor, AsyncFunctor } from './functor/index.mjs';
|
|
2
2
|
import './core/base/Base.mjs';
|
|
3
3
|
import { Throwable } from './core/error/Throwable.mjs';
|
|
4
4
|
import './identity/Identity.mjs';
|
|
@@ -16,10 +16,11 @@ type Option<T extends Type> = {
|
|
|
16
16
|
getOrElse(defaultValue: T): T;
|
|
17
17
|
getOrThrow(error: Error): T;
|
|
18
18
|
orElse(alternative: Option<T>): Option<T>;
|
|
19
|
-
|
|
19
|
+
orNull(): T | null;
|
|
20
20
|
map<U extends Type>(f: (value: T) => U): Option<U>;
|
|
21
21
|
filter(predicate: (value: T) => boolean): Option<T>;
|
|
22
22
|
flatMap<U extends Type>(f: (value: T) => Option<U>): Option<U>;
|
|
23
|
+
flatMapAsync<U extends Type>(f: (value: T) => Promise<Option<U>>): Promise<Option<U>>;
|
|
23
24
|
reduce<U>(f: (acc: U, value: T) => U): U;
|
|
24
25
|
reduceRight<U>(f: (acc: U, value: T) => U): U;
|
|
25
26
|
fold<U>(onNone: () => U, onSome: (value: T) => U): U;
|
|
@@ -34,49 +35,24 @@ type Option<T extends Type> = {
|
|
|
34
35
|
_tag: "Some" | "None";
|
|
35
36
|
value: T;
|
|
36
37
|
};
|
|
37
|
-
} & (Traversable<T> & Functor<T> & Typeable<"Some" | "None"> & Valuable<T>);
|
|
38
|
+
} & (Traversable<T> & Functor<T> & Typeable<"Some" | "None"> & Valuable<T> & AsyncFunctor<T>);
|
|
38
39
|
declare const Option: {
|
|
39
40
|
<T extends Type>(value: T | null | undefined): Option<T>;
|
|
40
41
|
from<T>(value: T): Option<T>;
|
|
41
42
|
none<T>(): Option<T>;
|
|
42
43
|
};
|
|
43
44
|
|
|
44
|
-
|
|
45
|
-
type Seq<A> = {
|
|
46
|
-
readonly length: number;
|
|
47
|
-
readonly [Symbol.iterator]: () => Iterator<A>;
|
|
48
|
-
map: <B>(f: (a: A) => B) => Seq<B>;
|
|
49
|
-
flatMap: <B>(f: (a: A) => _Iterable_<B>) => Seq<B>;
|
|
50
|
-
forEach: (f: (a: A) => void) => void;
|
|
51
|
-
count: (p: (x: A) => boolean) => number;
|
|
52
|
-
exists: (p: (a: A) => boolean) => boolean;
|
|
53
|
-
filter: (p: (a: A) => boolean) => Seq<A>;
|
|
54
|
-
filterNot: (p: (a: A) => boolean) => Seq<A>;
|
|
55
|
-
find: (p: (a: A) => boolean) => Option<A>;
|
|
56
|
-
readonly head: A;
|
|
57
|
-
readonly headOption: Option<A>;
|
|
58
|
-
readonly isEmpty: boolean;
|
|
59
|
-
readonly size: number;
|
|
60
|
-
toArray: () => A[];
|
|
61
|
-
reduce: (f: (prev: A, curr: A) => A) => A;
|
|
62
|
-
reduceRight: (f: (prev: A, curr: A) => A) => A;
|
|
63
|
-
foldLeft: <B>(z: B) => (op: (b: B, a: A) => B) => B;
|
|
64
|
-
foldRight: <B>(z: B) => (op: (a: A, b: B) => B) => B;
|
|
65
|
-
toString: () => string;
|
|
66
|
-
toValue: () => {
|
|
67
|
-
_tag: string;
|
|
68
|
-
value: A[];
|
|
69
|
-
};
|
|
70
|
-
} & _Iterable_<A> & Typeable<"Seq">;
|
|
71
|
-
declare const Seq: <A>(values?: Iterable<A> | _Iterable_<A>) => Seq<A>;
|
|
72
|
-
|
|
73
|
-
type _Iterable_<A extends Type> = {
|
|
45
|
+
type IterableType<A extends Type> = {
|
|
74
46
|
count(p: (x: A) => boolean): number;
|
|
75
47
|
find(p: (a: A) => boolean): Option<A>;
|
|
76
48
|
forEach(f: (a: A) => void): void;
|
|
49
|
+
drop(n: number): IterableType<A>;
|
|
50
|
+
dropRight(n: number): IterableType<A>;
|
|
51
|
+
dropWhile(p: (a: A) => boolean): IterableType<A>;
|
|
77
52
|
exists(p: (a: A) => boolean): boolean;
|
|
78
|
-
filter(p: (a: A) => boolean):
|
|
79
|
-
filterNot(p: (a: A) => boolean):
|
|
53
|
+
filter(p: (a: A) => boolean): IterableType<A>;
|
|
54
|
+
filterNot(p: (a: A) => boolean): IterableType<A>;
|
|
55
|
+
flatten<B>(): IterableType<B>;
|
|
80
56
|
reduce(f: (b: A, a: A) => A): A;
|
|
81
57
|
reduceRight(f: (b: A, a: A) => A): A;
|
|
82
58
|
foldLeft<B>(z: B): (op: (b: B, a: A) => B) => B;
|
|
@@ -84,11 +60,22 @@ type _Iterable_<A extends Type> = {
|
|
|
84
60
|
get head(): A;
|
|
85
61
|
get headOption(): Option<A>;
|
|
86
62
|
get isEmpty(): boolean;
|
|
87
|
-
map<B extends Type>(f: (a: A) => B):
|
|
88
|
-
flatMap<B extends Type>(f: (a: A) =>
|
|
63
|
+
map<B extends Type>(f: (a: A) => B): IterableType<B>;
|
|
64
|
+
flatMap<B extends Type>(f: (a: A) => IterableType<B>): IterableType<B>;
|
|
89
65
|
get size(): number;
|
|
90
66
|
toArray(): readonly A[];
|
|
91
|
-
|
|
67
|
+
toValue: () => {
|
|
68
|
+
_tag: string;
|
|
69
|
+
value: A[];
|
|
70
|
+
};
|
|
71
|
+
} & Iterable<A> & Functor<A> & AsyncFunctor<A>;
|
|
72
|
+
|
|
73
|
+
type Converters<A> = {
|
|
74
|
+
toList(): List<A>;
|
|
75
|
+
toSet(): Set<A>;
|
|
76
|
+
toString(): string;
|
|
77
|
+
};
|
|
78
|
+
type Collection<A> = Converters<A>;
|
|
92
79
|
|
|
93
80
|
type Set<A> = {
|
|
94
81
|
add: (value: A) => Set<A>;
|
|
@@ -96,28 +83,36 @@ type Set<A> = {
|
|
|
96
83
|
contains: (value: A) => boolean;
|
|
97
84
|
has: (value: A) => boolean;
|
|
98
85
|
map: <B>(f: (a: A) => B) => Set<B>;
|
|
99
|
-
flatMap: <B>(f: (a: A) =>
|
|
86
|
+
flatMap: <B>(f: (a: A) => IterableType<B>) => Set<B>;
|
|
100
87
|
toList: () => List<A>;
|
|
101
88
|
toSet: () => Set<A>;
|
|
102
89
|
toString: () => string;
|
|
103
|
-
} &
|
|
104
|
-
declare const Set: <A>(iterable?: Iterable<A> |
|
|
105
|
-
|
|
106
|
-
type Converters<A> = {
|
|
107
|
-
toList(): List<A>;
|
|
108
|
-
toSet(): Set<A>;
|
|
109
|
-
toString(): string;
|
|
110
|
-
};
|
|
111
|
-
type Collection<A> = Converters<A>;
|
|
90
|
+
} & IterableType<A> & Collection<A>;
|
|
91
|
+
declare const Set: <A>(iterable?: Iterable<A> | IterableType<A>) => Set<A>;
|
|
112
92
|
|
|
113
|
-
type InternalList<A> = List<A> & ArrayLike<A> & _Iterable_<A> & Collection<A>;
|
|
114
93
|
type List<A> = {
|
|
115
|
-
|
|
94
|
+
readonly length: number;
|
|
95
|
+
readonly [Symbol.iterator]: () => Iterator<A>;
|
|
116
96
|
map: <B>(f: (a: A) => B) => List<B>;
|
|
117
|
-
flatMap: <B>(f: (a: A) =>
|
|
97
|
+
flatMap: <B>(f: (a: A) => IterableType<B>) => List<B>;
|
|
98
|
+
flatMapAsync: <B>(f: (a: A) => PromiseLike<IterableType<B>>) => PromiseLike<List<B>>;
|
|
99
|
+
forEach: (f: (a: A) => void) => void;
|
|
100
|
+
count: (p: (x: A) => boolean) => number;
|
|
101
|
+
exists: (p: (a: A) => boolean) => boolean;
|
|
102
|
+
filter: (p: (a: A) => boolean) => List<A>;
|
|
103
|
+
filterNot: (p: (a: A) => boolean) => List<A>;
|
|
104
|
+
find: (p: (a: A) => boolean) => Option<A>;
|
|
105
|
+
readonly head: A;
|
|
106
|
+
readonly headOption: Option<A>;
|
|
107
|
+
readonly isEmpty: boolean;
|
|
108
|
+
toArray: () => A[];
|
|
109
|
+
reduce: (f: (prev: A, curr: A) => A) => A;
|
|
110
|
+
reduceRight: (f: (prev: A, curr: A) => A) => A;
|
|
111
|
+
foldLeft: <B>(z: B) => (op: (b: B, a: A) => B) => B;
|
|
112
|
+
foldRight: <B>(z: B) => (op: (a: A, b: B) => B) => B;
|
|
118
113
|
remove: (value: A) => List<A>;
|
|
119
|
-
contains: (value: A) => boolean;
|
|
120
114
|
removeAt: (index: number) => List<A>;
|
|
115
|
+
add: (item: A) => List<A>;
|
|
121
116
|
get: (index: number) => Option<A>;
|
|
122
117
|
concat: (other: List<A>) => List<A>;
|
|
123
118
|
toList: () => List<A>;
|
|
@@ -127,11 +122,10 @@ type List<A> = {
|
|
|
127
122
|
_tag: string;
|
|
128
123
|
value: A[];
|
|
129
124
|
};
|
|
130
|
-
} &
|
|
131
|
-
declare const List: <A>(values?: Iterable<A>
|
|
132
|
-
declare const TestList: <A>(values?: Iterable<A> | _Iterable_<A>) => InternalList<A>;
|
|
125
|
+
} & IterableType<A> & Typeable<"List"> & AsyncFunctor<A>;
|
|
126
|
+
declare const List: <A>(values?: Iterable<A>) => List<A>;
|
|
133
127
|
|
|
134
|
-
type TestEither<L extends Type, R extends Type> = Either<L, R> & Functor<R>;
|
|
128
|
+
type TestEither<L extends Type, R extends Type> = Either<L, R> & Functor<R> & AsyncFunctor<R>;
|
|
135
129
|
declare const Right: <L extends Type, R extends Type>(value: R) => Either<L, R>;
|
|
136
130
|
declare const Left: <L extends Type, R extends Type>(value: L) => Either<L, R>;
|
|
137
131
|
declare const isRight: <L extends Type, R extends Type>(either: Either<L, R>) => either is Either<L, R> & {
|
|
@@ -169,7 +163,7 @@ type Either<L extends Type, R extends Type> = {
|
|
|
169
163
|
bimap: <L2 extends Type, R2 extends Type>(fl: (value: L) => L2, fr: (value: R) => R2) => Either<L2, R2>;
|
|
170
164
|
fold: <T extends Type>(onLeft: (value: L) => T, onRight: (value: R) => T) => T;
|
|
171
165
|
swap: () => Either<R, L>;
|
|
172
|
-
} & Typeable<"Left" | "Right"> & PromiseLike<R>;
|
|
166
|
+
} & Typeable<"Left" | "Right"> & PromiseLike<R> & AsyncFunctor<R>;
|
|
173
167
|
declare const Either: {
|
|
174
168
|
sequence: <L extends Type, R extends Type>(eithers: Either<L, R>[]) => Either<L, R[]>;
|
|
175
169
|
traverse: <L extends Type, R extends Type, U extends Type>(arr: R[], f: (value: R) => Either<L, U>) => Either<L, U[]>;
|
|
@@ -207,7 +201,7 @@ type Map<K, V> = {
|
|
|
207
201
|
add(item: Tuple<[K, V]>): Map<K, V>;
|
|
208
202
|
remove(value: K): Map<K, V>;
|
|
209
203
|
map<U>(f: (value: V) => U): Map<K, U>;
|
|
210
|
-
flatMap<K2, V2>(f: (entry: Tuple<[K, V]>) =>
|
|
204
|
+
flatMap<K2, V2>(f: (entry: Tuple<[K, V]>) => IterableType<[K2, V2]>): Map<K2, V2>;
|
|
211
205
|
get(key: K): Option<V>;
|
|
212
206
|
getOrElse(key: K, defaultValue: V): V;
|
|
213
207
|
orElse(key: K, alternative: Option<V>): Option<V>;
|
|
@@ -241,4 +235,4 @@ type Traversable<A extends Type> = Functor<A> & {
|
|
|
241
235
|
foldRight<B>(z: B): (op: (a: A, b: B) => B) => B;
|
|
242
236
|
};
|
|
243
237
|
|
|
244
|
-
export { AppException as A, type Converters as C, Either as E, List as L, Map as M, None as N, Option as O, Right as R, Some as S,
|
|
238
|
+
export { AppException as A, type Converters as C, Either as E, type IterableType as I, List as L, Map as M, None as N, Option as O, Right as R, Some as S, type TestEither as T, type Collection as a, Set as b, Left as c, isLeft as d, TypeCheckRight as e, TypeCheckLeft as f, tryCatchAsync as g, AppResult as h, isRight as i, Task as j, AsyncTask as k, Try as l, type Traversable as m, tryCatch as t };
|