functype 0.0.6 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-3BACPU2L.mjs +1 -0
- package/dist/chunk-4BM7WJEY.js +1 -0
- package/dist/chunk-7F7OFOVC.mjs +1 -0
- package/dist/chunk-CFYIJKWF.mjs +1 -0
- package/dist/chunk-CMWFJ4NE.mjs +1 -0
- package/dist/chunk-ERJUPNUS.mjs +1 -0
- package/dist/chunk-IRUJTPRV.js +1 -0
- package/dist/chunk-QK32BSMQ.js +1 -0
- package/dist/chunk-RSJUG4F6.js +1 -0
- package/dist/chunk-SHAM4BB3.js +1 -0
- package/dist/chunk-T4ZDAXL2.mjs +1 -0
- package/dist/chunk-TAF2HXL3.mjs +1 -0
- package/dist/chunk-U5EUM74A.mjs +1 -0
- package/dist/chunk-VTKL7OQI.js +1 -1
- package/dist/chunk-ZQN22FM6.js +1 -0
- package/dist/chunk-ZTL76QDL.js +1 -1
- package/dist/either/Left.d.mts +2 -0
- package/dist/either/Left.js +1 -1
- package/dist/either/Left.mjs +1 -0
- package/dist/either/Right.d.mts +2 -0
- package/dist/either/Right.js +1 -1
- package/dist/either/Right.mjs +1 -0
- package/dist/either/index.d.mts +2 -0
- package/dist/either/index.d.ts +1 -1
- package/dist/either/index.js +1 -1
- package/dist/either/index.mjs +1 -0
- package/dist/error/ParseError.js +1 -1
- package/dist/error/ParseError.mjs +1 -0
- package/dist/index.d.mts +117 -0
- package/dist/index.d.ts +73 -19
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -0
- package/dist/list/List.d.mts +2 -0
- package/dist/list/List.js +1 -1
- package/dist/list/List.mjs +1 -0
- package/dist/list/index.d.mts +2 -0
- package/dist/list/index.d.ts +2 -0
- package/dist/list/index.js +1 -0
- package/dist/list/index.mjs +1 -0
- package/dist/map/Map.d.mts +2 -0
- package/dist/map/Map.d.ts +2 -0
- package/dist/map/Map.js +1 -0
- package/dist/map/Map.mjs +1 -0
- package/dist/map/index.d.mts +9 -0
- package/dist/map/index.d.ts +9 -0
- package/dist/map/index.js +1 -0
- package/dist/map/index.mjs +0 -0
- package/dist/option/None.d.mts +2 -0
- package/dist/option/None.d.ts +2 -0
- package/dist/option/None.js +1 -0
- package/dist/option/None.mjs +1 -0
- package/dist/option/Some.d.mts +2 -0
- package/dist/option/Some.d.ts +2 -0
- package/dist/option/Some.js +1 -0
- package/dist/option/Some.mjs +1 -0
- package/dist/option/index.d.mts +2 -0
- package/dist/option/index.d.ts +2 -0
- package/dist/option/index.js +1 -0
- package/dist/option/index.mjs +1 -0
- package/package.json +12 -6
- package/dist/chunk-4EVP3IRI.cjs +0 -1
- package/dist/chunk-6VKVA3TK.cjs +0 -1
- package/dist/chunk-ABUN2GHU.js +0 -1
- package/dist/chunk-CB3ZZ3RL.cjs +0 -1
- package/dist/chunk-CN6MP6AJ.js +0 -1
- package/dist/chunk-E4GBAXJ4.js +0 -1
- package/dist/chunk-GWLTG6GZ.cjs +0 -1
- package/dist/chunk-HWJMIJH6.cjs +0 -1
- package/dist/chunk-PXY4XULG.cjs +0 -1
- package/dist/chunk-QK5JVYJ3.js +0 -1
- package/dist/either/Left.cjs +0 -1
- package/dist/either/Left.d.cts +0 -2
- package/dist/either/Right.cjs +0 -1
- package/dist/either/Right.d.cts +0 -2
- package/dist/either/index.cjs +0 -1
- package/dist/either/index.d.cts +0 -2
- package/dist/error/ParseError.cjs +0 -1
- package/dist/index.cjs +0 -1
- package/dist/index.d.cts +0 -63
- package/dist/list/List.cjs +0 -1
- package/dist/list/List.d.cts +0 -2
- /package/dist/error/{ParseError.d.cts → ParseError.d.mts} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as n}from"./chunk-U5EUM74A.mjs";var m=class s{constructor(t){n(this,"items");this.items=t?[...t]:[]}isEmpty(){return this.items.length===0}get length(){return this.items.length}add(t){let e=new Map;return new s([...this.items,t])}removeAt(t){if(t<0||t>=this.items.length)return this;let e=[...this.items.slice(0,t),...this.items.slice(t+1)];return new s(e)}get(t){return this.items[t]}toArray(){return this.items}map(t){return new s(this.items.map(t))}flatMap(t){let e=[];for(let r of this.items){let i=t(r);i instanceof s&&e.push(...i.items)}return new s(e)}reduce(t){return this.items.reduce(t,void 0)}foldLeft(t,e){return this.items.reduce(e,t)}foldRight(t,e){return this.items.reduceRight((r,i)=>e(i,r),t)}concat(t){return new s([...this.items,...t.items])}toString(){return`List(${this.items.toString()})`}};export{m as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkVTKL7OQIjs = require('./chunk-VTKL7OQI.js');var m=class s{constructor(t){_chunkVTKL7OQIjs.a.call(void 0, this,"items");this.items=t?[...t]:[]}isEmpty(){return this.items.length===0}get length(){return this.items.length}add(t){let e=new Map;return new s([...this.items,t])}removeAt(t){if(t<0||t>=this.items.length)return this;let e=[...this.items.slice(0,t),...this.items.slice(t+1)];return new s(e)}get(t){return this.items[t]}toArray(){return this.items}map(t){return new s(this.items.map(t))}flatMap(t){let e=[];for(let r of this.items){let i=t(r);i instanceof s&&e.push(...i.items)}return new s(e)}reduce(t){return this.items.reduce(t,void 0)}foldLeft(t,e){return this.items.reduce(e,t)}foldRight(t,e){return this.items.reduceRight((r,i)=>e(i,r),t)}concat(t){return new s([...this.items,...t.items])}toString(){return`List(${this.items.toString()})`}};exports.a = m;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e}from"./chunk-TAF2HXL3.mjs";import{a as o}from"./chunk-ERJUPNUS.mjs";var i=t=>t?n(t):T(),n=t=>new o(t),T=()=>new e;export{i as a,n as b,T as c};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=class extends Error{};export{e as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as s,c as a}from"./chunk-7F7OFOVC.mjs";import{a as n}from"./chunk-CFYIJKWF.mjs";import{a as r}from"./chunk-3BACPU2L.mjs";var i=class e{constructor(t){this.value=t}isLeft(){return!1}isRight(){return!0}map(t){return new e(t(this.value))}flatMap(t){return t(this.value)}toOption(){return s(this.value)}toList(){return new r([this.value])}};var u=e=>new o(e),L=e=>new i(e),c=e=>{let t=parseInt(e,10);return isNaN(t)?u(new n(`${t}`)):L(t)};var o=class e{constructor(t){this.value=t}isLeft(){return!0}isRight(){return!1}map(t){return new e(this.value)}flatMap(t){return new e(this.value)}toOption(){return a()}toList(){return new r}};export{o as a,i as b,u as c,L as d,c as e};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as r}from"./chunk-3BACPU2L.mjs";var a=class u{constructor(t){this.value=t}isEmpty(){return!1}get(){return this.value}getOrElse(t){return this.value}orElse(t){return this}map(t){return new u(t(this.value))}flatMap(t){return t(this.value)}reduce(t){return t(void 0,this.value)}foldLeft(t,e){return e(t,this.value)}foldRight(t,e){return e(this.value,t)}toList(){return new r([this.value])}};export{a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk4BM7WJEYjs = require('./chunk-4BM7WJEY.js');var r=class t{isEmpty(){return!0}get(){throw new Error("Cannot call get() on a None")}getOrElse(e){return e}orElse(e){return e}map(e){return new t}flatMap(e){return new t}reduce(e){return e(void 0,void 0)}foldLeft(e,o){return e}foldRight(e,o){return e}toList(){return new _chunk4BM7WJEYjs.a}};exports.a = r;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk4BM7WJEYjs = require('./chunk-4BM7WJEY.js');var a=class u{constructor(t){this.value=t}isEmpty(){return!1}get(){return this.value}getOrElse(t){return this.value}orElse(t){return this}map(t){return new u(t(this.value))}flatMap(t){return t(this.value)}reduce(t){return t(void 0,this.value)}foldLeft(t,e){return e(t,this.value)}foldRight(t,e){return e(this.value,t)}toList(){return new (0, _chunk4BM7WJEYjs.a)([this.value])}};exports.a = a;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkIRUJTPRVjs = require('./chunk-IRUJTPRV.js');var _chunkQK32BSMQjs = require('./chunk-QK32BSMQ.js');var i=t=>t?n(t):T(),n= exports.b =t=>new (0, _chunkQK32BSMQjs.a)(t),T= exports.c =()=>new _chunkIRUJTPRVjs.a;exports.a = i; exports.b = n; exports.c = T;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk4BM7WJEYjs = require('./chunk-4BM7WJEY.js');var U=a=>new (0, _chunk4BM7WJEYjs.a)(a);exports.a = U;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e}from"./chunk-3BACPU2L.mjs";var U=a=>new e(a);export{U as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as n}from"./chunk-3BACPU2L.mjs";var r=class t{isEmpty(){return!0}get(){throw new Error("Cannot call get() on a None")}getOrElse(e){return e}orElse(e){return e}map(e){return new t}flatMap(e){return new t}reduce(e){return e(void 0,void 0)}foldLeft(e,o){return e}foldRight(e,o){return e}toList(){return new n}};export{r as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var d=Object.defineProperty;var e=(b,a,c)=>a in b?d(b,a,{enumerable:!0,configurable:!0,writable:!0,value:c}):b[a]=c;var f=(b,a,c)=>(e(b,typeof a!="symbol"?a+"":a,c),c);export{f as a};
|
package/dist/chunk-VTKL7OQI.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var d=Object.defineProperty;var e=(b,a,c)=>a in b?d(b,a,{enumerable:!0,configurable:!0,writable:!0,value:c}):b[a]=c;var f=(b,a,c)=>(e(b,typeof a!="symbol"?a+"":a,c),c);
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var d=Object.defineProperty;var e=(b,a,c)=>a in b?d(b,a,{enumerable:!0,configurable:!0,writable:!0,value:c}):b[a]=c;var f=(b,a,c)=>(e(b,typeof a!="symbol"?a+"":a,c),c);exports.a = f;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkRSJUG4F6js = require('./chunk-RSJUG4F6.js');var _chunkZTL76QDLjs = require('./chunk-ZTL76QDL.js');var _chunk4BM7WJEYjs = require('./chunk-4BM7WJEY.js');var i=class e{constructor(t){this.value=t}isLeft(){return!1}isRight(){return!0}map(t){return new e(t(this.value))}flatMap(t){return t(this.value)}toOption(){return _chunkRSJUG4F6js.b.call(void 0, this.value)}toList(){return new (0, _chunk4BM7WJEYjs.a)([this.value])}};var u=e=>new o(e),L= exports.d =e=>new i(e),c= exports.e =e=>{let t=parseInt(e,10);return isNaN(t)?u(new (0, _chunkZTL76QDLjs.a)(`${t}`)):L(t)};var o=class e{constructor(t){this.value=t}isLeft(){return!0}isRight(){return!1}map(t){return new e(this.value)}flatMap(t){return new e(this.value)}toOption(){return _chunkRSJUG4F6js.c.call(void 0, )}toList(){return new _chunk4BM7WJEYjs.a}};exports.a = o; exports.b = i; exports.c = u; exports.d = L; exports.e = c;
|
package/dist/chunk-ZTL76QDL.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var e=class extends Error{};
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var e=class extends Error{};exports.a = e;
|
package/dist/either/Left.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkZQN22FM6js = require('../chunk-ZQN22FM6.js');require('../chunk-RSJUG4F6.js');require('../chunk-IRUJTPRV.js');require('../chunk-QK32BSMQ.js');require('../chunk-ZTL76QDL.js');require('../chunk-SHAM4BB3.js');require('../chunk-4BM7WJEY.js');require('../chunk-VTKL7OQI.js');exports.Left = _chunkZQN22FM6js.a;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a}from"../chunk-CMWFJ4NE.mjs";import"../chunk-7F7OFOVC.mjs";import"../chunk-TAF2HXL3.mjs";import"../chunk-ERJUPNUS.mjs";import"../chunk-CFYIJKWF.mjs";import"../chunk-T4ZDAXL2.mjs";import"../chunk-3BACPU2L.mjs";import"../chunk-U5EUM74A.mjs";export{a as Left};
|
package/dist/either/Right.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkZQN22FM6js = require('../chunk-ZQN22FM6.js');require('../chunk-RSJUG4F6.js');require('../chunk-IRUJTPRV.js');require('../chunk-QK32BSMQ.js');require('../chunk-ZTL76QDL.js');require('../chunk-SHAM4BB3.js');require('../chunk-4BM7WJEY.js');require('../chunk-VTKL7OQI.js');exports.Right = _chunkZQN22FM6js.b;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as a}from"../chunk-CMWFJ4NE.mjs";import"../chunk-7F7OFOVC.mjs";import"../chunk-TAF2HXL3.mjs";import"../chunk-ERJUPNUS.mjs";import"../chunk-CFYIJKWF.mjs";import"../chunk-T4ZDAXL2.mjs";import"../chunk-3BACPU2L.mjs";import"../chunk-U5EUM74A.mjs";export{a as Right};
|
package/dist/either/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import '../error/ParseError.js';
|
|
2
|
-
export { Either, left, parseNumber, right } from '../index.js';
|
|
2
|
+
export { Either, Left, Right, left, parseNumber, right } from '../index.js';
|
package/dist/either/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkZQN22FM6js = require('../chunk-ZQN22FM6.js');require('../chunk-RSJUG4F6.js');require('../chunk-IRUJTPRV.js');require('../chunk-QK32BSMQ.js');require('../chunk-ZTL76QDL.js');require('../chunk-SHAM4BB3.js');require('../chunk-4BM7WJEY.js');require('../chunk-VTKL7OQI.js');exports.Left = _chunkZQN22FM6js.a; exports.Right = _chunkZQN22FM6js.b; exports.left = _chunkZQN22FM6js.c; exports.parseNumber = _chunkZQN22FM6js.e; exports.right = _chunkZQN22FM6js.d;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a,b,c,d,e}from"../chunk-CMWFJ4NE.mjs";import"../chunk-7F7OFOVC.mjs";import"../chunk-TAF2HXL3.mjs";import"../chunk-ERJUPNUS.mjs";import"../chunk-CFYIJKWF.mjs";import"../chunk-T4ZDAXL2.mjs";import"../chunk-3BACPU2L.mjs";import"../chunk-U5EUM74A.mjs";export{a as Left,b as Right,c as left,e as parseNumber,d as right};
|
package/dist/error/ParseError.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkZTL76QDLjs = require('../chunk-ZTL76QDL.js');require('../chunk-VTKL7OQI.js');exports.ParseError = _chunkZTL76QDLjs.a;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a}from"../chunk-CFYIJKWF.mjs";import"../chunk-U5EUM74A.mjs";export{a as ParseError};
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { ParseError } from './error/ParseError.mjs';
|
|
2
|
+
|
|
3
|
+
declare class Left<L, R> implements Either<L, R> {
|
|
4
|
+
value: L;
|
|
5
|
+
constructor(value: L);
|
|
6
|
+
isLeft(): this is Left<L, R>;
|
|
7
|
+
isRight(): this is Right<L, R>;
|
|
8
|
+
map<U>(_f: (value: R) => U): Either<L, U>;
|
|
9
|
+
flatMap<U>(_f: (value: R) => Either<L, U>): Either<L, U>;
|
|
10
|
+
toOption(): Option<R>;
|
|
11
|
+
toList(): List<R>;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
declare class Right<L, R> implements Either<L, R> {
|
|
15
|
+
value: R;
|
|
16
|
+
constructor(value: R);
|
|
17
|
+
isLeft(): this is Left<L, R>;
|
|
18
|
+
isRight(): this is Right<L, R>;
|
|
19
|
+
map<U>(f: (value: R) => U): Either<L, U>;
|
|
20
|
+
flatMap<U>(f: (value: R) => Either<L, U>): Either<L, U>;
|
|
21
|
+
toOption(): Option<R>;
|
|
22
|
+
toList(): List<R>;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
interface Either<L, R> extends IFunctor<R> {
|
|
26
|
+
value: L | R;
|
|
27
|
+
isLeft(): this is Left<L, R>;
|
|
28
|
+
isRight(): this is Right<L, R>;
|
|
29
|
+
map<U>(f: (value: R) => U): Either<L, U>;
|
|
30
|
+
flatMap<U>(f: (value: R) => Either<L, U>): Either<L, U>;
|
|
31
|
+
toOption(): Option<R>;
|
|
32
|
+
toList(): List<R>;
|
|
33
|
+
}
|
|
34
|
+
declare const left: <L, R>(value: L) => Either<L, R>;
|
|
35
|
+
declare const right: <L, R>(value: R) => Either<L, R>;
|
|
36
|
+
declare const parseNumber: (input: string) => Either<ParseError, number>;
|
|
37
|
+
|
|
38
|
+
declare class List<T> implements IList<T> {
|
|
39
|
+
private readonly items;
|
|
40
|
+
constructor(items?: T[]);
|
|
41
|
+
readonly [n: number]: T;
|
|
42
|
+
isEmpty(): boolean;
|
|
43
|
+
get length(): number;
|
|
44
|
+
add(item: T): List<T>;
|
|
45
|
+
removeAt(index: number): List<T>;
|
|
46
|
+
get(index: number): T | undefined;
|
|
47
|
+
toArray(): readonly T[];
|
|
48
|
+
map<U>(f: (value: T) => U): List<U>;
|
|
49
|
+
flatMap<U>(f: (value: T) => List<U>): List<U>;
|
|
50
|
+
reduce<U>(f: (acc: U, value: T) => U): U;
|
|
51
|
+
foldLeft<U>(initialValue: U, f: (acc: U, value: T) => U): U;
|
|
52
|
+
foldRight<U>(initialValue: U, f: (value: T, acc: U) => U): U;
|
|
53
|
+
concat(other: List<T>): List<T>;
|
|
54
|
+
toString(): string;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
interface IList<T> extends IFunctor<T>, ITraversable<T>, ArrayLike<T> {
|
|
58
|
+
map<U>(f: (value: T) => U): IList<U>;
|
|
59
|
+
flatMap<U>(f: (value: T) => IList<U>): IList<U>;
|
|
60
|
+
reduce<U>(f: (acc: U, value: T) => U): U;
|
|
61
|
+
foldLeft<U>(initialValue: U, f: (acc: U, value: T) => U): U;
|
|
62
|
+
foldRight<U>(initialValue: U, f: (value: T, acc: U) => U): U;
|
|
63
|
+
}
|
|
64
|
+
declare const list: <T>(items: T[] | undefined) => List<T>;
|
|
65
|
+
|
|
66
|
+
declare class Some<T> implements Option<T> {
|
|
67
|
+
private value;
|
|
68
|
+
constructor(value: T);
|
|
69
|
+
isEmpty(): boolean;
|
|
70
|
+
get(): T;
|
|
71
|
+
getOrElse(defaultValue: T): T;
|
|
72
|
+
orElse(alternative: Option<T>): Option<T>;
|
|
73
|
+
map<U>(f: (value: T) => U): Option<U>;
|
|
74
|
+
flatMap<U>(f: (value: T) => Option<U>): Option<U>;
|
|
75
|
+
reduce<U>(f: (acc: U, value: T) => U): U;
|
|
76
|
+
foldLeft<U>(initialValue: U, f: (acc: U, value: T) => U): U;
|
|
77
|
+
foldRight<U>(initialValue: U, f: (value: T, acc: U) => U): U;
|
|
78
|
+
toList(): List<T>;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
declare class None<T> implements Option<T> {
|
|
82
|
+
isEmpty(): boolean;
|
|
83
|
+
get(): T;
|
|
84
|
+
getOrElse(defaultValue: T): T;
|
|
85
|
+
orElse(alternative: Option<T>): Option<T>;
|
|
86
|
+
map<U>(f: (value: T) => U): Option<U>;
|
|
87
|
+
flatMap<U>(f: (value: T) => Option<U>): Option<U>;
|
|
88
|
+
reduce<U>(f: (acc: U, value: T) => U): U;
|
|
89
|
+
foldLeft<U>(initialValue: U, f: (acc: U, value: T) => U): U;
|
|
90
|
+
foldRight<U>(initialValue: U, f: (value: T, acc: U) => U): U;
|
|
91
|
+
toList(): List<T>;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
interface Option<T> extends IFunctor<T>, ITraversable<T> {
|
|
95
|
+
get(): T;
|
|
96
|
+
getOrElse(defaultValue: T): T;
|
|
97
|
+
orElse(alternative: Option<T>): Option<T>;
|
|
98
|
+
map<U>(f: (value: T) => U): Option<U>;
|
|
99
|
+
flatMap<U>(f: (value: T) => Option<U>): Option<U>;
|
|
100
|
+
toList(): List<T>;
|
|
101
|
+
}
|
|
102
|
+
declare const option: <T>(value?: T | undefined) => Option<T>;
|
|
103
|
+
declare const some: <T>(value: T) => Option<T>;
|
|
104
|
+
declare const none: <T>() => Option<T>;
|
|
105
|
+
|
|
106
|
+
interface IFunctor<T> {
|
|
107
|
+
map<U>(f: (value: T) => U): IFunctor<U>;
|
|
108
|
+
flatMap<U>(f: (value: T) => IFunctor<U>): IFunctor<U>;
|
|
109
|
+
}
|
|
110
|
+
interface ITraversable<T> {
|
|
111
|
+
isEmpty(): boolean;
|
|
112
|
+
reduce<U>(f: (acc: U, value: T) => U): U;
|
|
113
|
+
foldLeft<U>(initialValue: U, f: (acc: U, value: T) => U): U;
|
|
114
|
+
foldRight<U>(initialValue: U, f: (value: T, acc: U) => U): U;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export { Either, IFunctor, IList, ITraversable, Left, List, None, Option, Right, Some, left, list, none, option, parseNumber, right, some };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,17 +1,5 @@
|
|
|
1
1
|
import { ParseError } from './error/ParseError.js';
|
|
2
2
|
|
|
3
|
-
declare class Right<L, R> implements Either<L, R> {
|
|
4
|
-
value: R;
|
|
5
|
-
constructor(value: R);
|
|
6
|
-
isLeft(): this is Left<L, R>;
|
|
7
|
-
isRight(): this is Right<L, R>;
|
|
8
|
-
map<U>(f: (value: R) => U): Either<L, U>;
|
|
9
|
-
flatMap<U>(f: (value: R) => Either<L, U>): Either<L, U>;
|
|
10
|
-
reduce<U>(f: (acc: U, value: R) => U): IFunctor<U>;
|
|
11
|
-
foldLeft<U>(initialValue: U, f: (acc: U, value: R) => U): U;
|
|
12
|
-
foldRight<U>(initialValue: U, f: (value: R, acc: U) => U): U;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
3
|
declare class Left<L, R> implements Either<L, R> {
|
|
16
4
|
value: L;
|
|
17
5
|
constructor(value: L);
|
|
@@ -19,9 +7,19 @@ declare class Left<L, R> implements Either<L, R> {
|
|
|
19
7
|
isRight(): this is Right<L, R>;
|
|
20
8
|
map<U>(_f: (value: R) => U): Either<L, U>;
|
|
21
9
|
flatMap<U>(_f: (value: R) => Either<L, U>): Either<L, U>;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
10
|
+
toOption(): Option<R>;
|
|
11
|
+
toList(): List<R>;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
declare class Right<L, R> implements Either<L, R> {
|
|
15
|
+
value: R;
|
|
16
|
+
constructor(value: R);
|
|
17
|
+
isLeft(): this is Left<L, R>;
|
|
18
|
+
isRight(): this is Right<L, R>;
|
|
19
|
+
map<U>(f: (value: R) => U): Either<L, U>;
|
|
20
|
+
flatMap<U>(f: (value: R) => Either<L, U>): Either<L, U>;
|
|
21
|
+
toOption(): Option<R>;
|
|
22
|
+
toList(): List<R>;
|
|
25
23
|
}
|
|
26
24
|
|
|
27
25
|
interface Either<L, R> extends IFunctor<R> {
|
|
@@ -30,14 +28,18 @@ interface Either<L, R> extends IFunctor<R> {
|
|
|
30
28
|
isRight(): this is Right<L, R>;
|
|
31
29
|
map<U>(f: (value: R) => U): Either<L, U>;
|
|
32
30
|
flatMap<U>(f: (value: R) => Either<L, U>): Either<L, U>;
|
|
31
|
+
toOption(): Option<R>;
|
|
32
|
+
toList(): List<R>;
|
|
33
33
|
}
|
|
34
34
|
declare const left: <L, R>(value: L) => Either<L, R>;
|
|
35
35
|
declare const right: <L, R>(value: R) => Either<L, R>;
|
|
36
36
|
declare const parseNumber: (input: string) => Either<ParseError, number>;
|
|
37
37
|
|
|
38
|
-
declare class List<T> implements
|
|
38
|
+
declare class List<T> implements IList<T> {
|
|
39
39
|
private readonly items;
|
|
40
40
|
constructor(items?: T[]);
|
|
41
|
+
readonly [n: number]: T;
|
|
42
|
+
isEmpty(): boolean;
|
|
41
43
|
get length(): number;
|
|
42
44
|
add(item: T): List<T>;
|
|
43
45
|
removeAt(index: number): List<T>;
|
|
@@ -45,19 +47,71 @@ declare class List<T> implements IFunctor<T> {
|
|
|
45
47
|
toArray(): readonly T[];
|
|
46
48
|
map<U>(f: (value: T) => U): List<U>;
|
|
47
49
|
flatMap<U>(f: (value: T) => List<U>): List<U>;
|
|
48
|
-
reduce<U>(f: (acc: U, value: T) => U):
|
|
50
|
+
reduce<U>(f: (acc: U, value: T) => U): U;
|
|
49
51
|
foldLeft<U>(initialValue: U, f: (acc: U, value: T) => U): U;
|
|
50
52
|
foldRight<U>(initialValue: U, f: (value: T, acc: U) => U): U;
|
|
51
53
|
concat(other: List<T>): List<T>;
|
|
52
54
|
toString(): string;
|
|
53
55
|
}
|
|
54
56
|
|
|
57
|
+
interface IList<T> extends IFunctor<T>, ITraversable<T>, ArrayLike<T> {
|
|
58
|
+
map<U>(f: (value: T) => U): IList<U>;
|
|
59
|
+
flatMap<U>(f: (value: T) => IList<U>): IList<U>;
|
|
60
|
+
reduce<U>(f: (acc: U, value: T) => U): U;
|
|
61
|
+
foldLeft<U>(initialValue: U, f: (acc: U, value: T) => U): U;
|
|
62
|
+
foldRight<U>(initialValue: U, f: (value: T, acc: U) => U): U;
|
|
63
|
+
}
|
|
64
|
+
declare const list: <T>(items: T[] | undefined) => List<T>;
|
|
65
|
+
|
|
66
|
+
declare class Some<T> implements Option<T> {
|
|
67
|
+
private value;
|
|
68
|
+
constructor(value: T);
|
|
69
|
+
isEmpty(): boolean;
|
|
70
|
+
get(): T;
|
|
71
|
+
getOrElse(defaultValue: T): T;
|
|
72
|
+
orElse(alternative: Option<T>): Option<T>;
|
|
73
|
+
map<U>(f: (value: T) => U): Option<U>;
|
|
74
|
+
flatMap<U>(f: (value: T) => Option<U>): Option<U>;
|
|
75
|
+
reduce<U>(f: (acc: U, value: T) => U): U;
|
|
76
|
+
foldLeft<U>(initialValue: U, f: (acc: U, value: T) => U): U;
|
|
77
|
+
foldRight<U>(initialValue: U, f: (value: T, acc: U) => U): U;
|
|
78
|
+
toList(): List<T>;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
declare class None<T> implements Option<T> {
|
|
82
|
+
isEmpty(): boolean;
|
|
83
|
+
get(): T;
|
|
84
|
+
getOrElse(defaultValue: T): T;
|
|
85
|
+
orElse(alternative: Option<T>): Option<T>;
|
|
86
|
+
map<U>(f: (value: T) => U): Option<U>;
|
|
87
|
+
flatMap<U>(f: (value: T) => Option<U>): Option<U>;
|
|
88
|
+
reduce<U>(f: (acc: U, value: T) => U): U;
|
|
89
|
+
foldLeft<U>(initialValue: U, f: (acc: U, value: T) => U): U;
|
|
90
|
+
foldRight<U>(initialValue: U, f: (value: T, acc: U) => U): U;
|
|
91
|
+
toList(): List<T>;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
interface Option<T> extends IFunctor<T>, ITraversable<T> {
|
|
95
|
+
get(): T;
|
|
96
|
+
getOrElse(defaultValue: T): T;
|
|
97
|
+
orElse(alternative: Option<T>): Option<T>;
|
|
98
|
+
map<U>(f: (value: T) => U): Option<U>;
|
|
99
|
+
flatMap<U>(f: (value: T) => Option<U>): Option<U>;
|
|
100
|
+
toList(): List<T>;
|
|
101
|
+
}
|
|
102
|
+
declare const option: <T>(value?: T | undefined) => Option<T>;
|
|
103
|
+
declare const some: <T>(value: T) => Option<T>;
|
|
104
|
+
declare const none: <T>() => Option<T>;
|
|
105
|
+
|
|
55
106
|
interface IFunctor<T> {
|
|
56
107
|
map<U>(f: (value: T) => U): IFunctor<U>;
|
|
57
108
|
flatMap<U>(f: (value: T) => IFunctor<U>): IFunctor<U>;
|
|
58
|
-
|
|
109
|
+
}
|
|
110
|
+
interface ITraversable<T> {
|
|
111
|
+
isEmpty(): boolean;
|
|
112
|
+
reduce<U>(f: (acc: U, value: T) => U): U;
|
|
59
113
|
foldLeft<U>(initialValue: U, f: (acc: U, value: T) => U): U;
|
|
60
114
|
foldRight<U>(initialValue: U, f: (value: T, acc: U) => U): U;
|
|
61
115
|
}
|
|
62
116
|
|
|
63
|
-
export { Either, IFunctor, Left, List, Right, left, parseNumber, right };
|
|
117
|
+
export { Either, IFunctor, IList, ITraversable, Left, List, None, Option, Right, Some, left, list, none, option, parseNumber, right, some };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkZQN22FM6js = require('./chunk-ZQN22FM6.js');var _chunkRSJUG4F6js = require('./chunk-RSJUG4F6.js');var _chunkIRUJTPRVjs = require('./chunk-IRUJTPRV.js');var _chunkQK32BSMQjs = require('./chunk-QK32BSMQ.js');require('./chunk-ZTL76QDL.js');var _chunkSHAM4BB3js = require('./chunk-SHAM4BB3.js');var _chunk4BM7WJEYjs = require('./chunk-4BM7WJEY.js');require('./chunk-VTKL7OQI.js');exports.Left = _chunkZQN22FM6js.a; exports.List = _chunk4BM7WJEYjs.a; exports.None = _chunkIRUJTPRVjs.a; exports.Right = _chunkZQN22FM6js.b; exports.Some = _chunkQK32BSMQjs.a; exports.left = _chunkZQN22FM6js.c; exports.list = _chunkSHAM4BB3js.a; exports.none = _chunkRSJUG4F6js.c; exports.option = _chunkRSJUG4F6js.a; exports.parseNumber = _chunkZQN22FM6js.e; exports.right = _chunkZQN22FM6js.d; exports.some = _chunkRSJUG4F6js.b;
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a,b,c,d,e}from"./chunk-CMWFJ4NE.mjs";import{a as j,b as k,c as l}from"./chunk-7F7OFOVC.mjs";import{a as i}from"./chunk-TAF2HXL3.mjs";import{a as h}from"./chunk-ERJUPNUS.mjs";import"./chunk-CFYIJKWF.mjs";import{a as g}from"./chunk-T4ZDAXL2.mjs";import{a as f}from"./chunk-3BACPU2L.mjs";import"./chunk-U5EUM74A.mjs";export{a as Left,f as List,i as None,b as Right,h as Some,c as left,g as list,l as none,j as option,e as parseNumber,d as right,k as some};
|
package/dist/list/List.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk4BM7WJEYjs = require('../chunk-4BM7WJEY.js');require('../chunk-VTKL7OQI.js');exports.List = _chunk4BM7WJEYjs.a;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a}from"../chunk-3BACPU2L.mjs";import"../chunk-U5EUM74A.mjs";export{a as List};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkSHAM4BB3js = require('../chunk-SHAM4BB3.js');var _chunk4BM7WJEYjs = require('../chunk-4BM7WJEY.js');require('../chunk-VTKL7OQI.js');exports.List = _chunk4BM7WJEYjs.a; exports.list = _chunkSHAM4BB3js.a;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as b}from"../chunk-T4ZDAXL2.mjs";import{a}from"../chunk-3BACPU2L.mjs";import"../chunk-U5EUM74A.mjs";export{a as List,b as list};
|
package/dist/map/Map.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";require('../chunk-RSJUG4F6.js');require('../chunk-IRUJTPRV.js');require('../chunk-QK32BSMQ.js');require('../chunk-SHAM4BB3.js');require('../chunk-4BM7WJEY.js');require('../chunk-VTKL7OQI.js');
|
package/dist/map/Map.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"../chunk-7F7OFOVC.mjs";import"../chunk-TAF2HXL3.mjs";import"../chunk-ERJUPNUS.mjs";import"../chunk-T4ZDAXL2.mjs";import"../chunk-3BACPU2L.mjs";import"../chunk-U5EUM74A.mjs";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { IFunctor, ITraversable } from '../index.mjs';
|
|
2
|
+
import '../error/ParseError.mjs';
|
|
3
|
+
|
|
4
|
+
interface IMap<K, T> extends IFunctor<T>, ITraversable<T> {
|
|
5
|
+
map<U>(f: (value: T) => U): IMap<K, U>;
|
|
6
|
+
flatMap<U>(f: (value: T) => IMap<K, U>): IMap<K, U>;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export { IMap };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { IFunctor, ITraversable } from '../index.js';
|
|
2
|
+
import '../error/ParseError.js';
|
|
3
|
+
|
|
4
|
+
interface IMap<K, T> extends IFunctor<T>, ITraversable<T> {
|
|
5
|
+
map<U>(f: (value: T) => U): IMap<K, U>;
|
|
6
|
+
flatMap<U>(f: (value: T) => IMap<K, U>): IMap<K, U>;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export { IMap };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkIRUJTPRVjs = require('../chunk-IRUJTPRV.js');require('../chunk-SHAM4BB3.js');require('../chunk-4BM7WJEY.js');require('../chunk-VTKL7OQI.js');exports.None = _chunkIRUJTPRVjs.a;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a}from"../chunk-TAF2HXL3.mjs";import"../chunk-T4ZDAXL2.mjs";import"../chunk-3BACPU2L.mjs";import"../chunk-U5EUM74A.mjs";export{a as None};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkQK32BSMQjs = require('../chunk-QK32BSMQ.js');require('../chunk-SHAM4BB3.js');require('../chunk-4BM7WJEY.js');require('../chunk-VTKL7OQI.js');exports.Some = _chunkQK32BSMQjs.a;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a}from"../chunk-ERJUPNUS.mjs";import"../chunk-T4ZDAXL2.mjs";import"../chunk-3BACPU2L.mjs";import"../chunk-U5EUM74A.mjs";export{a as Some};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkRSJUG4F6js = require('../chunk-RSJUG4F6.js');var _chunkIRUJTPRVjs = require('../chunk-IRUJTPRV.js');var _chunkQK32BSMQjs = require('../chunk-QK32BSMQ.js');require('../chunk-SHAM4BB3.js');require('../chunk-4BM7WJEY.js');require('../chunk-VTKL7OQI.js');exports.None = _chunkIRUJTPRVjs.a; exports.Some = _chunkQK32BSMQjs.a; exports.none = _chunkRSJUG4F6js.c; exports.option = _chunkRSJUG4F6js.a; exports.some = _chunkRSJUG4F6js.b;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as c,b as d,c as e}from"../chunk-7F7OFOVC.mjs";import{a as b}from"../chunk-TAF2HXL3.mjs";import{a}from"../chunk-ERJUPNUS.mjs";import"../chunk-T4ZDAXL2.mjs";import"../chunk-3BACPU2L.mjs";import"../chunk-U5EUM74A.mjs";export{b as None,a as Some,e as none,c as option,d as some};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "functype",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8",
|
|
4
4
|
"description": "A small functional library for TypeScript",
|
|
5
5
|
"author": "jordan.burke@gmail.com",
|
|
6
6
|
"license": "MIT",
|
|
@@ -21,13 +21,19 @@
|
|
|
21
21
|
"rimraf": "^5.0.1",
|
|
22
22
|
"tsup": "^7.2.0",
|
|
23
23
|
"ts-jest": "^29.1.1",
|
|
24
|
+
"ts-node": "^10.9.1",
|
|
24
25
|
"typescript": "^5.1.6"
|
|
25
26
|
},
|
|
26
|
-
"main": "dist/index.
|
|
27
|
-
"module": "dist/index.
|
|
28
|
-
"types": "dist/index.d.ts",
|
|
29
|
-
"
|
|
30
|
-
|
|
27
|
+
"main": "./dist/index.js",
|
|
28
|
+
"module": "./dist/index.mjs",
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
30
|
+
"exports": {
|
|
31
|
+
".": {
|
|
32
|
+
"require": "./dist/index.js",
|
|
33
|
+
"import": "./dist/index.mjs",
|
|
34
|
+
"types": "./dist/index.d.ts"
|
|
35
|
+
}
|
|
36
|
+
},
|
|
31
37
|
"files": [
|
|
32
38
|
"lib",
|
|
33
39
|
"dist"
|
package/dist/chunk-4EVP3IRI.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var r=class e{constructor(t){this.value=t}isLeft(){return!0}isRight(){return!1}map(t){return new e(this.value)}flatMap(t){return new e(this.value)}reduce(t){return new e(this.value)}foldLeft(t,i){return t}foldRight(t,i){return t}};exports.a = r;
|
package/dist/chunk-6VKVA3TK.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var e=class extends Error{};exports.a = e;
|
package/dist/chunk-ABUN2GHU.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var r=class e{constructor(t){this.value=t}isLeft(){return!0}isRight(){return!1}map(t){return new e(this.value)}flatMap(t){return new e(this.value)}reduce(t){return new e(this.value)}foldLeft(t,i){return t}foldRight(t,i){return t}};export{r as a};
|
package/dist/chunk-CB3ZZ3RL.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var u=class r{constructor(e){this.value=e}isLeft(){return!1}isRight(){return!0}map(e){return new r(e(this.value))}flatMap(e){return e(this.value)}reduce(e){return new r(e(void 0,this.value))}foldLeft(e,t){return t(e,this.value)}foldRight(e,t){return t(this.value,e)}};exports.a = u;
|
package/dist/chunk-CN6MP6AJ.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var u=class r{constructor(e){this.value=e}isLeft(){return!1}isRight(){return!0}map(e){return new r(e(this.value))}flatMap(e){return e(this.value)}reduce(e){return new r(e(void 0,this.value))}foldLeft(e,t){return t(e,this.value)}foldRight(e,t){return t(this.value,e)}};export{u as a};
|
package/dist/chunk-E4GBAXJ4.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as i}from"./chunk-VTKL7OQI.js";var n=class r{constructor(t){i(this,"items");this.items=t?[...t]:[]}get length(){return this.items.length}add(t){return new r([...this.items,t])}removeAt(t){if(t<0||t>=this.items.length)return this;let e=[...this.items.slice(0,t),...this.items.slice(t+1)];return new r(e)}get(t){return this.items[t]}toArray(){return this.items}map(t){return new r(this.items.map(t))}flatMap(t){return this.items.reduce((e,s)=>e.concat(t(s)),new r)}reduce(t){let e=this.items.reduce(t,void 0);return new r([e])}foldLeft(t,e){return this.items.reduce(e,t)}foldRight(t,e){return this.items.reduceRight((s,u)=>e(u,s),t)}concat(t){return new r([...this.items,...t.items])}toString(){return`List(${this.items.toString()})`}};export{n as a};
|
package/dist/chunk-GWLTG6GZ.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var d=Object.defineProperty;var e=(b,a,c)=>a in b?d(b,a,{enumerable:!0,configurable:!0,writable:!0,value:c}):b[a]=c;var f=(b,a,c)=>(e(b,typeof a!="symbol"?a+"":a,c),c);exports.a = f;
|
package/dist/chunk-HWJMIJH6.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk4EVP3IRIcjs = require('./chunk-4EVP3IRI.cjs');var _chunkCB3ZZ3RLcjs = require('./chunk-CB3ZZ3RL.cjs');var _chunk6VKVA3TKcjs = require('./chunk-6VKVA3TK.cjs');var s=r=>new (0, _chunk4EVP3IRIcjs.a)(r),n= exports.b =r=>new (0, _chunkCB3ZZ3RLcjs.a)(r),h= exports.c =r=>{let t=parseInt(r,10);return isNaN(t)?s(new (0, _chunk6VKVA3TKcjs.a)(`${t}`)):n(t)};exports.a = s; exports.b = n; exports.c = h;
|
package/dist/chunk-PXY4XULG.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkGWLTG6GZcjs = require('./chunk-GWLTG6GZ.cjs');var n=class r{constructor(t){_chunkGWLTG6GZcjs.a.call(void 0, this,"items");this.items=t?[...t]:[]}get length(){return this.items.length}add(t){return new r([...this.items,t])}removeAt(t){if(t<0||t>=this.items.length)return this;let e=[...this.items.slice(0,t),...this.items.slice(t+1)];return new r(e)}get(t){return this.items[t]}toArray(){return this.items}map(t){return new r(this.items.map(t))}flatMap(t){return this.items.reduce((e,s)=>e.concat(t(s)),new r)}reduce(t){let e=this.items.reduce(t,void 0);return new r([e])}foldLeft(t,e){return this.items.reduce(e,t)}foldRight(t,e){return this.items.reduceRight((s,u)=>e(u,s),t)}concat(t){return new r([...this.items,...t.items])}toString(){return`List(${this.items.toString()})`}};exports.a = n;
|
package/dist/chunk-QK5JVYJ3.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as i}from"./chunk-ABUN2GHU.js";import{a as o}from"./chunk-CN6MP6AJ.js";import{a as e}from"./chunk-ZTL76QDL.js";var s=r=>new i(r),n=r=>new o(r),h=r=>{let t=parseInt(r,10);return isNaN(t)?s(new e(`${t}`)):n(t)};export{s as a,n as b,h as c};
|
package/dist/either/Left.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk4EVP3IRIcjs = require('../chunk-4EVP3IRI.cjs');require('../chunk-GWLTG6GZ.cjs');exports.Left = _chunk4EVP3IRIcjs.a;
|
package/dist/either/Left.d.cts
DELETED
package/dist/either/Right.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkCB3ZZ3RLcjs = require('../chunk-CB3ZZ3RL.cjs');require('../chunk-GWLTG6GZ.cjs');exports.Right = _chunkCB3ZZ3RLcjs.a;
|
package/dist/either/Right.d.cts
DELETED
package/dist/either/index.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkHWJMIJH6cjs = require('../chunk-HWJMIJH6.cjs');require('../chunk-4EVP3IRI.cjs');require('../chunk-CB3ZZ3RL.cjs');require('../chunk-6VKVA3TK.cjs');require('../chunk-GWLTG6GZ.cjs');exports.left = _chunkHWJMIJH6cjs.a; exports.parseNumber = _chunkHWJMIJH6cjs.c; exports.right = _chunkHWJMIJH6cjs.b;
|
package/dist/either/index.d.cts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk6VKVA3TKcjs = require('../chunk-6VKVA3TK.cjs');require('../chunk-GWLTG6GZ.cjs');exports.ParseError = _chunk6VKVA3TKcjs.a;
|
package/dist/index.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkHWJMIJH6cjs = require('./chunk-HWJMIJH6.cjs');var _chunk4EVP3IRIcjs = require('./chunk-4EVP3IRI.cjs');var _chunkCB3ZZ3RLcjs = require('./chunk-CB3ZZ3RL.cjs');require('./chunk-6VKVA3TK.cjs');var _chunkPXY4XULGcjs = require('./chunk-PXY4XULG.cjs');require('./chunk-GWLTG6GZ.cjs');exports.Left = _chunk4EVP3IRIcjs.a; exports.List = _chunkPXY4XULGcjs.a; exports.Right = _chunkCB3ZZ3RLcjs.a; exports.left = _chunkHWJMIJH6cjs.a; exports.parseNumber = _chunkHWJMIJH6cjs.c; exports.right = _chunkHWJMIJH6cjs.b;
|
package/dist/index.d.cts
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { ParseError } from './error/ParseError.cjs';
|
|
2
|
-
|
|
3
|
-
declare class Right<L, R> implements Either<L, R> {
|
|
4
|
-
value: R;
|
|
5
|
-
constructor(value: R);
|
|
6
|
-
isLeft(): this is Left<L, R>;
|
|
7
|
-
isRight(): this is Right<L, R>;
|
|
8
|
-
map<U>(f: (value: R) => U): Either<L, U>;
|
|
9
|
-
flatMap<U>(f: (value: R) => Either<L, U>): Either<L, U>;
|
|
10
|
-
reduce<U>(f: (acc: U, value: R) => U): IFunctor<U>;
|
|
11
|
-
foldLeft<U>(initialValue: U, f: (acc: U, value: R) => U): U;
|
|
12
|
-
foldRight<U>(initialValue: U, f: (value: R, acc: U) => U): U;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
declare class Left<L, R> implements Either<L, R> {
|
|
16
|
-
value: L;
|
|
17
|
-
constructor(value: L);
|
|
18
|
-
isLeft(): this is Left<L, R>;
|
|
19
|
-
isRight(): this is Right<L, R>;
|
|
20
|
-
map<U>(_f: (value: R) => U): Either<L, U>;
|
|
21
|
-
flatMap<U>(_f: (value: R) => Either<L, U>): Either<L, U>;
|
|
22
|
-
reduce<U>(_f: (acc: U, value: R) => U): IFunctor<U>;
|
|
23
|
-
foldLeft<U>(initialValue: U, _f: (acc: U, value: R) => U): U;
|
|
24
|
-
foldRight<U>(initialValue: U, _f: (value: R, acc: U) => U): U;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
interface Either<L, R> extends IFunctor<R> {
|
|
28
|
-
value: L | R;
|
|
29
|
-
isLeft(): this is Left<L, R>;
|
|
30
|
-
isRight(): this is Right<L, R>;
|
|
31
|
-
map<U>(f: (value: R) => U): Either<L, U>;
|
|
32
|
-
flatMap<U>(f: (value: R) => Either<L, U>): Either<L, U>;
|
|
33
|
-
}
|
|
34
|
-
declare const left: <L, R>(value: L) => Either<L, R>;
|
|
35
|
-
declare const right: <L, R>(value: R) => Either<L, R>;
|
|
36
|
-
declare const parseNumber: (input: string) => Either<ParseError, number>;
|
|
37
|
-
|
|
38
|
-
declare class List<T> implements IFunctor<T> {
|
|
39
|
-
private readonly items;
|
|
40
|
-
constructor(items?: T[]);
|
|
41
|
-
get length(): number;
|
|
42
|
-
add(item: T): List<T>;
|
|
43
|
-
removeAt(index: number): List<T>;
|
|
44
|
-
get(index: number): T | undefined;
|
|
45
|
-
toArray(): readonly T[];
|
|
46
|
-
map<U>(f: (value: T) => U): List<U>;
|
|
47
|
-
flatMap<U>(f: (value: T) => List<U>): List<U>;
|
|
48
|
-
reduce<U>(f: (acc: U, value: T) => U): List<U>;
|
|
49
|
-
foldLeft<U>(initialValue: U, f: (acc: U, value: T) => U): U;
|
|
50
|
-
foldRight<U>(initialValue: U, f: (value: T, acc: U) => U): U;
|
|
51
|
-
concat(other: List<T>): List<T>;
|
|
52
|
-
toString(): string;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
interface IFunctor<T> {
|
|
56
|
-
map<U>(f: (value: T) => U): IFunctor<U>;
|
|
57
|
-
flatMap<U>(f: (value: T) => IFunctor<U>): IFunctor<U>;
|
|
58
|
-
reduce<U>(f: (acc: U, value: T) => U): IFunctor<U>;
|
|
59
|
-
foldLeft<U>(initialValue: U, f: (acc: U, value: T) => U): U;
|
|
60
|
-
foldRight<U>(initialValue: U, f: (value: T, acc: U) => U): U;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export { Either, IFunctor, Left, List, Right, left, parseNumber, right };
|
package/dist/list/List.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkPXY4XULGcjs = require('../chunk-PXY4XULG.cjs');require('../chunk-GWLTG6GZ.cjs');exports.List = _chunkPXY4XULGcjs.a;
|
package/dist/list/List.d.cts
DELETED
|
File without changes
|