functype 0.0.5 → 0.0.7

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 (55) hide show
  1. package/dist/chunk-ALLQJFGO.cjs +1 -0
  2. package/dist/chunk-E4GBAXJ4.js +1 -0
  3. package/dist/chunk-HJKBTHS6.cjs +1 -0
  4. package/dist/chunk-IU7MDTQA.cjs +1 -0
  5. package/dist/chunk-LXNGDVCQ.js +1 -0
  6. package/dist/chunk-MG5D2OQV.js +1 -0
  7. package/dist/chunk-OAC7TJZK.js +1 -0
  8. package/dist/chunk-OO6BXJDP.cjs +1 -0
  9. package/dist/chunk-PXY4XULG.cjs +1 -0
  10. package/dist/chunk-TZ5KQ47S.js +1 -0
  11. package/dist/chunk-UHHZ2CVW.js +1 -0
  12. package/dist/chunk-WAM77UJL.cjs +1 -0
  13. package/dist/either/Left.cjs +1 -1
  14. package/dist/either/Left.d.cts +1 -2
  15. package/dist/either/Left.d.ts +1 -2
  16. package/dist/either/Left.js +1 -1
  17. package/dist/either/Right.cjs +1 -1
  18. package/dist/either/Right.d.cts +1 -2
  19. package/dist/either/Right.d.ts +1 -2
  20. package/dist/either/Right.js +1 -1
  21. package/dist/either/index.cjs +1 -1
  22. package/dist/either/index.d.cts +1 -2
  23. package/dist/either/index.d.ts +1 -2
  24. package/dist/either/index.js +1 -1
  25. package/dist/index.cjs +1 -1
  26. package/dist/index.d.cts +104 -1
  27. package/dist/index.d.ts +104 -1
  28. package/dist/index.js +1 -0
  29. package/dist/list/List.cjs +1 -1
  30. package/dist/list/List.d.cts +2 -20
  31. package/dist/list/List.d.ts +2 -20
  32. package/dist/list/List.js +1 -1
  33. package/dist/list/index.cjs +1 -0
  34. package/dist/list/index.d.cts +2 -0
  35. package/dist/list/index.d.ts +2 -0
  36. package/dist/list/index.js +1 -0
  37. package/dist/option/None.cjs +1 -0
  38. package/dist/option/None.d.cts +2 -0
  39. package/dist/option/None.d.ts +2 -0
  40. package/dist/option/None.js +1 -0
  41. package/dist/option/Some.cjs +1 -0
  42. package/dist/option/Some.d.cts +2 -0
  43. package/dist/option/Some.d.ts +2 -0
  44. package/dist/option/Some.js +1 -0
  45. package/dist/option/index.cjs +1 -0
  46. package/dist/option/index.d.cts +2 -0
  47. package/dist/option/index.d.ts +2 -0
  48. package/dist/option/index.js +1 -0
  49. package/package.json +1 -1
  50. package/dist/chunk-4EVP3IRI.cjs +0 -1
  51. package/dist/chunk-ABUN2GHU.js +0 -1
  52. package/dist/chunk-CB3ZZ3RL.cjs +0 -1
  53. package/dist/chunk-CN6MP6AJ.js +0 -1
  54. package/dist/index-28de5927.d.ts +0 -39
  55. package/dist/index-402b9aa2.d.ts +0 -39
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkPXY4XULGcjs = require('./chunk-PXY4XULG.cjs');var n=e=>new (0, _chunkPXY4XULGcjs.a)(e);exports.a = n;
@@ -0,0 +1 @@
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};
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk6VKVA3TKcjs = require('./chunk-6VKVA3TK.cjs');var _chunkWAM77UJLcjs = require('./chunk-WAM77UJL.cjs');var _chunkPXY4XULGcjs = require('./chunk-PXY4XULG.cjs');var u=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)}reduce(t){return new e(t(void 0,this.value))}foldLeft(t,r){return r(t,this.value)}foldRight(t,r){return r(this.value,t)}toOption(){return _chunkWAM77UJLcjs.b.call(void 0, this.value)}toList(){return new (0, _chunkPXY4XULGcjs.a)([this.value])}};var s=e=>new o(e),l= exports.d =e=>new u(e),v= exports.e =e=>{let t=parseInt(e,10);return isNaN(t)?s(new (0, _chunk6VKVA3TKcjs.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)}reduce(t){return new e(this.value)}foldLeft(t,r){return t}foldRight(t,r){return t}toOption(){return _chunkWAM77UJLcjs.c.call(void 0, )}toList(){return new _chunkPXY4XULGcjs.a}};exports.a = o; exports.b = u; exports.c = s; exports.d = l; exports.e = v;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkPXY4XULGcjs = require('./chunk-PXY4XULG.cjs');var u=class r{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 r(t(this.value))}flatMap(t){return t(this.value)}reduce(t){return new r(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, _chunkPXY4XULGcjs.a)([this.value])}};exports.a = u;
@@ -0,0 +1 @@
1
+ import{a as e}from"./chunk-TZ5KQ47S.js";import{a as o}from"./chunk-OAC7TJZK.js";var r=t=>t?n(t):p(),n=t=>new o(t),p=()=>new e;export{r as a,n as b,p as c};
@@ -0,0 +1 @@
1
+ import{a as n}from"./chunk-ZTL76QDL.js";import{b as U,c as a}from"./chunk-LXNGDVCQ.js";import{a as i}from"./chunk-E4GBAXJ4.js";var u=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)}reduce(t){return new e(t(void 0,this.value))}foldLeft(t,r){return r(t,this.value)}foldRight(t,r){return r(this.value,t)}toOption(){return U(this.value)}toList(){return new i([this.value])}};var s=e=>new o(e),l=e=>new u(e),v=e=>{let t=parseInt(e,10);return isNaN(t)?s(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)}reduce(t){return new e(this.value)}foldLeft(t,r){return t}foldRight(t,r){return t}toOption(){return a()}toList(){return new i}};export{o as a,u as b,s as c,l as d,v as e};
@@ -0,0 +1 @@
1
+ import{a}from"./chunk-E4GBAXJ4.js";var u=class r{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 r(t(this.value))}flatMap(t){return t(this.value)}reduce(t){return new r(t(void 0,this.value))}foldLeft(t,e){return e(t,this.value)}foldRight(t,e){return e(this.value,t)}toList(){return new a([this.value])}};export{u as a};
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkPXY4XULGcjs = require('./chunk-PXY4XULG.cjs');var n=class e{isEmpty(){return!0}get(){throw new Error("Cannot call get() on a None")}getOrElse(t){return t}orElse(t){return t}map(t){return new e}flatMap(t){return new e}reduce(t){return new e}foldLeft(t,o){return t}foldRight(t,o){return t}toList(){return new _chunkPXY4XULGcjs.a}};exports.a = n;
@@ -0,0 +1 @@
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;
@@ -0,0 +1 @@
1
+ import{a as r}from"./chunk-E4GBAXJ4.js";var n=class e{isEmpty(){return!0}get(){throw new Error("Cannot call get() on a None")}getOrElse(t){return t}orElse(t){return t}map(t){return new e}flatMap(t){return new e}reduce(t){return new e}foldLeft(t,o){return t}foldRight(t,o){return t}toList(){return new r}};export{n as a};
@@ -0,0 +1 @@
1
+ import{a as t}from"./chunk-E4GBAXJ4.js";var n=e=>new t(e);export{n as a};
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkOO6BXJDPcjs = require('./chunk-OO6BXJDP.cjs');var _chunkIU7MDTQAcjs = require('./chunk-IU7MDTQA.cjs');var r=t=>t?n(t):p(),n= exports.b =t=>new (0, _chunkIU7MDTQAcjs.a)(t),p= exports.c =()=>new _chunkOO6BXJDPcjs.a;exports.a = r; exports.b = n; exports.c = p;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk4EVP3IRIcjs = require('../chunk-4EVP3IRI.cjs');require('../chunk-GWLTG6GZ.cjs');exports.Left = _chunk4EVP3IRIcjs.a;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkHJKBTHS6cjs = require('../chunk-HJKBTHS6.cjs');require('../chunk-6VKVA3TK.cjs');require('../chunk-WAM77UJL.cjs');require('../chunk-OO6BXJDP.cjs');require('../chunk-IU7MDTQA.cjs');require('../chunk-ALLQJFGO.cjs');require('../chunk-PXY4XULG.cjs');require('../chunk-GWLTG6GZ.cjs');exports.Left = _chunkHJKBTHS6cjs.a;
@@ -1,3 +1,2 @@
1
- export { L as Left } from '../index-402b9aa2.js';
2
- import '../index.cjs';
1
+ export { Left } from '../index.cjs';
3
2
  import '../error/ParseError.cjs';
@@ -1,3 +1,2 @@
1
- export { L as Left } from '../index-28de5927.js';
2
- import '../index.js';
1
+ export { Left } from '../index.js';
3
2
  import '../error/ParseError.js';
@@ -1 +1 @@
1
- import{a}from"../chunk-ABUN2GHU.js";import"../chunk-VTKL7OQI.js";export{a as Left};
1
+ import{a}from"../chunk-MG5D2OQV.js";import"../chunk-ZTL76QDL.js";import"../chunk-LXNGDVCQ.js";import"../chunk-TZ5KQ47S.js";import"../chunk-OAC7TJZK.js";import"../chunk-UHHZ2CVW.js";import"../chunk-E4GBAXJ4.js";import"../chunk-VTKL7OQI.js";export{a as Left};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkCB3ZZ3RLcjs = require('../chunk-CB3ZZ3RL.cjs');require('../chunk-GWLTG6GZ.cjs');exports.Right = _chunkCB3ZZ3RLcjs.a;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkHJKBTHS6cjs = require('../chunk-HJKBTHS6.cjs');require('../chunk-6VKVA3TK.cjs');require('../chunk-WAM77UJL.cjs');require('../chunk-OO6BXJDP.cjs');require('../chunk-IU7MDTQA.cjs');require('../chunk-ALLQJFGO.cjs');require('../chunk-PXY4XULG.cjs');require('../chunk-GWLTG6GZ.cjs');exports.Right = _chunkHJKBTHS6cjs.b;
@@ -1,3 +1,2 @@
1
- export { R as Right } from '../index-402b9aa2.js';
2
- import '../index.cjs';
1
+ export { Right } from '../index.cjs';
3
2
  import '../error/ParseError.cjs';
@@ -1,3 +1,2 @@
1
- export { R as Right } from '../index-28de5927.js';
2
- import '../index.js';
1
+ export { Right } from '../index.js';
3
2
  import '../error/ParseError.js';
@@ -1 +1 @@
1
- import{a}from"../chunk-CN6MP6AJ.js";import"../chunk-VTKL7OQI.js";export{a as Right};
1
+ import{b as a}from"../chunk-MG5D2OQV.js";import"../chunk-ZTL76QDL.js";import"../chunk-LXNGDVCQ.js";import"../chunk-TZ5KQ47S.js";import"../chunk-OAC7TJZK.js";import"../chunk-UHHZ2CVW.js";import"../chunk-E4GBAXJ4.js";import"../chunk-VTKL7OQI.js";export{a as Right};
@@ -1 +1 @@
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');require('../chunk-GWLTG6GZ.cjs');var s=r=>new (0, _chunk4EVP3IRIcjs.a)(r),n= exports.right =r=>new (0, _chunkCB3ZZ3RLcjs.a)(r),h= exports.parseNumber =r=>{let t=parseInt(r,10);return isNaN(t)?s(new (0, _chunk6VKVA3TKcjs.a)(`${t}`)):n(t)};exports.left = s; exports.parseNumber = h; exports.right = n;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkHJKBTHS6cjs = require('../chunk-HJKBTHS6.cjs');require('../chunk-6VKVA3TK.cjs');require('../chunk-WAM77UJL.cjs');require('../chunk-OO6BXJDP.cjs');require('../chunk-IU7MDTQA.cjs');require('../chunk-ALLQJFGO.cjs');require('../chunk-PXY4XULG.cjs');require('../chunk-GWLTG6GZ.cjs');exports.Left = _chunkHJKBTHS6cjs.a; exports.Right = _chunkHJKBTHS6cjs.b; exports.left = _chunkHJKBTHS6cjs.c; exports.parseNumber = _chunkHJKBTHS6cjs.e; exports.right = _chunkHJKBTHS6cjs.d;
@@ -1,3 +1,2 @@
1
1
  import '../error/ParseError.cjs';
2
- export { E as Either, l as left, p as parseNumber, r as right } from '../index-402b9aa2.js';
3
- import '../index.cjs';
2
+ export { Either, Left, Right, left, parseNumber, right } from '../index.cjs';
@@ -1,3 +1,2 @@
1
1
  import '../error/ParseError.js';
2
- export { E as Either, l as left, p as parseNumber, r as right } from '../index-28de5927.js';
3
- import '../index.js';
2
+ export { Either, Left, Right, left, parseNumber, right } from '../index.js';
@@ -1 +1 @@
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";import"../chunk-VTKL7OQI.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 left,h as parseNumber,n as right};
1
+ import{a,b,c,d,e}from"../chunk-MG5D2OQV.js";import"../chunk-ZTL76QDL.js";import"../chunk-LXNGDVCQ.js";import"../chunk-TZ5KQ47S.js";import"../chunk-OAC7TJZK.js";import"../chunk-UHHZ2CVW.js";import"../chunk-E4GBAXJ4.js";import"../chunk-VTKL7OQI.js";export{a as Left,b as Right,c as left,e as parseNumber,d as right};
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkHJKBTHS6cjs = require('./chunk-HJKBTHS6.cjs');require('./chunk-6VKVA3TK.cjs');var _chunkWAM77UJLcjs = require('./chunk-WAM77UJL.cjs');var _chunkOO6BXJDPcjs = require('./chunk-OO6BXJDP.cjs');var _chunkIU7MDTQAcjs = require('./chunk-IU7MDTQA.cjs');var _chunkALLQJFGOcjs = require('./chunk-ALLQJFGO.cjs');var _chunkPXY4XULGcjs = require('./chunk-PXY4XULG.cjs');require('./chunk-GWLTG6GZ.cjs');exports.Left = _chunkHJKBTHS6cjs.a; exports.List = _chunkPXY4XULGcjs.a; exports.None = _chunkOO6BXJDPcjs.a; exports.Right = _chunkHJKBTHS6cjs.b; exports.Some = _chunkIU7MDTQAcjs.a; exports.left = _chunkHJKBTHS6cjs.c; exports.list = _chunkALLQJFGOcjs.a; exports.none = _chunkWAM77UJLcjs.c; exports.option = _chunkWAM77UJLcjs.a; exports.parseNumber = _chunkHJKBTHS6cjs.e; exports.right = _chunkHJKBTHS6cjs.d; exports.some = _chunkWAM77UJLcjs.b;
package/dist/index.d.cts CHANGED
@@ -1,3 +1,106 @@
1
+ import { ParseError } from './error/ParseError.cjs';
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
+ 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
+ toOption(): Option<R>;
14
+ toList(): List<R>;
15
+ }
16
+
17
+ declare class Right<L, R> implements Either<L, R> {
18
+ value: R;
19
+ constructor(value: R);
20
+ isLeft(): this is Left<L, R>;
21
+ isRight(): this is Right<L, R>;
22
+ map<U>(f: (value: R) => U): Either<L, U>;
23
+ flatMap<U>(f: (value: R) => Either<L, U>): Either<L, U>;
24
+ reduce<U>(f: (acc: U, value: R) => U): IFunctor<U>;
25
+ foldLeft<U>(initialValue: U, f: (acc: U, value: R) => U): U;
26
+ foldRight<U>(initialValue: U, f: (value: R, acc: U) => U): U;
27
+ toOption(): Option<R>;
28
+ toList(): List<R>;
29
+ }
30
+
31
+ interface Either<L, R> extends IFunctor<R> {
32
+ value: L | R;
33
+ isLeft(): this is Left<L, R>;
34
+ isRight(): this is Right<L, R>;
35
+ map<U>(f: (value: R) => U): Either<L, U>;
36
+ flatMap<U>(f: (value: R) => Either<L, U>): Either<L, U>;
37
+ toOption(): Option<R>;
38
+ toList(): List<R>;
39
+ }
40
+ declare const left: <L, R>(value: L) => Either<L, R>;
41
+ declare const right: <L, R>(value: R) => Either<L, R>;
42
+ declare const parseNumber: (input: string) => Either<ParseError, number>;
43
+
44
+ declare class List<T> implements IFunctor<T> {
45
+ private readonly items;
46
+ constructor(items?: T[]);
47
+ get length(): number;
48
+ add(item: T): List<T>;
49
+ removeAt(index: number): List<T>;
50
+ get(index: number): T | undefined;
51
+ toArray(): readonly T[];
52
+ map<U>(f: (value: T) => U): List<U>;
53
+ flatMap<U>(f: (value: T) => List<U>): List<U>;
54
+ reduce<U>(f: (acc: U, value: T) => U): List<U>;
55
+ foldLeft<U>(initialValue: U, f: (acc: U, value: T) => U): U;
56
+ foldRight<U>(initialValue: U, f: (value: T, acc: U) => U): U;
57
+ concat(other: List<T>): List<T>;
58
+ toString(): string;
59
+ }
60
+
61
+ declare const list: <T>(items: T[] | undefined) => List<T>;
62
+
63
+ declare class Some<T> implements Option<T> {
64
+ private value;
65
+ constructor(value: T);
66
+ isEmpty(): boolean;
67
+ get(): T;
68
+ getOrElse(defaultValue: T): T;
69
+ orElse(alternative: Option<T>): Option<T>;
70
+ map<U>(f: (value: T) => U): Option<U>;
71
+ flatMap<U>(f: (value: T) => Option<U>): Option<U>;
72
+ reduce<U>(f: (acc: U, value: T) => U): Option<U>;
73
+ foldLeft<U>(initialValue: U, f: (acc: U, value: T) => U): U;
74
+ foldRight<U>(initialValue: U, f: (value: T, acc: U) => U): U;
75
+ toList(): List<T>;
76
+ }
77
+
78
+ declare class None<T> implements Option<T> {
79
+ isEmpty(): boolean;
80
+ get(): T;
81
+ getOrElse(defaultValue: T): T;
82
+ orElse(alternative: Option<T>): Option<T>;
83
+ map<U>(f: (value: T) => U): Option<U>;
84
+ flatMap<U>(f: (value: T) => Option<U>): Option<U>;
85
+ reduce<U>(f: (acc: U, value: T) => U): Option<U>;
86
+ foldLeft<U>(initialValue: U, f: (acc: U, value: T) => U): U;
87
+ foldRight<U>(initialValue: U, f: (value: T, acc: U) => U): U;
88
+ toList(): List<T>;
89
+ }
90
+
91
+ interface Option<T> extends IFunctor<T> {
92
+ isEmpty(): boolean;
93
+ get(): T;
94
+ getOrElse(defaultValue: T): T;
95
+ orElse(alternative: Option<T>): Option<T>;
96
+ map<U>(f: (value: T) => U): Option<U>;
97
+ flatMap<U>(f: (value: T) => Option<U>): Option<U>;
98
+ toList(): List<T>;
99
+ }
100
+ declare const option: <T>(value?: T | undefined) => Option<T>;
101
+ declare const some: <T>(value: T) => Option<T>;
102
+ declare const none: <T>() => Option<T>;
103
+
1
104
  interface IFunctor<T> {
2
105
  map<U>(f: (value: T) => U): IFunctor<U>;
3
106
  flatMap<U>(f: (value: T) => IFunctor<U>): IFunctor<U>;
@@ -6,4 +109,4 @@ interface IFunctor<T> {
6
109
  foldRight<U>(initialValue: U, f: (value: T, acc: U) => U): U;
7
110
  }
8
111
 
9
- export { IFunctor };
112
+ export { Either, IFunctor, Left, List, None, Option, Right, Some, left, list, none, option, parseNumber, right, some };
package/dist/index.d.ts CHANGED
@@ -1,3 +1,106 @@
1
+ import { ParseError } from './error/ParseError.js';
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
+ 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
+ toOption(): Option<R>;
14
+ toList(): List<R>;
15
+ }
16
+
17
+ declare class Right<L, R> implements Either<L, R> {
18
+ value: R;
19
+ constructor(value: R);
20
+ isLeft(): this is Left<L, R>;
21
+ isRight(): this is Right<L, R>;
22
+ map<U>(f: (value: R) => U): Either<L, U>;
23
+ flatMap<U>(f: (value: R) => Either<L, U>): Either<L, U>;
24
+ reduce<U>(f: (acc: U, value: R) => U): IFunctor<U>;
25
+ foldLeft<U>(initialValue: U, f: (acc: U, value: R) => U): U;
26
+ foldRight<U>(initialValue: U, f: (value: R, acc: U) => U): U;
27
+ toOption(): Option<R>;
28
+ toList(): List<R>;
29
+ }
30
+
31
+ interface Either<L, R> extends IFunctor<R> {
32
+ value: L | R;
33
+ isLeft(): this is Left<L, R>;
34
+ isRight(): this is Right<L, R>;
35
+ map<U>(f: (value: R) => U): Either<L, U>;
36
+ flatMap<U>(f: (value: R) => Either<L, U>): Either<L, U>;
37
+ toOption(): Option<R>;
38
+ toList(): List<R>;
39
+ }
40
+ declare const left: <L, R>(value: L) => Either<L, R>;
41
+ declare const right: <L, R>(value: R) => Either<L, R>;
42
+ declare const parseNumber: (input: string) => Either<ParseError, number>;
43
+
44
+ declare class List<T> implements IFunctor<T> {
45
+ private readonly items;
46
+ constructor(items?: T[]);
47
+ get length(): number;
48
+ add(item: T): List<T>;
49
+ removeAt(index: number): List<T>;
50
+ get(index: number): T | undefined;
51
+ toArray(): readonly T[];
52
+ map<U>(f: (value: T) => U): List<U>;
53
+ flatMap<U>(f: (value: T) => List<U>): List<U>;
54
+ reduce<U>(f: (acc: U, value: T) => U): List<U>;
55
+ foldLeft<U>(initialValue: U, f: (acc: U, value: T) => U): U;
56
+ foldRight<U>(initialValue: U, f: (value: T, acc: U) => U): U;
57
+ concat(other: List<T>): List<T>;
58
+ toString(): string;
59
+ }
60
+
61
+ declare const list: <T>(items: T[] | undefined) => List<T>;
62
+
63
+ declare class Some<T> implements Option<T> {
64
+ private value;
65
+ constructor(value: T);
66
+ isEmpty(): boolean;
67
+ get(): T;
68
+ getOrElse(defaultValue: T): T;
69
+ orElse(alternative: Option<T>): Option<T>;
70
+ map<U>(f: (value: T) => U): Option<U>;
71
+ flatMap<U>(f: (value: T) => Option<U>): Option<U>;
72
+ reduce<U>(f: (acc: U, value: T) => U): Option<U>;
73
+ foldLeft<U>(initialValue: U, f: (acc: U, value: T) => U): U;
74
+ foldRight<U>(initialValue: U, f: (value: T, acc: U) => U): U;
75
+ toList(): List<T>;
76
+ }
77
+
78
+ declare class None<T> implements Option<T> {
79
+ isEmpty(): boolean;
80
+ get(): T;
81
+ getOrElse(defaultValue: T): T;
82
+ orElse(alternative: Option<T>): Option<T>;
83
+ map<U>(f: (value: T) => U): Option<U>;
84
+ flatMap<U>(f: (value: T) => Option<U>): Option<U>;
85
+ reduce<U>(f: (acc: U, value: T) => U): Option<U>;
86
+ foldLeft<U>(initialValue: U, f: (acc: U, value: T) => U): U;
87
+ foldRight<U>(initialValue: U, f: (value: T, acc: U) => U): U;
88
+ toList(): List<T>;
89
+ }
90
+
91
+ interface Option<T> extends IFunctor<T> {
92
+ isEmpty(): boolean;
93
+ get(): T;
94
+ getOrElse(defaultValue: T): T;
95
+ orElse(alternative: Option<T>): Option<T>;
96
+ map<U>(f: (value: T) => U): Option<U>;
97
+ flatMap<U>(f: (value: T) => Option<U>): Option<U>;
98
+ toList(): List<T>;
99
+ }
100
+ declare const option: <T>(value?: T | undefined) => Option<T>;
101
+ declare const some: <T>(value: T) => Option<T>;
102
+ declare const none: <T>() => Option<T>;
103
+
1
104
  interface IFunctor<T> {
2
105
  map<U>(f: (value: T) => U): IFunctor<U>;
3
106
  flatMap<U>(f: (value: T) => IFunctor<U>): IFunctor<U>;
@@ -6,4 +109,4 @@ interface IFunctor<T> {
6
109
  foldRight<U>(initialValue: U, f: (value: T, acc: U) => U): U;
7
110
  }
8
111
 
9
- export { IFunctor };
112
+ export { Either, IFunctor, Left, List, None, Option, Right, Some, left, list, none, option, parseNumber, right, some };
package/dist/index.js CHANGED
@@ -0,0 +1 @@
1
+ import{a,b,c,d,e}from"./chunk-MG5D2OQV.js";import"./chunk-ZTL76QDL.js";import{a as j,b as k,c as l}from"./chunk-LXNGDVCQ.js";import{a as i}from"./chunk-TZ5KQ47S.js";import{a as h}from"./chunk-OAC7TJZK.js";import{a as g}from"./chunk-UHHZ2CVW.js";import{a as f}from"./chunk-E4GBAXJ4.js";import"./chunk-VTKL7OQI.js";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};
@@ -1 +1 @@
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.List = n;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkPXY4XULGcjs = require('../chunk-PXY4XULG.cjs');require('../chunk-GWLTG6GZ.cjs');exports.List = _chunkPXY4XULGcjs.a;
@@ -1,20 +1,2 @@
1
- import { IFunctor } from '../index.cjs';
2
-
3
- declare class List<T> implements IFunctor<T> {
4
- private readonly items;
5
- constructor(items?: T[]);
6
- get length(): number;
7
- add(item: T): List<T>;
8
- removeAt(index: number): List<T>;
9
- get(index: number): T | undefined;
10
- toArray(): readonly T[];
11
- map<U>(f: (value: T) => U): List<U>;
12
- flatMap<U>(f: (value: T) => List<U>): List<U>;
13
- reduce<U>(f: (acc: U, value: T) => U): List<U>;
14
- foldLeft<U>(initialValue: U, f: (acc: U, value: T) => U): U;
15
- foldRight<U>(initialValue: U, f: (value: T, acc: U) => U): U;
16
- concat(other: List<T>): List<T>;
17
- toString(): string;
18
- }
19
-
20
- export { List };
1
+ export { List } from '../index.cjs';
2
+ import '../error/ParseError.cjs';
@@ -1,20 +1,2 @@
1
- import { IFunctor } from '../index.js';
2
-
3
- declare class List<T> implements IFunctor<T> {
4
- private readonly items;
5
- constructor(items?: T[]);
6
- get length(): number;
7
- add(item: T): List<T>;
8
- removeAt(index: number): List<T>;
9
- get(index: number): T | undefined;
10
- toArray(): readonly T[];
11
- map<U>(f: (value: T) => U): List<U>;
12
- flatMap<U>(f: (value: T) => List<U>): List<U>;
13
- reduce<U>(f: (acc: U, value: T) => U): List<U>;
14
- foldLeft<U>(initialValue: U, f: (acc: U, value: T) => U): U;
15
- foldRight<U>(initialValue: U, f: (value: T, acc: U) => U): U;
16
- concat(other: List<T>): List<T>;
17
- toString(): string;
18
- }
19
-
20
- export { List };
1
+ export { List } from '../index.js';
2
+ import '../error/ParseError.js';
package/dist/list/List.js CHANGED
@@ -1 +1 @@
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 List};
1
+ import{a}from"../chunk-E4GBAXJ4.js";import"../chunk-VTKL7OQI.js";export{a as List};
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkALLQJFGOcjs = require('../chunk-ALLQJFGO.cjs');var _chunkPXY4XULGcjs = require('../chunk-PXY4XULG.cjs');require('../chunk-GWLTG6GZ.cjs');exports.List = _chunkPXY4XULGcjs.a; exports.list = _chunkALLQJFGOcjs.a;
@@ -0,0 +1,2 @@
1
+ export { List, list } from '../index.cjs';
2
+ import '../error/ParseError.cjs';
@@ -0,0 +1,2 @@
1
+ export { List, list } from '../index.js';
2
+ import '../error/ParseError.js';
@@ -0,0 +1 @@
1
+ import{a as b}from"../chunk-UHHZ2CVW.js";import{a}from"../chunk-E4GBAXJ4.js";import"../chunk-VTKL7OQI.js";export{a as List,b as list};
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkOO6BXJDPcjs = require('../chunk-OO6BXJDP.cjs');require('../chunk-ALLQJFGO.cjs');require('../chunk-PXY4XULG.cjs');require('../chunk-GWLTG6GZ.cjs');exports.None = _chunkOO6BXJDPcjs.a;
@@ -0,0 +1,2 @@
1
+ export { None } from '../index.cjs';
2
+ import '../error/ParseError.cjs';
@@ -0,0 +1,2 @@
1
+ export { None } from '../index.js';
2
+ import '../error/ParseError.js';
@@ -0,0 +1 @@
1
+ import{a}from"../chunk-TZ5KQ47S.js";import"../chunk-UHHZ2CVW.js";import"../chunk-E4GBAXJ4.js";import"../chunk-VTKL7OQI.js";export{a as None};
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkIU7MDTQAcjs = require('../chunk-IU7MDTQA.cjs');require('../chunk-ALLQJFGO.cjs');require('../chunk-PXY4XULG.cjs');require('../chunk-GWLTG6GZ.cjs');exports.Some = _chunkIU7MDTQAcjs.a;
@@ -0,0 +1,2 @@
1
+ export { Some } from '../index.cjs';
2
+ import '../error/ParseError.cjs';
@@ -0,0 +1,2 @@
1
+ export { Some } from '../index.js';
2
+ import '../error/ParseError.js';
@@ -0,0 +1 @@
1
+ import{a}from"../chunk-OAC7TJZK.js";import"../chunk-UHHZ2CVW.js";import"../chunk-E4GBAXJ4.js";import"../chunk-VTKL7OQI.js";export{a as Some};
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkWAM77UJLcjs = require('../chunk-WAM77UJL.cjs');var _chunkOO6BXJDPcjs = require('../chunk-OO6BXJDP.cjs');var _chunkIU7MDTQAcjs = require('../chunk-IU7MDTQA.cjs');require('../chunk-ALLQJFGO.cjs');require('../chunk-PXY4XULG.cjs');require('../chunk-GWLTG6GZ.cjs');exports.None = _chunkOO6BXJDPcjs.a; exports.Some = _chunkIU7MDTQAcjs.a; exports.none = _chunkWAM77UJLcjs.c; exports.option = _chunkWAM77UJLcjs.a; exports.some = _chunkWAM77UJLcjs.b;
@@ -0,0 +1,2 @@
1
+ export { None, Option, Some, none, option, some } from '../index.cjs';
2
+ import '../error/ParseError.cjs';
@@ -0,0 +1,2 @@
1
+ export { None, Option, Some, none, option, some } from '../index.js';
2
+ import '../error/ParseError.js';
@@ -0,0 +1 @@
1
+ import{a as c,b as d,c as e}from"../chunk-LXNGDVCQ.js";import{a as b}from"../chunk-TZ5KQ47S.js";import{a}from"../chunk-OAC7TJZK.js";import"../chunk-UHHZ2CVW.js";import"../chunk-E4GBAXJ4.js";import"../chunk-VTKL7OQI.js";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.5",
3
+ "version": "0.0.7",
4
4
  "description": "A small functional library for TypeScript",
5
5
  "author": "jordan.burke@gmail.com",
6
6
  "license": "MIT",
@@ -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
- 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,39 +0,0 @@
1
- import { ParseError } from './error/ParseError.js';
2
- import { IFunctor } from './index.js';
3
-
4
- declare class Right<L, R> implements Either<L, R> {
5
- value: R;
6
- constructor(value: R);
7
- isLeft(): this is Left<L, R>;
8
- isRight(): this is Right<L, R>;
9
- map<U>(f: (value: R) => U): Either<L, U>;
10
- flatMap<U>(f: (value: R) => Either<L, U>): Either<L, U>;
11
- reduce<U>(f: (acc: U, value: R) => U): IFunctor<U>;
12
- foldLeft<U>(initialValue: U, f: (acc: U, value: R) => U): U;
13
- foldRight<U>(initialValue: U, f: (value: R, acc: U) => U): U;
14
- }
15
-
16
- declare class Left<L, R> implements Either<L, R> {
17
- value: L;
18
- constructor(value: L);
19
- isLeft(): this is Left<L, R>;
20
- isRight(): this is Right<L, R>;
21
- map<U>(_f: (value: R) => U): Either<L, U>;
22
- flatMap<U>(_f: (value: R) => Either<L, U>): Either<L, U>;
23
- reduce<U>(_f: (acc: U, value: R) => U): IFunctor<U>;
24
- foldLeft<U>(initialValue: U, _f: (acc: U, value: R) => U): U;
25
- foldRight<U>(initialValue: U, _f: (value: R, acc: U) => U): U;
26
- }
27
-
28
- interface Either<L, R> extends IFunctor<R> {
29
- value: L | R;
30
- isLeft(): this is Left<L, R>;
31
- isRight(): this is Right<L, R>;
32
- map<U>(f: (value: R) => U): Either<L, U>;
33
- flatMap<U>(f: (value: R) => Either<L, U>): Either<L, U>;
34
- }
35
- declare const left: <L, R>(value: L) => Either<L, R>;
36
- declare const right: <L, R>(value: R) => Either<L, R>;
37
- declare const parseNumber: (input: string) => Either<ParseError, number>;
38
-
39
- export { Either as E, Left as L, Right as R, left as l, parseNumber as p, right as r };
@@ -1,39 +0,0 @@
1
- import { ParseError } from './error/ParseError.cjs';
2
- import { IFunctor } from './index.cjs';
3
-
4
- declare class Right<L, R> implements Either<L, R> {
5
- value: R;
6
- constructor(value: R);
7
- isLeft(): this is Left<L, R>;
8
- isRight(): this is Right<L, R>;
9
- map<U>(f: (value: R) => U): Either<L, U>;
10
- flatMap<U>(f: (value: R) => Either<L, U>): Either<L, U>;
11
- reduce<U>(f: (acc: U, value: R) => U): IFunctor<U>;
12
- foldLeft<U>(initialValue: U, f: (acc: U, value: R) => U): U;
13
- foldRight<U>(initialValue: U, f: (value: R, acc: U) => U): U;
14
- }
15
-
16
- declare class Left<L, R> implements Either<L, R> {
17
- value: L;
18
- constructor(value: L);
19
- isLeft(): this is Left<L, R>;
20
- isRight(): this is Right<L, R>;
21
- map<U>(_f: (value: R) => U): Either<L, U>;
22
- flatMap<U>(_f: (value: R) => Either<L, U>): Either<L, U>;
23
- reduce<U>(_f: (acc: U, value: R) => U): IFunctor<U>;
24
- foldLeft<U>(initialValue: U, _f: (acc: U, value: R) => U): U;
25
- foldRight<U>(initialValue: U, _f: (value: R, acc: U) => U): U;
26
- }
27
-
28
- interface Either<L, R> extends IFunctor<R> {
29
- value: L | R;
30
- isLeft(): this is Left<L, R>;
31
- isRight(): this is Right<L, R>;
32
- map<U>(f: (value: R) => U): Either<L, U>;
33
- flatMap<U>(f: (value: R) => Either<L, U>): Either<L, U>;
34
- }
35
- declare const left: <L, R>(value: L) => Either<L, R>;
36
- declare const right: <L, R>(value: R) => Either<L, R>;
37
- declare const parseNumber: (input: string) => Either<ParseError, number>;
38
-
39
- export { Either as E, Left as L, Right as R, left as l, parseNumber as p, right as r };