functype 0.8.34 → 0.8.35
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-AIYLBUQO.js → chunk-52OPFRS2.js} +1 -1
- package/dist/chunk-QBAH7SOA.mjs +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/{index-w6bBTfvr.d.ts → index-B6k3GVAd.d.ts} +7 -1
- package/dist/{index-d37-44E9.d.mts → index-Cwkc_dEO.d.mts} +7 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/iterable/Seq.d.mts +1 -1
- package/dist/iterable/Seq.d.ts +1 -1
- package/dist/iterable/Seq.js +1 -1
- package/dist/iterable/Seq.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 +1 -1
- package/dist/list/List.d.ts +1 -1
- 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/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/lib/TaskPromise.d.ts +3 -0
- package/lib/collections/index.d.ts +8 -0
- package/lib/either/Either.d.ts +52 -0
- package/lib/either/EitherT.d.ts +9 -0
- package/lib/error/ParseError.d.ts +6 -0
- package/lib/functor/index.d.ts +15 -0
- package/lib/identity/Identity.d.ts +4 -0
- package/lib/index.d.ts +21 -0
- package/lib/iterable/Seq.d.ts +31 -0
- package/lib/iterable/index.d.ts +22 -0
- package/lib/list/List.d.ts +26 -0
- package/lib/map/Map.d.ts +17 -0
- package/lib/map/shim.d.ts +2 -0
- package/lib/option/Option.d.ts +30 -0
- package/lib/serializable/Serializable.d.ts +15 -0
- package/lib/set/Set.d.ts +15 -0
- package/lib/set/shim.d.ts +2 -0
- package/lib/try/Try.d.ts +18 -0
- package/lib/tuple/Tuple.d.ts +9 -0
- package/lib/typeable/Typeable.d.ts +4 -0
- package/lib/util/index.d.ts +3 -0
- package/lib/util/isIterable.d.ts +1 -0
- package/package.json +3 -3
- package/dist/chunk-HSSHSCKD.mjs +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
|
+
```
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunkOXLZ6UIZjs = require('./chunk-OXLZ6UIZ.js');var _chunkBNNK42JCjs = require('./chunk-BNNK42JC.js');var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunkOXLZ6UIZjs = require('./chunk-OXLZ6UIZ.js');var _chunkBNNK42JCjs = require('./chunk-BNNK42JC.js');var _chunk2U34DUZUjs = require('./chunk-2U34DUZU.js');var _chunkSQWNJC6Ojs = require('./chunk-SQWNJC6O.js');var _chunk5VTXJIR3js = require('./chunk-5VTXJIR3.js');var _chunk3VJERXBPjs = require('./chunk-3VJERXBP.js');var _safestablestringify = require('safe-stable-stringify'); var _safestablestringify2 = _interopRequireDefault(_safestablestringify);var A=e=>{let t=_chunkBNNK42JCjs.a.call(void 0, e)?e:e instanceof Object&&"toArray"in e?e.toArray():[],r=Array.from(t),p="Seq";return{[Symbol.iterator]:()=>r[Symbol.iterator](),get length(){return r.length},_tag:p,map:o=>A(r.map(o)),flatMap:o=>A(r.flatMap(n=>o(n).toArray())),forEach:o=>r.forEach(o),count:o=>r.filter(o).length,exists:o=>r.some(o),filter:o=>A(r.filter(o)),filterNot:o=>A(r.filter(n=>!o(n))),find:o=>T(r.find(o)),get head(){return r[0]},get headOption(){return r.length>0?T(r[0]):y()},get isEmpty(){return r.length===0},get size(){return r.length},toArray:()=>[...r],reduce:o=>r.reduce(o),reduceRight:o=>r.reduceRight(o),foldLeft:o=>n=>r.reduce(n,o),foldRight:o=>n=>r.reduceRight((f,S)=>n(S,f),o),toString:()=>`Seq(${_safestablestringify2.default.call(void 0, e)})`,toValue:()=>({_tag:p,value:r})}},L= exports.e =e=>A(e);var R=e=>{let t=_chunkBNNK42JCjs.a.call(void 0, e)?new (0, _chunk3VJERXBPjs.a)(e):new (0, _chunk3VJERXBPjs.a)(_nullishCoalesce(_optionalChain([e, 'optionalAccess', _2 => _2.toArray, 'call', _3 => _3()]), () => ([]))),r=L(t),p={...r,add:o=>R([...t,o]),remove:o=>{let n=new (0, _chunk3VJERXBPjs.a)(t);return n.delete(o),R(n)},contains:o=>t.has(o),has:o=>t.has(o),map:o=>R(r.map(o)),flatMap:o=>R(r.flatMap(o)),toList:()=>u(t),toSet:()=>p,toString:()=>`Set(${Array.from(t).toString()})`};return p},b= exports.f =e=>R(e);var d=e=>{function t(n){return n!=null&&typeof n[Symbol.iterator]=="function"}let r=Array.isArray(e)?e:t(e)?Array.from(e):[],p=L(r),o={...p,_tag:"List",length:r.length,map:n=>d(r.map(n)),flatMap:n=>d(p.flatMap(n)),remove:n=>{let f=r.indexOf(n);return o.removeAt(f)},contains:n=>r.includes(n),add:n=>d([...r,n]),removeAt:n=>n<0||n>=r.length?o:d([...r.slice(0,n),...r.slice(n+1)]),get:n=>T(r[n]),concat:n=>d([...r,...n.toArray()]),toList:()=>o,toSet:()=>b(r),toValue:()=>({_tag:"List",value:r}),toString:()=>`List(${_safestablestringify2.default.call(void 0, u(r))})`};return new Proxy(o,{get(n,f){return typeof f=="symbol"||isNaN(Number(f))?n[f]:n.get(Number(f))}})},u= exports.g =e=>d(e),W= exports.h =e=>d(e);console.assert(W);var K=e=>({_tag:"Right",value:e,isLeft:()=>!1,isRight:()=>!0,getOrElse:t=>e,getOrThrow:()=>e,map:t=>s(t(e)),mapAsync:t=>t(e).then(r=>s(r)).catch(r=>Promise.resolve(a(r))),merge:t=>t.isLeft()?a(t.value):s([e,t.value]),flatMap:t=>t(e),flatMapAsync:t=>t(e).catch(r=>a(r)),toOption:()=>c(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()?a(r.value):s([r.value])},lazyMap:function*(t){yield s(t(e))},tap:t=>(t(e),s(e)),tapLeft:t=>s(e),mapLeft:t=>s(e),bimap:(t,r)=>s(r(e)),fold:(t,r)=>r(e),swap:()=>a(e),then:(t,r)=>Promise.resolve(e).then(t,r)}),I=e=>({_tag:"Left",value:e,isLeft:()=>!0,isRight:()=>!1,getOrElse:t=>t,getOrThrow:()=>{throw e},map:t=>a(e),mapAsync:t=>Promise.resolve(a(e)),merge:t=>a(e),flatMap:t=>a(e),flatMapAsync:t=>Promise.resolve(a(e)),toOption:()=>y(),toList:()=>u(),toString:()=>`Left(${_safestablestringify2.default.call(void 0, e)})`,[Symbol.iterator]:function*(){},yield:function*(){},traverse:t=>a(e),lazyMap:function*(t){yield a(e)},tap:t=>a(e),tapLeft:t=>(t(e),a(e)),mapLeft:t=>a(t(e)),bimap:(t,r)=>a(t(e)),fold:(t,r)=>t(e),swap:()=>s(e),then:(t,r)=>Promise.reject(e).then(null,r)}),s= exports.i =e=>K(e),a= exports.j =e=>I(e),ve= exports.k =e=>e.isRight(),Ve= exports.l =e=>e.isLeft(),Oe= exports.m =(e,t)=>{try{return s(e())}catch(r){return a(t(r))}},X= exports.n =e=>K(e);console.assert(X);var Y=e=>I(e);console.assert(Y);var we=async(e,t)=>{try{let r=await e();return s(r)}catch(r){return a(t(r))}},Z= exports.q ={sequence:e=>{let t=[];for(let r of e){if(r.isLeft())return a(r.value);t.push(r.value)}return s(t)},traverse:(e,t)=>Z.sequence(e.map(t)),fromNullable:(e,t)=>e==null?a(t):s(e),fromPredicate:(e,t,r)=>t(e)?s(e):a(r),ap:(e,t)=>e.flatMap(r=>t.map(r)),fromPromise:async(e,t)=>{try{let r=await e;return s(r)}catch(r){return a(t(r))}}};var U=(e,t)=>{let r=_chunk2U34DUZUjs.a.call(void 0, e,t);return{..._chunkSQWNJC6Ojs.a.call(void 0, "AppException"),...a(r)}},B= exports.s =e=>({..._chunkSQWNJC6Ojs.a.call(void 0, "AppResult"),...s(e)});function M(e,t=r=>r){try{return B(e())}catch(r){return U(t(r))}}M.success=e=>B(e);M.fail=e=>U(e);async function k(e,t=r=>r){try{let r=await e();return B(r)}catch(r){let p=await t(r);return U(p)}}k.success=e=>B(e);k.fail=e=>U(e);var m=e=>{let t={values:new (0, _chunk5VTXJIR3js.a)(e)},r=()=>Array.from(t.values.entries()).map(([i,l])=>_chunkOXLZ6UIZjs.a.call(void 0, [i,l])),p=i=>m(new (0, _chunk5VTXJIR3js.a)(t.values).set(i.toArray()[0],i.toArray()[1]).entries()),o=i=>{let l=new (0, _chunk5VTXJIR3js.a)(t.values);return l.delete(i)?m(l.entries()):m(t.values.entries())},n=i=>t.values.get(i[0])===i[1],f=()=>t.values.size,S=i=>m(Array.from(t.values.entries()).map(([l,H])=>[l,i(H)])),q=i=>{let l=m(t.values.entries()).toList();return m(l.flatMap(i).toArray())},z=i=>L(r()).reduce(i),F=i=>L(r()).reduceRight(i),C=i=>l=>L(r()).foldLeft(i)(l),$=i=>l=>L(r()).foldRight(i)(l),j=i=>T(t.values.get(i)),G=(i,l)=>T(t.values.get(i)).getOrElse(l),D=()=>t.values.size===0;return{add:p,remove:o,contains:n,get size(){return f()},map:S,flatMap:q,reduce:z,reduceRight:F,foldLeft:C,foldRight:$,get:j,getOrElse:G,get isEmpty(){return D()},orElse:(i,l)=>T(t.values.get(i)).orElse(l),toList:()=>u(r()),toSet:()=>b(r()),toString:()=>`Map(${r().toString()})`}},He= exports.v =e=>m(e);var N=e=>({_tag:"Success",value:e,error:void 0,isSuccess:()=>!0,isFailure:()=>!1,get:()=>e,getOrElse:t=>e,orElse:t=>N(e),orThrow:t=>e,toEither:()=>s(e),map:t=>ee(()=>t(e)),flatMap:t=>t(e),toString:()=>`Success(${_safestablestringify2.default.call(void 0, e)})`}),v=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:()=>a(e),map:t=>v(e),flatMap:t=>v(e),toString:()=>`Failure(${_safestablestringify2.default.call(void 0, e)}))`}),ee= exports.w =e=>{try{return N(e())}catch(t){return v(t instanceof Error?t:new Error(String(t)))}};var c=e=>({_tag:"Some",value:e,isEmpty:!1,get:()=>e,getOrElse:()=>e,getOrThrow:()=>e,orElse:()=>c(e),getOrNull:()=>e,map:t=>c(t(e)),filter(t){return t(e)?c(e):h},fold:(t,r)=>r(e),flatMap:t=>t(e),reduce:t=>t(void 0,e),reduceRight:t=>t(void 0,e),foldLeft:t=>r=>r(t,e),foldRight:t=>r=>r(e,t),toList:()=>u([e]),contains:t=>t===e,size:1,toEither:t=>s(e),toString:()=>`Some(${_safestablestringify2.default.call(void 0, e)})`,toValue:()=>({_tag:"Some",value:e})}),h={_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,getOrNull:()=>null,map:e=>h,filter(e){return h},flatMap:e=>h,reduce:()=>{},reduceRight:()=>{},fold:(e,t)=>e(),foldLeft:e=>()=>e,foldRight:e=>()=>e,toList:()=>u([]),contains:()=>!1,size:0,toEither:e=>a(e),toString:()=>"None",toValue:()=>({_tag:"None",value:void 0})},y= exports.b =()=>h,T= exports.c =e=>e!=null?c(e):y();T.from=e=>T(e);T.none=()=>y();exports.a = c; exports.b = y; exports.c = T; exports.d = A; exports.e = L; exports.f = b; exports.g = u; exports.h = W; exports.i = s; exports.j = a; exports.k = ve; exports.l = Ve; exports.m = Oe; exports.n = X; exports.o = Y; exports.p = we; exports.q = Z; exports.r = U; exports.s = B; exports.t = M; exports.u = k; exports.v = He; exports.w = ee;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as O}from"./chunk-2I2NKDFN.mjs";import{a as g}from"./chunk-RRAIFS3D.mjs";import{a as V}from"./chunk-HD6YYUHO.mjs";import{a as _}from"./chunk-JF5YGNCO.mjs";import{a as E}from"./chunk-377WQNCB.mjs";import{a as x}from"./chunk-HA5XD5KC.mjs";import te from"safe-stable-stringify";import w from"safe-stable-stringify";import Q from"safe-stable-stringify";import J from"safe-stable-stringify";var A=e=>{let t=g(e)?e:e instanceof Object&&"toArray"in e?e.toArray():[],r=Array.from(t),p="Seq";return{[Symbol.iterator]:()=>r[Symbol.iterator](),get length(){return r.length},_tag:p,map:o=>A(r.map(o)),flatMap:o=>A(r.flatMap(n=>o(n).toArray())),forEach:o=>r.forEach(o),count:o=>r.filter(o).length,exists:o=>r.some(o),filter:o=>A(r.filter(o)),filterNot:o=>A(r.filter(n=>!o(n))),find:o=>T(r.find(o)),get head(){return r[0]},get headOption(){return r.length>0?T(r[0]):y()},get isEmpty(){return r.length===0},get size(){return r.length},toArray:()=>[...r],reduce:o=>r.reduce(o),reduceRight:o=>r.reduceRight(o),foldLeft:o=>n=>r.reduce(n,o),foldRight:o=>n=>r.reduceRight((f,S)=>n(S,f),o),toString:()=>`Seq(${J(e)})`,toValue:()=>({_tag:p,value:r})}},L=e=>A(e);var R=e=>{let t=g(e)?new x(e):new x(e?.toArray()??[]),r=L(t),p={...r,add:o=>R([...t,o]),remove:o=>{let n=new x(t);return n.delete(o),R(n)},contains:o=>t.has(o),has:o=>t.has(o),map:o=>R(r.map(o)),flatMap:o=>R(r.flatMap(o)),toList:()=>u(t),toSet:()=>p,toString:()=>`Set(${Array.from(t).toString()})`};return p},b=e=>R(e);var d=e=>{function t(n){return n!=null&&typeof n[Symbol.iterator]=="function"}let r=Array.isArray(e)?e:t(e)?Array.from(e):[],p=L(r),o={...p,_tag:"List",length:r.length,map:n=>d(r.map(n)),flatMap:n=>d(p.flatMap(n)),remove:n=>{let f=r.indexOf(n);return o.removeAt(f)},contains:n=>r.includes(n),add:n=>d([...r,n]),removeAt:n=>n<0||n>=r.length?o:d([...r.slice(0,n),...r.slice(n+1)]),get:n=>T(r[n]),concat:n=>d([...r,...n.toArray()]),toList:()=>o,toSet:()=>b(r),toValue:()=>({_tag:"List",value:r}),toString:()=>`List(${Q(u(r))})`};return new Proxy(o,{get(n,f){return typeof f=="symbol"||isNaN(Number(f))?n[f]:n.get(Number(f))}})},u=e=>d(e),W=e=>d(e);console.assert(W);var K=e=>({_tag:"Right",value:e,isLeft:()=>!1,isRight:()=>!0,getOrElse:t=>e,getOrThrow:()=>e,map:t=>s(t(e)),mapAsync:t=>t(e).then(r=>s(r)).catch(r=>Promise.resolve(a(r))),merge:t=>t.isLeft()?a(t.value):s([e,t.value]),flatMap:t=>t(e),flatMapAsync:t=>t(e).catch(r=>a(r)),toOption:()=>c(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()?a(r.value):s([r.value])},lazyMap:function*(t){yield s(t(e))},tap:t=>(t(e),s(e)),tapLeft:t=>s(e),mapLeft:t=>s(e),bimap:(t,r)=>s(r(e)),fold:(t,r)=>r(e),swap:()=>a(e),then:(t,r)=>Promise.resolve(e).then(t,r)}),I=e=>({_tag:"Left",value:e,isLeft:()=>!0,isRight:()=>!1,getOrElse:t=>t,getOrThrow:()=>{throw e},map:t=>a(e),mapAsync:t=>Promise.resolve(a(e)),merge:t=>a(e),flatMap:t=>a(e),flatMapAsync:t=>Promise.resolve(a(e)),toOption:()=>y(),toList:()=>u(),toString:()=>`Left(${w(e)})`,[Symbol.iterator]:function*(){},yield:function*(){},traverse:t=>a(e),lazyMap:function*(t){yield a(e)},tap:t=>a(e),tapLeft:t=>(t(e),a(e)),mapLeft:t=>a(t(e)),bimap:(t,r)=>a(t(e)),fold:(t,r)=>t(e),swap:()=>s(e),then:(t,r)=>Promise.reject(e).then(null,r)}),s=e=>K(e),a=e=>I(e),ve=e=>e.isRight(),Ve=e=>e.isLeft(),Oe=(e,t)=>{try{return s(e())}catch(r){return a(t(r))}},X=e=>K(e);console.assert(X);var Y=e=>I(e);console.assert(Y);var we=async(e,t)=>{try{let r=await e();return s(r)}catch(r){return a(t(r))}},Z={sequence:e=>{let t=[];for(let r of e){if(r.isLeft())return a(r.value);t.push(r.value)}return s(t)},traverse:(e,t)=>Z.sequence(e.map(t)),fromNullable:(e,t)=>e==null?a(t):s(e),fromPredicate:(e,t,r)=>t(e)?s(e):a(r),ap:(e,t)=>e.flatMap(r=>t.map(r)),fromPromise:async(e,t)=>{try{let r=await e;return s(r)}catch(r){return a(t(r))}}};var U=(e,t)=>{let r=V(e,t);return{..._("AppException"),...a(r)}},B=e=>({..._("AppResult"),...s(e)});function M(e,t=r=>r){try{return B(e())}catch(r){return U(t(r))}}M.success=e=>B(e);M.fail=e=>U(e);async function k(e,t=r=>r){try{let r=await e();return B(r)}catch(r){let p=await t(r);return U(p)}}k.success=e=>B(e);k.fail=e=>U(e);var m=e=>{let t={values:new E(e)},r=()=>Array.from(t.values.entries()).map(([i,l])=>O([i,l])),p=i=>m(new E(t.values).set(i.toArray()[0],i.toArray()[1]).entries()),o=i=>{let l=new E(t.values);return l.delete(i)?m(l.entries()):m(t.values.entries())},n=i=>t.values.get(i[0])===i[1],f=()=>t.values.size,S=i=>m(Array.from(t.values.entries()).map(([l,H])=>[l,i(H)])),q=i=>{let l=m(t.values.entries()).toList();return m(l.flatMap(i).toArray())},z=i=>L(r()).reduce(i),F=i=>L(r()).reduceRight(i),C=i=>l=>L(r()).foldLeft(i)(l),$=i=>l=>L(r()).foldRight(i)(l),j=i=>T(t.values.get(i)),G=(i,l)=>T(t.values.get(i)).getOrElse(l),D=()=>t.values.size===0;return{add:p,remove:o,contains:n,get size(){return f()},map:S,flatMap:q,reduce:z,reduceRight:F,foldLeft:C,foldRight:$,get:j,getOrElse:G,get isEmpty(){return D()},orElse:(i,l)=>T(t.values.get(i)).orElse(l),toList:()=>u(r()),toSet:()=>b(r()),toString:()=>`Map(${r().toString()})`}},He=e=>m(e);import P from"safe-stable-stringify";var N=e=>({_tag:"Success",value:e,error:void 0,isSuccess:()=>!0,isFailure:()=>!1,get:()=>e,getOrElse:t=>e,orElse:t=>N(e),orThrow:t=>e,toEither:()=>s(e),map:t=>ee(()=>t(e)),flatMap:t=>t(e),toString:()=>`Success(${P(e)})`}),v=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:()=>a(e),map:t=>v(e),flatMap:t=>v(e),toString:()=>`Failure(${P(e)}))`}),ee=e=>{try{return N(e())}catch(t){return v(t instanceof Error?t:new Error(String(t)))}};var c=e=>({_tag:"Some",value:e,isEmpty:!1,get:()=>e,getOrElse:()=>e,getOrThrow:()=>e,orElse:()=>c(e),getOrNull:()=>e,map:t=>c(t(e)),filter(t){return t(e)?c(e):h},fold:(t,r)=>r(e),flatMap:t=>t(e),reduce:t=>t(void 0,e),reduceRight:t=>t(void 0,e),foldLeft:t=>r=>r(t,e),foldRight:t=>r=>r(e,t),toList:()=>u([e]),contains:t=>t===e,size:1,toEither:t=>s(e),toString:()=>`Some(${te(e)})`,toValue:()=>({_tag:"Some",value:e})}),h={_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,getOrNull:()=>null,map:e=>h,filter(e){return h},flatMap:e=>h,reduce:()=>{},reduceRight:()=>{},fold:(e,t)=>e(),foldLeft:e=>()=>e,foldRight:e=>()=>e,toList:()=>u([]),contains:()=>!1,size:0,toEither:e=>a(e),toString:()=>"None",toValue:()=>({_tag:"None",value:void 0})},y=()=>h,T=e=>e!=null?c(e):y();T.from=e=>T(e);T.none=()=>y();export{c as a,y as b,T as c,A as d,L as e,b as f,u as g,W as h,s as i,a as j,ve as k,Ve as l,Oe as m,X as n,Y as o,we as p,Z as q,U as r,B as s,M as t,k as u,He as v,ee as w};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { A as AppException, l as AppResult, n as AsyncTask, m as Task } from '../../index-
|
|
1
|
+
export { A as AppException, l as AppResult, n as AsyncTask, m as Task } from '../../index-Cwkc_dEO.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, l as AppResult, n as AsyncTask, m as Task } from '../../index-
|
|
1
|
+
export { A as AppException, l as AppResult, n as AsyncTask, m as Task } from '../../index-B6k3GVAd.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 _chunk52OPFRS2js = require('../../chunk-52OPFRS2.js');require('../../chunk-OXLZ6UIZ.js');require('../../chunk-BNNK42JC.js');require('../../chunk-2U34DUZU.js');require('../../chunk-SQWNJC6O.js');require('../../chunk-5O6YELD3.js');require('../../chunk-5VTXJIR3.js');require('../../chunk-3VJERXBP.js');require('../../chunk-XORABVON.js');require('../../chunk-K3EKBPQE.js');exports.AppException = _chunk52OPFRS2js.r; exports.AppResult = _chunk52OPFRS2js.s; exports.AsyncTask = _chunk52OPFRS2js.u; exports.Task = _chunk52OPFRS2js.t;
|
package/dist/core/task/Task.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as a,s as b,t as c,u as d}from"../../chunk-
|
|
1
|
+
import{r as a,s as b,t as c,u as d}from"../../chunk-QBAH7SOA.mjs";import"../../chunk-2I2NKDFN.mjs";import"../../chunk-RRAIFS3D.mjs";import"../../chunk-HD6YYUHO.mjs";import"../../chunk-JF5YGNCO.mjs";import"../../chunk-V7DKESTM.mjs";import"../../chunk-377WQNCB.mjs";import"../../chunk-HA5XD5KC.mjs";import"../../chunk-V2J3R5IU.mjs";import"../../chunk-2ML63TYF.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, f as Left, R as Right, e as TestEither, j as TypeCheckLeft, h as TypeCheckRight, g as isLeft, i as isRight, t as tryCatch, k as tryCatchAsync } from '../index-
|
|
2
|
+
export { E as Either, f as Left, R as Right, e as TestEither, j as TypeCheckLeft, h as TypeCheckRight, g as isLeft, i as isRight, t as tryCatch, k as tryCatchAsync } from '../index-Cwkc_dEO.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, f as Left, R as Right, e as TestEither, j as TypeCheckLeft, h as TypeCheckRight, g as isLeft, i as isRight, t as tryCatch, k as tryCatchAsync } from '../index-
|
|
2
|
+
export { E as Either, f as Left, R as Right, e as TestEither, j as TypeCheckLeft, h as TypeCheckRight, g as isLeft, i as isRight, t as tryCatch, k as tryCatchAsync } from '../index-B6k3GVAd.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 _chunk52OPFRS2js = require('../chunk-52OPFRS2.js');require('../chunk-OXLZ6UIZ.js');require('../chunk-BNNK42JC.js');require('../chunk-2U34DUZU.js');require('../chunk-SQWNJC6O.js');require('../chunk-5O6YELD3.js');require('../chunk-5VTXJIR3.js');require('../chunk-3VJERXBP.js');require('../chunk-XORABVON.js');require('../chunk-K3EKBPQE.js');exports.Either = _chunk52OPFRS2js.q; exports.Left = _chunk52OPFRS2js.j; exports.Right = _chunk52OPFRS2js.i; exports.TypeCheckLeft = _chunk52OPFRS2js.o; exports.TypeCheckRight = _chunk52OPFRS2js.n; exports.isLeft = _chunk52OPFRS2js.l; exports.isRight = _chunk52OPFRS2js.k; exports.tryCatch = _chunk52OPFRS2js.m; exports.tryCatchAsync = _chunk52OPFRS2js.p;
|
package/dist/either/Either.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as a,j as b,k as c,l as d,m as e,n as f,o as g,p as h,q as i}from"../chunk-
|
|
1
|
+
import{i as a,j as b,k as c,l as d,m as e,n as f,o as g,p as h,q as i}from"../chunk-QBAH7SOA.mjs";import"../chunk-2I2NKDFN.mjs";import"../chunk-RRAIFS3D.mjs";import"../chunk-HD6YYUHO.mjs";import"../chunk-JF5YGNCO.mjs";import"../chunk-V7DKESTM.mjs";import"../chunk-377WQNCB.mjs";import"../chunk-HA5XD5KC.mjs";import"../chunk-V2J3R5IU.mjs";import"../chunk-2ML63TYF.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};
|
|
@@ -16,11 +16,13 @@ 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
|
+
getOrNull(): T | null;
|
|
19
20
|
map<U extends Type>(f: (value: T) => U): Option<U>;
|
|
20
21
|
filter(predicate: (value: T) => boolean): Option<T>;
|
|
21
22
|
flatMap<U extends Type>(f: (value: T) => Option<U>): Option<U>;
|
|
22
23
|
reduce<U>(f: (acc: U, value: T) => U): U;
|
|
23
24
|
reduceRight<U>(f: (acc: U, value: T) => U): U;
|
|
25
|
+
fold<U>(onNone: () => U, onSome: (value: T) => U): U;
|
|
24
26
|
foldLeft<B>(z: B): (op: (b: B, a: T) => B) => B;
|
|
25
27
|
foldRight<B>(z: B): (op: (a: T, b: B) => B) => B;
|
|
26
28
|
toList(): List<T>;
|
|
@@ -33,7 +35,11 @@ type Option<T extends Type> = {
|
|
|
33
35
|
value: T;
|
|
34
36
|
};
|
|
35
37
|
} & (Traversable<T> & Functor<T> & Typeable<"Some" | "None"> & Valuable<T>);
|
|
36
|
-
declare const Option:
|
|
38
|
+
declare const Option: {
|
|
39
|
+
<T extends Type>(value: T | null | undefined): Option<T>;
|
|
40
|
+
from<T>(value: T): Option<T>;
|
|
41
|
+
none<T>(): Option<T>;
|
|
42
|
+
};
|
|
37
43
|
|
|
38
44
|
declare const createSeq: <A>(values?: Iterable<A> | _Iterable_<A>) => Seq<A>;
|
|
39
45
|
type Seq<A> = {
|
|
@@ -16,11 +16,13 @@ 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
|
+
getOrNull(): T | null;
|
|
19
20
|
map<U extends Type>(f: (value: T) => U): Option<U>;
|
|
20
21
|
filter(predicate: (value: T) => boolean): Option<T>;
|
|
21
22
|
flatMap<U extends Type>(f: (value: T) => Option<U>): Option<U>;
|
|
22
23
|
reduce<U>(f: (acc: U, value: T) => U): U;
|
|
23
24
|
reduceRight<U>(f: (acc: U, value: T) => U): U;
|
|
25
|
+
fold<U>(onNone: () => U, onSome: (value: T) => U): U;
|
|
24
26
|
foldLeft<B>(z: B): (op: (b: B, a: T) => B) => B;
|
|
25
27
|
foldRight<B>(z: B): (op: (a: T, b: B) => B) => B;
|
|
26
28
|
toList(): List<T>;
|
|
@@ -33,7 +35,11 @@ type Option<T extends Type> = {
|
|
|
33
35
|
value: T;
|
|
34
36
|
};
|
|
35
37
|
} & (Traversable<T> & Functor<T> & Typeable<"Some" | "None"> & Valuable<T>);
|
|
36
|
-
declare const Option:
|
|
38
|
+
declare const Option: {
|
|
39
|
+
<T extends Type>(value: T | null | undefined): Option<T>;
|
|
40
|
+
from<T>(value: T): Option<T>;
|
|
41
|
+
none<T>(): Option<T>;
|
|
42
|
+
};
|
|
37
43
|
|
|
38
44
|
declare const createSeq: <A>(values?: Iterable<A> | _Iterable_<A>) => Seq<A>;
|
|
39
45
|
type Seq<A> = {
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { AbstractFunctor, ArrayFunctor, ArrayType, 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, l as AppResult, n as AsyncTask, E as Either, f as Left, L as List, M as Map, N as None, O as Option, R as Right, a as Seq, b as Set, S as Some, m as Task, e as TestEither, T as TestList, p as Traversable, o as Try, j as TypeCheckLeft, h as TypeCheckRight, _ as _Iterable_, g as isLeft, i as isRight, t as tryCatch, k as tryCatchAsync } from './index-
|
|
4
|
+
export { A as AppException, l as AppResult, n as AsyncTask, E as Either, f as Left, L as List, M as Map, N as None, O as Option, R as Right, a as Seq, b as Set, S as Some, m as Task, e as TestEither, T as TestList, p as Traversable, o as Try, j as TypeCheckLeft, h as TypeCheckRight, _ as _Iterable_, g as isLeft, i as isRight, t as tryCatch, k as tryCatchAsync } from './index-Cwkc_dEO.mjs';
|
|
5
5
|
export { Identity } from './identity/Identity.mjs';
|
|
6
6
|
export { Tuple } from './tuple/Tuple.mjs';
|
|
7
7
|
export { Typeable } from './typeable/Typeable.mjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { AbstractFunctor, ArrayFunctor, ArrayType, 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, l as AppResult, n as AsyncTask, E as Either, f as Left, L as List, M as Map, N as None, O as Option, R as Right, a as Seq, b as Set, S as Some, m as Task, e as TestEither, T as TestList, p as Traversable, o as Try, j as TypeCheckLeft, h as TypeCheckRight, _ as _Iterable_, g as isLeft, i as isRight, t as tryCatch, k as tryCatchAsync } from './index-
|
|
4
|
+
export { A as AppException, l as AppResult, n as AsyncTask, E as Either, f as Left, L as List, M as Map, N as None, O as Option, R as Right, a as Seq, b as Set, S as Some, m as Task, e as TestEither, T as TestList, p as Traversable, o as Try, j as TypeCheckLeft, h as TypeCheckRight, _ as _Iterable_, g as isLeft, i as isRight, t as tryCatch, k as tryCatchAsync } from './index-B6k3GVAd.js';
|
|
5
5
|
export { Identity } from './identity/Identity.js';
|
|
6
6
|
export { Tuple } from './tuple/Tuple.js';
|
|
7
7
|
export { Typeable } from './typeable/Typeable.js';
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk52OPFRS2js = require('./chunk-52OPFRS2.js');var _chunkOXLZ6UIZjs = require('./chunk-OXLZ6UIZ.js');require('./chunk-BNNK42JC.js');var _chunk2U34DUZUjs = require('./chunk-2U34DUZU.js');var _chunkSQWNJC6Ojs = require('./chunk-SQWNJC6O.js');var _chunk5O6YELD3js = require('./chunk-5O6YELD3.js');require('./chunk-5VTXJIR3.js');require('./chunk-3VJERXBP.js');require('./chunk-XORABVON.js');require('./chunk-K3EKBPQE.js');exports.AppException = _chunk52OPFRS2js.r; exports.AppResult = _chunk52OPFRS2js.s; exports.AsyncTask = _chunk52OPFRS2js.u; exports.Base = _chunkSQWNJC6Ojs.a; exports.Either = _chunk52OPFRS2js.q; exports.Left = _chunk52OPFRS2js.j; exports.List = _chunk52OPFRS2js.g; exports.Map = _chunk52OPFRS2js.v; exports.None = _chunk52OPFRS2js.b; exports.Option = _chunk52OPFRS2js.c; exports.Right = _chunk52OPFRS2js.i; exports.Seq = _chunk52OPFRS2js.e; exports.Set = _chunk52OPFRS2js.f; exports.Some = _chunk52OPFRS2js.a; exports.Task = _chunk52OPFRS2js.t; exports.TestList = _chunk52OPFRS2js.h; exports.Throwable = _chunk2U34DUZUjs.a; exports.Try = _chunk52OPFRS2js.w; exports.Tuple = _chunkOXLZ6UIZjs.a; exports.TypeCheckLeft = _chunk52OPFRS2js.o; exports.TypeCheckRight = _chunk52OPFRS2js.n; exports.Typeable = _chunk5O6YELD3js.a; exports.isLeft = _chunk52OPFRS2js.l; exports.isRight = _chunk52OPFRS2js.k; exports.tryCatch = _chunk52OPFRS2js.m; exports.tryCatchAsync = _chunk52OPFRS2js.p;
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as d,b as e,c as f,e as g,f as h,g as i,h as j,i as k,j as l,k as m,l as n,m as o,n as p,o as q,p as r,q as s,r as t,s as u,t as v,u as w,v as y,w as z}from"./chunk-
|
|
1
|
+
import{a as d,b as e,c as f,e as g,f as h,g as i,h as j,i as k,j as l,k as m,l as n,m as o,n as p,o as q,p as r,q as s,r as t,s as u,t as v,u as w,v as y,w as z}from"./chunk-QBAH7SOA.mjs";import{a as x}from"./chunk-2I2NKDFN.mjs";import"./chunk-RRAIFS3D.mjs";import{a as c}from"./chunk-HD6YYUHO.mjs";import{a as b}from"./chunk-JF5YGNCO.mjs";import{a}from"./chunk-V7DKESTM.mjs";import"./chunk-377WQNCB.mjs";import"./chunk-HA5XD5KC.mjs";import"./chunk-V2J3R5IU.mjs";import"./chunk-2ML63TYF.mjs";export{t as AppException,u as AppResult,w as AsyncTask,b as Base,s as Either,l as Left,i as List,y as Map,e as None,f as Option,k as Right,g as Seq,h as Set,d as Some,v as Task,j as TestList,c as Throwable,z as Try,x as Tuple,q as TypeCheckLeft,p as TypeCheckRight,a as Typeable,n as isLeft,m as isRight,o as tryCatch,r as tryCatchAsync};
|
package/dist/iterable/Seq.d.mts
CHANGED
package/dist/iterable/Seq.d.ts
CHANGED
package/dist/iterable/Seq.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk52OPFRS2js = require('../chunk-52OPFRS2.js');require('../chunk-OXLZ6UIZ.js');require('../chunk-BNNK42JC.js');require('../chunk-2U34DUZU.js');require('../chunk-SQWNJC6O.js');require('../chunk-5O6YELD3.js');require('../chunk-5VTXJIR3.js');require('../chunk-3VJERXBP.js');require('../chunk-XORABVON.js');require('../chunk-K3EKBPQE.js');exports.Seq = _chunk52OPFRS2js.e; exports.createSeq = _chunk52OPFRS2js.d;
|
package/dist/iterable/Seq.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as a,e as b}from"../chunk-
|
|
1
|
+
import{d as a,e as b}from"../chunk-QBAH7SOA.mjs";import"../chunk-2I2NKDFN.mjs";import"../chunk-RRAIFS3D.mjs";import"../chunk-HD6YYUHO.mjs";import"../chunk-JF5YGNCO.mjs";import"../chunk-V7DKESTM.mjs";import"../chunk-377WQNCB.mjs";import"../chunk-HA5XD5KC.mjs";import"../chunk-V2J3R5IU.mjs";import"../chunk-2ML63TYF.mjs";export{b as Seq,a as createSeq};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import '../functor/index.mjs';
|
|
2
|
-
export { a as Seq, _ as _Iterable_ } from '../index-
|
|
2
|
+
export { a as Seq, _ as _Iterable_ } from '../index-Cwkc_dEO.mjs';
|
|
3
3
|
import '../core/base/Base.mjs';
|
|
4
4
|
import '../core/error/Throwable.mjs';
|
|
5
5
|
import '../typeable/Typeable.mjs';
|
package/dist/iterable/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import '../functor/index.js';
|
|
2
|
-
export { a as Seq, _ as _Iterable_ } from '../index-
|
|
2
|
+
export { a as Seq, _ as _Iterable_ } from '../index-B6k3GVAd.js';
|
|
3
3
|
import '../core/base/Base.js';
|
|
4
4
|
import '../core/error/Throwable.js';
|
|
5
5
|
import '../typeable/Typeable.js';
|
package/dist/iterable/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk52OPFRS2js = require('../chunk-52OPFRS2.js');require('../chunk-OXLZ6UIZ.js');require('../chunk-BNNK42JC.js');require('../chunk-2U34DUZU.js');require('../chunk-SQWNJC6O.js');require('../chunk-5O6YELD3.js');require('../chunk-5VTXJIR3.js');require('../chunk-3VJERXBP.js');require('../chunk-XORABVON.js');require('../chunk-K3EKBPQE.js');exports.Seq = _chunk52OPFRS2js.e;
|
package/dist/iterable/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{e as a}from"../chunk-
|
|
1
|
+
import{e as a}from"../chunk-QBAH7SOA.mjs";import"../chunk-2I2NKDFN.mjs";import"../chunk-RRAIFS3D.mjs";import"../chunk-HD6YYUHO.mjs";import"../chunk-JF5YGNCO.mjs";import"../chunk-V7DKESTM.mjs";import"../chunk-377WQNCB.mjs";import"../chunk-HA5XD5KC.mjs";import"../chunk-V2J3R5IU.mjs";import"../chunk-2ML63TYF.mjs";export{a as Seq};
|
package/dist/list/List.d.mts
CHANGED
package/dist/list/List.d.ts
CHANGED
package/dist/list/List.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk52OPFRS2js = require('../chunk-52OPFRS2.js');require('../chunk-OXLZ6UIZ.js');require('../chunk-BNNK42JC.js');require('../chunk-2U34DUZU.js');require('../chunk-SQWNJC6O.js');require('../chunk-5O6YELD3.js');require('../chunk-5VTXJIR3.js');require('../chunk-3VJERXBP.js');require('../chunk-XORABVON.js');require('../chunk-K3EKBPQE.js');exports.List = _chunk52OPFRS2js.g; exports.TestList = _chunk52OPFRS2js.h;
|
package/dist/list/List.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{g as a,h as b}from"../chunk-
|
|
1
|
+
import{g as a,h as b}from"../chunk-QBAH7SOA.mjs";import"../chunk-2I2NKDFN.mjs";import"../chunk-RRAIFS3D.mjs";import"../chunk-HD6YYUHO.mjs";import"../chunk-JF5YGNCO.mjs";import"../chunk-V7DKESTM.mjs";import"../chunk-377WQNCB.mjs";import"../chunk-HA5XD5KC.mjs";import"../chunk-V2J3R5IU.mjs";import"../chunk-2ML63TYF.mjs";export{a as List,b as TestList};
|
package/dist/map/Map.d.mts
CHANGED
package/dist/map/Map.d.ts
CHANGED
package/dist/map/Map.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk52OPFRS2js = require('../chunk-52OPFRS2.js');require('../chunk-OXLZ6UIZ.js');require('../chunk-BNNK42JC.js');require('../chunk-2U34DUZU.js');require('../chunk-SQWNJC6O.js');require('../chunk-5O6YELD3.js');require('../chunk-5VTXJIR3.js');require('../chunk-3VJERXBP.js');require('../chunk-XORABVON.js');require('../chunk-K3EKBPQE.js');exports.Map = _chunk52OPFRS2js.v;
|
package/dist/map/Map.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{v as a}from"../chunk-
|
|
1
|
+
import{v as a}from"../chunk-QBAH7SOA.mjs";import"../chunk-2I2NKDFN.mjs";import"../chunk-RRAIFS3D.mjs";import"../chunk-HD6YYUHO.mjs";import"../chunk-JF5YGNCO.mjs";import"../chunk-V7DKESTM.mjs";import"../chunk-377WQNCB.mjs";import"../chunk-HA5XD5KC.mjs";import"../chunk-V2J3R5IU.mjs";import"../chunk-2ML63TYF.mjs";export{a as Map};
|
package/dist/option/Option.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import '../functor/index.mjs';
|
|
2
|
-
export { N as None, O as Option, S as Some } from '../index-
|
|
2
|
+
export { N as None, O as Option, S as Some } from '../index-Cwkc_dEO.mjs';
|
|
3
3
|
import '../typeable/Typeable.mjs';
|
|
4
4
|
import '../valuable/Valuable.mjs';
|
|
5
5
|
import '../core/base/Base.mjs';
|
package/dist/option/Option.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import '../functor/index.js';
|
|
2
|
-
export { N as None, O as Option, S as Some } from '../index-
|
|
2
|
+
export { N as None, O as Option, S as Some } from '../index-B6k3GVAd.js';
|
|
3
3
|
import '../typeable/Typeable.js';
|
|
4
4
|
import '../valuable/Valuable.js';
|
|
5
5
|
import '../core/base/Base.js';
|
package/dist/option/Option.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk52OPFRS2js = require('../chunk-52OPFRS2.js');require('../chunk-OXLZ6UIZ.js');require('../chunk-BNNK42JC.js');require('../chunk-2U34DUZU.js');require('../chunk-SQWNJC6O.js');require('../chunk-5O6YELD3.js');require('../chunk-5VTXJIR3.js');require('../chunk-3VJERXBP.js');require('../chunk-XORABVON.js');require('../chunk-K3EKBPQE.js');exports.None = _chunk52OPFRS2js.b; exports.Option = _chunk52OPFRS2js.c; exports.Some = _chunk52OPFRS2js.a;
|
package/dist/option/Option.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a,b,c}from"../chunk-
|
|
1
|
+
import{a,b,c}from"../chunk-QBAH7SOA.mjs";import"../chunk-2I2NKDFN.mjs";import"../chunk-RRAIFS3D.mjs";import"../chunk-HD6YYUHO.mjs";import"../chunk-JF5YGNCO.mjs";import"../chunk-V7DKESTM.mjs";import"../chunk-377WQNCB.mjs";import"../chunk-HA5XD5KC.mjs";import"../chunk-V2J3R5IU.mjs";import"../chunk-2ML63TYF.mjs";export{b as None,c as Option,a as Some};
|
package/dist/set/Set.d.mts
CHANGED
package/dist/set/Set.d.ts
CHANGED
package/dist/set/Set.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk52OPFRS2js = require('../chunk-52OPFRS2.js');require('../chunk-OXLZ6UIZ.js');require('../chunk-BNNK42JC.js');require('../chunk-2U34DUZU.js');require('../chunk-SQWNJC6O.js');require('../chunk-5O6YELD3.js');require('../chunk-5VTXJIR3.js');require('../chunk-3VJERXBP.js');require('../chunk-XORABVON.js');require('../chunk-K3EKBPQE.js');exports.Set = _chunk52OPFRS2js.f;
|
package/dist/set/Set.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{f as a}from"../chunk-
|
|
1
|
+
import{f as a}from"../chunk-QBAH7SOA.mjs";import"../chunk-2I2NKDFN.mjs";import"../chunk-RRAIFS3D.mjs";import"../chunk-HD6YYUHO.mjs";import"../chunk-JF5YGNCO.mjs";import"../chunk-V7DKESTM.mjs";import"../chunk-377WQNCB.mjs";import"../chunk-HA5XD5KC.mjs";import"../chunk-V2J3R5IU.mjs";import"../chunk-2ML63TYF.mjs";export{a as Set};
|
package/dist/try/Try.d.mts
CHANGED
package/dist/try/Try.d.ts
CHANGED
package/dist/try/Try.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk52OPFRS2js = require('../chunk-52OPFRS2.js');require('../chunk-OXLZ6UIZ.js');require('../chunk-BNNK42JC.js');require('../chunk-2U34DUZU.js');require('../chunk-SQWNJC6O.js');require('../chunk-5O6YELD3.js');require('../chunk-5VTXJIR3.js');require('../chunk-3VJERXBP.js');require('../chunk-XORABVON.js');require('../chunk-K3EKBPQE.js');exports.Try = _chunk52OPFRS2js.w;
|
package/dist/try/Try.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{w as a}from"../chunk-
|
|
1
|
+
import{w as a}from"../chunk-QBAH7SOA.mjs";import"../chunk-2I2NKDFN.mjs";import"../chunk-RRAIFS3D.mjs";import"../chunk-HD6YYUHO.mjs";import"../chunk-JF5YGNCO.mjs";import"../chunk-V7DKESTM.mjs";import"../chunk-377WQNCB.mjs";import"../chunk-HA5XD5KC.mjs";import"../chunk-V2J3R5IU.mjs";import"../chunk-2ML63TYF.mjs";export{a as Try};
|
package/dist/util/index.d.mts
CHANGED
package/dist/util/index.d.ts
CHANGED
package/dist/util/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkE6RS47F7js = require('../chunk-E6RS47F7.js');var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkE6RS47F7js = require('../chunk-E6RS47F7.js');var _chunk52OPFRS2js = require('../chunk-52OPFRS2.js');require('../chunk-OXLZ6UIZ.js');require('../chunk-BNNK42JC.js');require('../chunk-2U34DUZU.js');require('../chunk-SQWNJC6O.js');require('../chunk-5O6YELD3.js');require('../chunk-5VTXJIR3.js');require('../chunk-3VJERXBP.js');require('../chunk-XORABVON.js');require('../chunk-K3EKBPQE.js');var a=o=>{let r=parseInt(o,10);return isNaN(r)?_chunk52OPFRS2js.j.call(void 0, _chunkE6RS47F7js.a.call(void 0, `${r}`)):_chunk52OPFRS2js.i.call(void 0, r)};exports.parseNumber = a;
|
package/dist/util/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as s}from"../chunk-VK5GL6NM.mjs";import{i as e,j as t}from"../chunk-
|
|
1
|
+
import{a as s}from"../chunk-VK5GL6NM.mjs";import{i as e,j as t}from"../chunk-QBAH7SOA.mjs";import"../chunk-2I2NKDFN.mjs";import"../chunk-RRAIFS3D.mjs";import"../chunk-HD6YYUHO.mjs";import"../chunk-JF5YGNCO.mjs";import"../chunk-V7DKESTM.mjs";import"../chunk-377WQNCB.mjs";import"../chunk-HA5XD5KC.mjs";import"../chunk-V2J3R5IU.mjs";import"../chunk-2ML63TYF.mjs";var a=o=>{let r=parseInt(o,10);return isNaN(r)?t(s(`${r}`)):e(r)};export{a as parseNumber};
|
|
@@ -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,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
|
+
};
|
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 {};
|
package/lib/map/Map.d.ts
ADDED
|
@@ -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,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 {};
|
package/lib/set/Set.d.ts
ADDED
|
@@ -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>;
|
package/lib/try/Try.d.ts
ADDED
|
@@ -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 @@
|
|
|
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.
|
|
3
|
+
"version": "0.8.35",
|
|
4
4
|
"description": "A smallish functional library for TypeScript",
|
|
5
5
|
"author": "jordan.burke@gmail.com",
|
|
6
6
|
"license": "MIT",
|
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
"@eslint/js": "^9.14.0",
|
|
17
17
|
"@types/jest": "29.5.14",
|
|
18
18
|
"@types/node": "^22.9.0",
|
|
19
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
20
|
-
"@typescript-eslint/parser": "^8.
|
|
19
|
+
"@typescript-eslint/eslint-plugin": "^8.14.0",
|
|
20
|
+
"@typescript-eslint/parser": "^8.14.0",
|
|
21
21
|
"cross-env": "^7.0.3",
|
|
22
22
|
"eslint": "^9.14.0",
|
|
23
23
|
"eslint-config-prettier": "^9.1.0",
|
package/dist/chunk-HSSHSCKD.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as O}from"./chunk-2I2NKDFN.mjs";import{a as g}from"./chunk-RRAIFS3D.mjs";import{a as _}from"./chunk-JF5YGNCO.mjs";import{a as V}from"./chunk-HD6YYUHO.mjs";import{a as E}from"./chunk-377WQNCB.mjs";import{a as x}from"./chunk-HA5XD5KC.mjs";import te from"safe-stable-stringify";import w from"safe-stable-stringify";import Q from"safe-stable-stringify";import J from"safe-stable-stringify";var c=e=>{let t=g(e)?e:e instanceof Object&&"toArray"in e?e.toArray():[],r=Array.from(t),l="Seq";return{[Symbol.iterator]:()=>r[Symbol.iterator](),get length(){return r.length},_tag:l,map:o=>c(r.map(o)),flatMap:o=>c(r.flatMap(n=>o(n).toArray())),forEach:o=>r.forEach(o),count:o=>r.filter(o).length,exists:o=>r.some(o),filter:o=>c(r.filter(o)),filterNot:o=>c(r.filter(n=>!o(n))),find:o=>L(r.find(o)),get head(){return r[0]},get headOption(){return r.length>0?L(r[0]):A()},get isEmpty(){return r.length===0},get size(){return r.length},toArray:()=>[...r],reduce:o=>r.reduce(o),reduceRight:o=>r.reduceRight(o),foldLeft:o=>n=>r.reduce(n,o),foldRight:o=>n=>r.reduceRight((u,S)=>n(S,u),o),toString:()=>`Seq(${J(e)})`,toValue:()=>({_tag:l,value:r})}},f=e=>c(e);var R=e=>{let t=g(e)?new x(e):new x(e?.toArray()??[]),r=f(t),l={...r,add:o=>R([...t,o]),remove:o=>{let n=new x(t);return n.delete(o),R(n)},contains:o=>t.has(o),has:o=>t.has(o),map:o=>R(r.map(o)),flatMap:o=>R(r.flatMap(o)),toList:()=>T(t),toSet:()=>l,toString:()=>`Set(${Array.from(t).toString()})`};return l},b=e=>R(e);var d=e=>{function t(n){return n!=null&&typeof n[Symbol.iterator]=="function"}let r=Array.isArray(e)?e:t(e)?Array.from(e):[],l=f(r),o={...l,_tag:"List",length:r.length,map:n=>d(r.map(n)),flatMap:n=>d(l.flatMap(n)),remove:n=>{let u=r.indexOf(n);return o.removeAt(u)},contains:n=>r.includes(n),add:n=>d([...r,n]),removeAt:n=>n<0||n>=r.length?o:d([...r.slice(0,n),...r.slice(n+1)]),get:n=>L(r[n]),concat:n=>d([...r,...n.toArray()]),toList:()=>o,toSet:()=>b(r),toValue:()=>({_tag:"List",value:r}),toString:()=>`List(${Q(T(r))})`};return new Proxy(o,{get(n,u){return typeof u=="symbol"||isNaN(Number(u))?n[u]:n.get(Number(u))}})},T=e=>d(e),W=e=>d(e);console.assert(W);var K=e=>({_tag:"Right",value:e,isLeft:()=>!1,isRight:()=>!0,getOrElse:t=>e,getOrThrow:()=>e,map:t=>s(t(e)),mapAsync:t=>t(e).then(r=>s(r)).catch(r=>Promise.resolve(a(r))),merge:t=>t.isLeft()?a(t.value):s([e,t.value]),flatMap:t=>t(e),flatMapAsync:t=>t(e).catch(r=>a(r)),toOption:()=>y(e),toList:()=>T([e]),toString:()=>`Right(${w(e)})`,[Symbol.iterator]:function*(){yield e},yield:function*(){yield e},traverse:t=>{let r=t(e);return r.isLeft()?a(r.value):s([r.value])},lazyMap:function*(t){yield s(t(e))},tap:t=>(t(e),s(e)),tapLeft:t=>s(e),mapLeft:t=>s(e),bimap:(t,r)=>s(r(e)),fold:(t,r)=>r(e),swap:()=>a(e),then:(t,r)=>Promise.resolve(e).then(t,r)}),I=e=>({_tag:"Left",value:e,isLeft:()=>!0,isRight:()=>!1,getOrElse:t=>t,getOrThrow:()=>{throw e},map:t=>a(e),mapAsync:t=>Promise.resolve(a(e)),merge:t=>a(e),flatMap:t=>a(e),flatMapAsync:t=>Promise.resolve(a(e)),toOption:()=>A(),toList:()=>T(),toString:()=>`Left(${w(e)})`,[Symbol.iterator]:function*(){},yield:function*(){},traverse:t=>a(e),lazyMap:function*(t){yield a(e)},tap:t=>a(e),tapLeft:t=>(t(e),a(e)),mapLeft:t=>a(t(e)),bimap:(t,r)=>a(t(e)),fold:(t,r)=>t(e),swap:()=>s(e),then:(t,r)=>Promise.reject(e).then(null,r)}),s=e=>K(e),a=e=>I(e),ve=e=>e.isRight(),Ve=e=>e.isLeft(),Oe=(e,t)=>{try{return s(e())}catch(r){return a(t(r))}},X=e=>K(e);console.assert(X);var Y=e=>I(e);console.assert(Y);var we=async(e,t)=>{try{let r=await e();return s(r)}catch(r){return a(t(r))}},Z={sequence:e=>{let t=[];for(let r of e){if(r.isLeft())return a(r.value);t.push(r.value)}return s(t)},traverse:(e,t)=>Z.sequence(e.map(t)),fromNullable:(e,t)=>e==null?a(t):s(e),fromPredicate:(e,t,r)=>t(e)?s(e):a(r),ap:(e,t)=>e.flatMap(r=>t.map(r)),fromPromise:async(e,t)=>{try{let r=await e;return s(r)}catch(r){return a(t(r))}}};var U=(e,t)=>{let r=V(e,t);return{..._("AppException"),...a(r)}},B=e=>({..._("AppResult"),...s(e)});function M(e,t=r=>r){try{return B(e())}catch(r){return U(t(r))}}M.success=e=>B(e);M.fail=e=>U(e);async function k(e,t=r=>r){try{let r=await e();return B(r)}catch(r){let l=await t(r);return U(l)}}k.success=e=>B(e);k.fail=e=>U(e);var m=e=>{let t={values:new E(e)},r=()=>Array.from(t.values.entries()).map(([i,p])=>O([i,p])),l=i=>m(new E(t.values).set(i.toArray()[0],i.toArray()[1]).entries()),o=i=>{let p=new E(t.values);return p.delete(i)?m(p.entries()):m(t.values.entries())},n=i=>t.values.get(i[0])===i[1],u=()=>t.values.size,S=i=>m(Array.from(t.values.entries()).map(([p,H])=>[p,i(H)])),z=i=>{let p=m(t.values.entries()).toList();return m(p.flatMap(i).toArray())},N=i=>f(r()).reduce(i),F=i=>f(r()).reduceRight(i),C=i=>p=>f(r()).foldLeft(i)(p),$=i=>p=>f(r()).foldRight(i)(p),j=i=>L(t.values.get(i)),G=(i,p)=>L(t.values.get(i)).getOrElse(p),D=()=>t.values.size===0;return{add:l,remove:o,contains:n,get size(){return u()},map:S,flatMap:z,reduce:N,reduceRight:F,foldLeft:C,foldRight:$,get:j,getOrElse:G,get isEmpty(){return D()},orElse:(i,p)=>L(t.values.get(i)).orElse(p),toList:()=>T(r()),toSet:()=>b(r()),toString:()=>`Map(${r().toString()})`}},He=e=>m(e);import P from"safe-stable-stringify";var q=e=>({_tag:"Success",value:e,error:void 0,isSuccess:()=>!0,isFailure:()=>!1,get:()=>e,getOrElse:t=>e,orElse:t=>q(e),orThrow:t=>e,toEither:()=>s(e),map:t=>ee(()=>t(e)),flatMap:t=>t(e),toString:()=>`Success(${P(e)})`}),v=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:()=>a(e),map:t=>v(e),flatMap:t=>v(e),toString:()=>`Failure(${P(e)}))`}),ee=e=>{try{return q(e())}catch(t){return v(t instanceof Error?t:new Error(String(t)))}};var y=e=>({_tag:"Some",value:e,isEmpty:!1,get:()=>e,getOrElse:()=>e,getOrThrow:()=>e,orElse:()=>y(e),map:t=>y(t(e)),filter(t){return t(e)?y(e):h},flatMap:t=>t(e),reduce:t=>t(void 0,e),reduceRight:t=>t(void 0,e),foldLeft:t=>r=>r(t,e),foldRight:t=>r=>r(e,t),toList:()=>T([e]),contains:t=>t===e,size:1,toEither:t=>s(e),toString:()=>`Some(${te(e)})`,toValue:()=>({_tag:"Some",value:e})}),h={_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,map:e=>h,filter(e){return h},flatMap:e=>h,reduce:()=>{},reduceRight:()=>{},foldLeft:e=>()=>e,foldRight:e=>()=>e,toList:()=>T([]),contains:()=>!1,size:0,toEither:e=>a(e),toString:()=>"None",toValue:()=>({_tag:"None",value:void 0})},A=()=>h,L=e=>e!=null?y(e):A();export{y as a,A as b,L as c,c as d,f as e,b as f,T as g,W as h,s as i,a as j,ve as k,Ve as l,Oe as m,X as n,Y as o,we as p,Z as q,U as r,B as s,M as t,k as u,He as v,ee as w};
|