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.
Files changed (82) hide show
  1. package/dist/chunk-3BACPU2L.mjs +1 -0
  2. package/dist/chunk-4BM7WJEY.js +1 -0
  3. package/dist/chunk-7F7OFOVC.mjs +1 -0
  4. package/dist/chunk-CFYIJKWF.mjs +1 -0
  5. package/dist/chunk-CMWFJ4NE.mjs +1 -0
  6. package/dist/chunk-ERJUPNUS.mjs +1 -0
  7. package/dist/chunk-IRUJTPRV.js +1 -0
  8. package/dist/chunk-QK32BSMQ.js +1 -0
  9. package/dist/chunk-RSJUG4F6.js +1 -0
  10. package/dist/chunk-SHAM4BB3.js +1 -0
  11. package/dist/chunk-T4ZDAXL2.mjs +1 -0
  12. package/dist/chunk-TAF2HXL3.mjs +1 -0
  13. package/dist/chunk-U5EUM74A.mjs +1 -0
  14. package/dist/chunk-VTKL7OQI.js +1 -1
  15. package/dist/chunk-ZQN22FM6.js +1 -0
  16. package/dist/chunk-ZTL76QDL.js +1 -1
  17. package/dist/either/Left.d.mts +2 -0
  18. package/dist/either/Left.js +1 -1
  19. package/dist/either/Left.mjs +1 -0
  20. package/dist/either/Right.d.mts +2 -0
  21. package/dist/either/Right.js +1 -1
  22. package/dist/either/Right.mjs +1 -0
  23. package/dist/either/index.d.mts +2 -0
  24. package/dist/either/index.d.ts +1 -1
  25. package/dist/either/index.js +1 -1
  26. package/dist/either/index.mjs +1 -0
  27. package/dist/error/ParseError.js +1 -1
  28. package/dist/error/ParseError.mjs +1 -0
  29. package/dist/index.d.mts +117 -0
  30. package/dist/index.d.ts +73 -19
  31. package/dist/index.js +1 -1
  32. package/dist/index.mjs +1 -0
  33. package/dist/list/List.d.mts +2 -0
  34. package/dist/list/List.js +1 -1
  35. package/dist/list/List.mjs +1 -0
  36. package/dist/list/index.d.mts +2 -0
  37. package/dist/list/index.d.ts +2 -0
  38. package/dist/list/index.js +1 -0
  39. package/dist/list/index.mjs +1 -0
  40. package/dist/map/Map.d.mts +2 -0
  41. package/dist/map/Map.d.ts +2 -0
  42. package/dist/map/Map.js +1 -0
  43. package/dist/map/Map.mjs +1 -0
  44. package/dist/map/index.d.mts +9 -0
  45. package/dist/map/index.d.ts +9 -0
  46. package/dist/map/index.js +1 -0
  47. package/dist/map/index.mjs +0 -0
  48. package/dist/option/None.d.mts +2 -0
  49. package/dist/option/None.d.ts +2 -0
  50. package/dist/option/None.js +1 -0
  51. package/dist/option/None.mjs +1 -0
  52. package/dist/option/Some.d.mts +2 -0
  53. package/dist/option/Some.d.ts +2 -0
  54. package/dist/option/Some.js +1 -0
  55. package/dist/option/Some.mjs +1 -0
  56. package/dist/option/index.d.mts +2 -0
  57. package/dist/option/index.d.ts +2 -0
  58. package/dist/option/index.js +1 -0
  59. package/dist/option/index.mjs +1 -0
  60. package/package.json +12 -6
  61. package/dist/chunk-4EVP3IRI.cjs +0 -1
  62. package/dist/chunk-6VKVA3TK.cjs +0 -1
  63. package/dist/chunk-ABUN2GHU.js +0 -1
  64. package/dist/chunk-CB3ZZ3RL.cjs +0 -1
  65. package/dist/chunk-CN6MP6AJ.js +0 -1
  66. package/dist/chunk-E4GBAXJ4.js +0 -1
  67. package/dist/chunk-GWLTG6GZ.cjs +0 -1
  68. package/dist/chunk-HWJMIJH6.cjs +0 -1
  69. package/dist/chunk-PXY4XULG.cjs +0 -1
  70. package/dist/chunk-QK5JVYJ3.js +0 -1
  71. package/dist/either/Left.cjs +0 -1
  72. package/dist/either/Left.d.cts +0 -2
  73. package/dist/either/Right.cjs +0 -1
  74. package/dist/either/Right.d.cts +0 -2
  75. package/dist/either/index.cjs +0 -1
  76. package/dist/either/index.d.cts +0 -2
  77. package/dist/error/ParseError.cjs +0 -1
  78. package/dist/index.cjs +0 -1
  79. package/dist/index.d.cts +0 -63
  80. package/dist/list/List.cjs +0 -1
  81. package/dist/list/List.d.cts +0 -2
  82. /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};
@@ -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);export{f as a};
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;
@@ -1 +1 @@
1
- var e=class extends Error{};export{e as a};
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var e=class extends Error{};exports.a = e;
@@ -0,0 +1,2 @@
1
+ export { Left } from '../index.mjs';
2
+ import '../error/ParseError.mjs';
@@ -1 +1 @@
1
- import{a}from"../chunk-ABUN2GHU.js";import"../chunk-VTKL7OQI.js";export{a as Left};
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};
@@ -0,0 +1,2 @@
1
+ export { Right } from '../index.mjs';
2
+ import '../error/ParseError.mjs';
@@ -1 +1 @@
1
- import{a}from"../chunk-CN6MP6AJ.js";import"../chunk-VTKL7OQI.js";export{a as Right};
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};
@@ -0,0 +1,2 @@
1
+ import '../error/ParseError.mjs';
2
+ export { Either, Left, Right, left, parseNumber, right } from '../index.mjs';
@@ -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';
@@ -1 +1 @@
1
- import{a,b,c}from"../chunk-QK5JVYJ3.js";import"../chunk-ABUN2GHU.js";import"../chunk-CN6MP6AJ.js";import"../chunk-ZTL76QDL.js";import"../chunk-VTKL7OQI.js";export{a as left,c as parseNumber,b as right};
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};
@@ -1 +1 @@
1
- import{a}from"../chunk-ZTL76QDL.js";import"../chunk-VTKL7OQI.js";export{a as ParseError};
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};
@@ -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
- 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;
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 IFunctor<T> {
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): List<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
- reduce<U>(f: (acc: U, value: T) => U): IFunctor<U>;
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
- import{a,b as o,c as r}from"./chunk-QK5JVYJ3.js";import{a as U}from"./chunk-ABUN2GHU.js";import{a as e}from"./chunk-CN6MP6AJ.js";import"./chunk-ZTL76QDL.js";import{a as t}from"./chunk-E4GBAXJ4.js";import"./chunk-VTKL7OQI.js";export{U as Left,t as List,e as Right,a as left,r as parseNumber,o as right};
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};
@@ -0,0 +1,2 @@
1
+ export { List } from '../index.mjs';
2
+ import '../error/ParseError.mjs';
package/dist/list/List.js CHANGED
@@ -1 +1 @@
1
- import{a}from"../chunk-E4GBAXJ4.js";import"../chunk-VTKL7OQI.js";export{a as List};
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,2 @@
1
+ export { IList, List, list } from '../index.mjs';
2
+ import '../error/ParseError.mjs';
@@ -0,0 +1,2 @@
1
+ export { IList, List, list } from '../index.js';
2
+ import '../error/ParseError.js';
@@ -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};
@@ -0,0 +1,2 @@
1
+
2
+ export { }
@@ -0,0 +1,2 @@
1
+
2
+ export { }
@@ -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');
@@ -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,2 @@
1
+ export { None } from '../index.mjs';
2
+ import '../error/ParseError.mjs';
@@ -0,0 +1,2 @@
1
+ export { None } from '../index.js';
2
+ import '../error/ParseError.js';
@@ -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,2 @@
1
+ export { Some } from '../index.mjs';
2
+ import '../error/ParseError.mjs';
@@ -0,0 +1,2 @@
1
+ export { Some } from '../index.js';
2
+ import '../error/ParseError.js';
@@ -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,2 @@
1
+ export { None, Option, Some, none, option, some } from '../index.mjs';
2
+ import '../error/ParseError.mjs';
@@ -0,0 +1,2 @@
1
+ export { None, Option, Some, none, option, some } from '../index.js';
2
+ import '../error/ParseError.js';
@@ -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.6",
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.cjs",
27
- "module": "dist/index.js",
28
- "types": "dist/index.d.ts",
29
- "type": "module",
30
- "dependencies": {},
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"
@@ -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;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var e=class extends Error{};exports.a = e;
@@ -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};
@@ -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;
@@ -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};
@@ -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};
@@ -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;
@@ -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;
@@ -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;
@@ -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};
@@ -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;
@@ -1,2 +0,0 @@
1
- export { Left } from '../index.cjs';
2
- import '../error/ParseError.cjs';
@@ -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;
@@ -1,2 +0,0 @@
1
- export { Right } from '../index.cjs';
2
- import '../error/ParseError.cjs';
@@ -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;
@@ -1,2 +0,0 @@
1
- import '../error/ParseError.cjs';
2
- export { Either, left, parseNumber, right } from '../index.cjs';
@@ -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 };
@@ -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;
@@ -1,2 +0,0 @@
1
- export { List } from '../index.cjs';
2
- import '../error/ParseError.cjs';