lite-fp 0.5.0 → 0.6.0

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/index.d.mts CHANGED
@@ -1,22 +1,22 @@
1
- type Left<A> = {
1
+ interface Left<A> {
2
2
  readonly $: "Left";
3
3
  readonly value: A;
4
- };
5
- type Right<B> = {
4
+ }
5
+ interface Right<B> {
6
6
  readonly $: "Right";
7
7
  readonly value: B;
8
- };
8
+ }
9
9
  declare const left: <A>(value: A) => Left<A>;
10
10
  declare const right: <B>(value: B) => Right<B>;
11
11
  declare const isLeft: <A, B>(e: Either<A, B>) => e is Left<A>;
12
12
  declare const isRight: <A, B>(e: Either<A, B>) => e is Right<B>;
13
- declare const getLeft: <A>(e: Left<A>) => A;
14
- declare const getRight: <B>(e: Right<B>) => B;
13
+ declare const lft: <A>(e: Left<A>) => A;
14
+ declare const rgt: <B>(e: Right<B>) => B;
15
15
  type Either<A, B> = Left<A> | Right<B>;
16
16
  declare const Either: {
17
+ new: <A, B>(value: B | null | undefined, error: A) => Either<A, B>;
17
18
  left: <A>(value: A) => Left<A>;
18
19
  right: <B>(value: B) => Right<B>;
19
- new: <A, B>(value: B | null | undefined, error: A) => Either<A, B>;
20
20
  isLeft: <A, B>(e: Either<A, B>) => e is Left<A>;
21
21
  isRight: <A, B>(e: Either<A, B>) => e is Right<B>;
22
22
  fromNullable: <A, B>(value: B | null | undefined, error: A) => Either<A, B>;
@@ -26,6 +26,7 @@ declare const Either: {
26
26
  mapLeft: <A, B, C>(e: Either<A, B>, fn: (l: A) => C) => Either<C, B>;
27
27
  bimap: <A, B, C, D>(e: Either<A, B>, fl: (l: A) => C, fr: (r: B) => D) => Either<C, D>;
28
28
  flatMap: <A, B, C>(e: Either<A, B>, fn: (value: B) => Either<A, C>) => Either<A, C>;
29
+ filter: <A, B>(e: Either<A, B>, predicate: (value: B) => boolean, onFalse: A) => Either<A, B>;
29
30
  chain: <A, B, C>(e: Either<A, B>, fn: (r: B) => Either<A, C>) => Either<A, C>;
30
31
  fold: <A, B, C>(e: Either<A, B>, onLeft: (l: A) => C, onRight: (r: B) => C) => C;
31
32
  match: <A, B, C>(e: Either<A, B>, matcher: {
@@ -33,13 +34,15 @@ declare const Either: {
33
34
  left: (value: A) => C;
34
35
  }) => C;
35
36
  swap: <A, B>(e: Either<A, B>) => Either<B, A>;
36
- getLeft: <A>(e: Left<A>) => A;
37
- getRight: <B>(e: Right<B>) => B;
37
+ lft: <A>(e: Left<A>) => A;
38
+ rgt: <B>(e: Right<B>) => B;
38
39
  getOrElse: <A, B>(e: Either<A, B>, defaultValue: B) => B;
40
+ getOrNull: <A, B>(e: Either<A, B>) => B | null;
39
41
  getOrUndefined: <A, B>(e: Either<A, B>) => B | undefined;
40
42
  getOrThrow: <A, B>(e: Either<A, B>) => B;
41
43
  zip: <E, A, B>(a: Either<E, A>, b: Either<E, B>) => Either<E, [A, B]>;
42
44
  apply: <E, A, B>(fn: Either<E, (value: A) => B>, arg: Either<E, A>) => Either<E, B>;
45
+ orElse: <E, A, B>(a: Either<E, A>, b: Either<E, B>) => Either<E, A | B>;
43
46
  tap: <A, B>(e: Either<A, B>, f: (r: B) => void) => Either<A, B>;
44
47
  tapLeft: <A, B>(e: Either<A, B>, f: (l: A) => void) => Either<A, B>;
45
48
  };
@@ -49,29 +52,26 @@ declare global {
49
52
  }
50
53
  }
51
54
 
52
- type NothingNull = null;
53
- type NothingUndefined = undefined;
54
- type Nothing = NothingNull | NothingUndefined;
55
- declare const just: <T>(value: T) => Maybe<T>;
55
+ type Nothing = null | undefined;
56
+ declare const just: <T>(value: T) => T;
56
57
  declare const nothing: () => Nothing;
57
58
  declare const isJust: <T>(m: Maybe<T>) => m is T;
58
59
  declare const isNothing: <T>(m: Maybe<T>) => m is Nothing;
59
60
  type Maybe<T> = T | Nothing;
60
61
  declare const Maybe: {
61
- just: <T>(value: T) => Maybe<T>;
62
- nothing: () => Nothing;
63
62
  new: <T>(m: T | null | undefined) => Maybe<T>;
64
- nothingNull: () => NothingNull;
65
- nothingUndefined: () => NothingUndefined;
63
+ just: <T>(value: T) => T;
64
+ nothing: () => Nothing;
65
+ nothingNull: () => null;
66
+ nothingUndefined: () => undefined;
66
67
  isJust: <T>(m: Maybe<T>) => m is T;
67
68
  isNothing: <T>(m: Maybe<T>) => m is Nothing;
68
- isNothingNull: <T>(m: Maybe<T>) => m is NothingNull;
69
- isNothingUndefined: <T>(m: Maybe<T>) => m is NothingUndefined;
69
+ isNull: <T>(m: Maybe<T>) => m is null;
70
+ isUndefined: <T>(m: Maybe<T>) => m is undefined;
70
71
  fromNullable: <T>(m: T | null | undefined) => Maybe<T>;
71
72
  fromThrowable: <T>(fn: () => T) => Maybe<T>;
73
+ fromPredicate: <T>(value: T, predicate: (value: T) => boolean) => Maybe<T>;
72
74
  fromPromise: <T>(promise: Promise<T>) => Promise<Maybe<T>>;
73
- toNullable: <T>(m: Maybe<T>) => T | null;
74
- toUndefined: <T>(m: Maybe<T>) => T | undefined;
75
75
  map: <T, U>(m: Maybe<T>, fn: (v: T) => U) => Maybe<U>;
76
76
  flatMap: <T, U>(m: Maybe<T>, fn: (v: T) => Maybe<U>) => Maybe<U>;
77
77
  filter: <T>(m: Maybe<T>, predicate: (value: T) => boolean) => Maybe<T>;
@@ -80,21 +80,23 @@ declare const Maybe: {
80
80
  nothing: () => U;
81
81
  }) => U;
82
82
  fold: <T, U>(m: Maybe<T>, onNothing: () => U, onJust: (v: T) => U) => U;
83
- getOrElse: <T>(m: Maybe<T>, d: T) => T;
83
+ getOrElse: <T>(m: Maybe<T>, defaultValue: T) => T;
84
84
  getOrUndefined: <T>(m: Maybe<T>) => T | undefined;
85
+ getOrNull: <T>(m: Maybe<T>) => T | null;
85
86
  getOrThrow: <T>(m: Maybe<T>) => T;
86
87
  zip: <T, U>(a: Maybe<T>, b: Maybe<U>) => Maybe<[T, U]>;
87
88
  apply: <T, U>(fn: Maybe<(value: T) => U>, opt: Maybe<T>) => Maybe<U>;
88
89
  orElse: <T>(opt: Maybe<T>, other: Maybe<T>) => Maybe<T>;
90
+ tap: <T>(m: Maybe<T>, fn: (v: T) => void) => Maybe<T>;
89
91
  };
90
92
 
91
- type None = {
93
+ interface None {
92
94
  readonly $: "None";
93
- };
94
- type Some<T> = {
95
+ }
96
+ interface Some<T> {
95
97
  readonly $: "Some";
96
98
  readonly value: T;
97
- };
99
+ }
98
100
  declare const none: <T>() => Option<T>;
99
101
  declare const some: <T>(value: T) => Option<T>;
100
102
  declare const isSome: <T>(option: Option<T>) => option is Some<T>;
@@ -102,9 +104,9 @@ declare const isNone: <T>(option: Option<T>) => option is None;
102
104
  declare const unwrap: <T>(option: Some<T>) => T;
103
105
  type Option<T> = None | Some<T>;
104
106
  declare const Option: {
107
+ new: <T>(value: T | null | undefined) => Option<T>;
105
108
  none: <T>() => Option<T>;
106
109
  some: <T>(value: T) => Option<T>;
107
- new: <T>(value: T | null | undefined) => Option<T>;
108
110
  isSome: <T>(option: Option<T>) => option is Some<T>;
109
111
  isNone: <T>(option: Option<T>) => option is None;
110
112
  fromNullable: <T>(value: T | null | undefined) => Option<T>;
@@ -114,6 +116,7 @@ declare const Option: {
114
116
  map: <T, U>(option: Option<T>, fn: (value: T) => U) => Option<U>;
115
117
  flatMap: <T, U>(option: Option<T>, fn: (value: T) => Option<U>) => Option<U>;
116
118
  filter: <T>(option: Option<T>, predicate: (value: T) => boolean) => Option<T>;
119
+ fold: <T, U>(option: Option<T>, onNone: () => U, onSome: (value: T) => U) => U;
117
120
  match: <T, U>(option: Option<T>, matcher: {
118
121
  some: (value: T) => U;
119
122
  none: () => U;
@@ -121,10 +124,12 @@ declare const Option: {
121
124
  unwrap: <T>(option: Some<T>) => T;
122
125
  getOrElse: <T>(option: Option<T>, defaultValue: T) => T;
123
126
  getOrUndefined: <T>(option: Option<T>) => T | undefined;
127
+ getOrNull: <T>(option: Option<T>) => T | null;
124
128
  getOrThrow: <T>(option: Option<T>) => T;
125
129
  zip: <T, U>(a: Option<T>, b: Option<U>) => Option<[T, U]>;
126
130
  apply: <T, U>(fn: Option<(value: T) => U>, opt: Option<T>) => Option<U>;
127
131
  orElse: <T>(opt: Option<T>, other: Option<T>) => Option<T>;
132
+ tap: <T>(option: Option<T>, f: (value: T) => void) => Option<T>;
128
133
  };
129
134
  declare global {
130
135
  interface Array<T> {
@@ -135,43 +140,46 @@ declare global {
135
140
  }
136
141
  }
137
142
 
143
+ declare const pair: <A, B>(a: A, b: B) => Pair<A, B>;
138
144
  declare const fst: <A, B>(p: Pair<A, B>) => A;
139
145
  declare const snd: <A, B>(p: Pair<A, B>) => B;
140
- declare const pair: <A, B>(a: A, b: B) => Pair<A, B>;
141
146
  type Pair<A, B> = readonly [A, B];
142
147
  declare const Pair: {
143
- fst: <A, B>(p: Pair<A, B>) => A;
144
- snd: <A, B>(p: Pair<A, B>) => B;
145
148
  new: <A, B>(a: A, b: B) => Pair<A, B>;
149
+ curry: <A>(a: A) => <B>(b: B) => Pair<A, B>;
146
150
  fromArray: <A, B>([a, b]: [A, B]) => Pair<A, B>;
147
151
  fromObject: <A, B>(obj: {
148
152
  fst: A;
149
153
  snd: B;
150
154
  }) => Pair<A, B>;
151
- curry: <A>(a: A) => <B>(b: B) => Pair<A, B>;
152
- mapFirst: <A, B, C>(p: Pair<A, B>, fn: (a: A) => C) => Pair<C, B>;
153
- mapSecond: <A, B, C>(p: Pair<A, B>, fn: (b: B) => C) => Pair<A, C>;
154
- map: <A, B, C, D>(p: Pair<A, B>, fnA: (a: A) => C, fnB: (b: B) => D) => Pair<C, D>;
155
- swap: <A, B>(p: Pair<A, B>) => Pair<B, A>;
156
- apply: <A, B, C>(p: Pair<(a: A) => B, C>, value: A) => Pair<B, C>;
157
- apply2: <A, B, C>(fnPair: Pair<(a: A) => B, (b: B) => C>, vPair: Pair<A, B>) => Pair<A, C>;
158
- reduce: <A, B, C>(p: Pair<A, B>, fn: (a: A, b: B) => C) => C;
159
155
  toArray: <A, B>(p: Pair<A, B>) => [A, B];
160
156
  toObject: <A, B>(p: Pair<A, B>) => {
161
157
  fst: A;
162
158
  snd: B;
163
159
  };
160
+ mapFirst: <A, B, C>(p: Pair<A, B>, fn: (a: A) => C) => Pair<C, B>;
161
+ mapSecond: <A, B, C>(p: Pair<A, B>, fn: (b: B) => C) => Pair<A, C>;
162
+ map: <A, B, C, D>(p: Pair<A, B>, fnA: (a: A) => C, fnB: (b: B) => D) => Pair<C, D>;
163
+ swap: <A, B>(p: Pair<A, B>) => Pair<B, A>;
164
+ fold: <A, B, C>(p: Pair<A, B>, fn: (first: A, second: B) => C) => C;
165
+ match: <A, B, C>(p: Pair<A, B>, matcher: {
166
+ new: (first: A, second: B) => C;
167
+ }) => C;
164
168
  eq: <A, B>(p1: Pair<A, B>, p2: Pair<A, B>) => boolean;
165
- equals: <A, B>(p1: Pair<A, B>, p2: Pair<A, B>, eqA: (a1: A, a2: A) => boolean, eqB: (b1: B, b2: B) => boolean) => boolean;
169
+ eql: <A, B>(p1: Pair<A, B>, p2: Pair<A, B>, eqA: (a1: A, a2: A) => boolean, eqB: (b1: B, b2: B) => boolean) => boolean;
170
+ fst: <A, B>(p: Pair<A, B>) => A;
171
+ snd: <A, B>(p: Pair<A, B>) => B;
172
+ app: <A, B, C>(p: Pair<(a: A) => B, C>, value: A) => Pair<B, C>;
173
+ apply: <A, B, C>(fnPair: Pair<(a: A) => B, (b: B) => C>, vPair: Pair<A, B>) => Pair<A, C>;
166
174
  zip: <A, B, C, D>(p1: Pair<A, B>, p2: Pair<C, D>) => Pair<Pair<A, C>, Pair<B, D>>;
167
175
  };
168
176
 
169
- type Done<T> = {
177
+ interface Done<T> {
170
178
  readonly v: T;
171
- };
172
- type Fail<E> = {
179
+ }
180
+ interface Fail<E> {
173
181
  readonly e: E;
174
- };
182
+ }
175
183
  declare const done: <T>(v: T) => Done<T>;
176
184
  declare const fail: <E>(e: E) => Fail<E>;
177
185
  declare const Ok: <T>(v: T) => Done<T>;
@@ -184,13 +192,9 @@ declare const val: <T>(r: Done<T>) => T;
184
192
  declare const err: <E>(r: Fail<E>) => E;
185
193
  type Result<T, E> = Done<T> | Fail<E>;
186
194
  declare const Result: {
195
+ new: <T, E>(value: T | null | undefined, error: E) => Result<T, E>;
187
196
  done: <T>(v: T) => Done<T>;
188
197
  fail: <E>(e: E) => Fail<E>;
189
- Ok: <T>(v: T) => Done<T>;
190
- Err: <E>(e: E) => Fail<E>;
191
- val: <T>(r: Done<T>) => T;
192
- err: <E>(r: Fail<E>) => E;
193
- new: <T, E>(value: T | null | undefined, error: E) => Result<T, E>;
194
198
  isDone: <T, E>(r: Result<T, E>) => r is Done<T>;
195
199
  isFail: <T, E>(r: Result<T, E>) => r is Fail<E>;
196
200
  isOk: <T, E>(r: Result<T, E>) => r is Done<T>;
@@ -202,19 +206,23 @@ declare const Result: {
202
206
  mapErr: <T, E, F>(r: Result<T, E>, fn: (b: E) => F) => Result<T, F>;
203
207
  bimap: <T, E, U, F>(r: Result<T, E>, onDone: (a: T) => U, onFail: (b: E) => F) => Result<U, F>;
204
208
  flatMap: <T, E, C>(r: Result<T, E>, fn: (a: T) => Result<C, E>) => Result<C, E>;
209
+ filter: <T, E>(r: Result<T, E>, predicate: (a: T) => boolean, onFalse: E) => Result<T, E>;
205
210
  match: <T, E, U>(r: Result<T, E>, matcher: {
206
211
  done: (a: T) => U;
207
212
  fail: (b: E) => U;
208
213
  }) => U;
209
214
  fold: <T, E, U>(r: Result<T, E>, onFail: (error: E) => U, onDone: (value: T) => U) => U;
215
+ chain: <T, E, C>(r: Result<T, E>, fn: (a: T) => Result<C, E>) => Result<C, E>;
210
216
  recover: <T, E>(r: Result<T, E>, fn: (error: E) => T) => Result<T, E>;
211
- getOrElse: <T, E>(r: Result<T, E>, d: T) => T;
217
+ val: <T>(r: Done<T>) => T;
218
+ err: <E>(r: Fail<E>) => E;
219
+ getOrElse: <T, E>(r: Result<T, E>, defaultValue: T) => T;
212
220
  getOrUndefined: <T, E>(r: Result<T, E>) => T | undefined;
221
+ getOrNull: <T, E>(r: Result<T, E>) => T | null;
213
222
  getOrThrow: <T, E>(r: Result<T, E>) => T;
214
223
  zip: <T, U, E>(a: Result<T, E>, b: Result<U, E>) => Result<[T, U], E>;
215
224
  apply: <T, U, E>(fn: Result<(a: T) => U, E>, arg: Result<T, E>) => Result<U, E>;
216
225
  orElse: <T, E>(a: Result<T, E>, b: Result<T, E>) => Result<T, E>;
217
- filter: <T, E>(r: Result<T, E>, predicate: (a: T) => boolean, onFalse: E) => Result<T, E>;
218
226
  tap: <T, E>(r: Result<T, E>, f: (a: T) => void) => Result<T, E>;
219
227
  tapErr: <T, E>(r: Result<T, E>, f: (b: E) => void) => Result<T, E>;
220
228
  };
@@ -224,4 +232,4 @@ declare global {
224
232
  }
225
233
  }
226
234
 
227
- export { type Done, Either, Err, type Fail, type Left, Maybe, type None, type Nothing, type NothingNull, type NothingUndefined, Ok, Option, Pair, Result, type Right, type Some, done, err, fail, fst, getLeft, getRight, isDone, isErr, isFail, isJust, isLeft, isNone, isNothing, isOk, isRight, isSome, just, left, none, nothing, pair, right, snd, some, unwrap, val };
235
+ export { type Done, Either, Err, type Fail, type Left, Maybe, type None, type Nothing, Ok, Option, Pair, Result, type Right, type Some, done, err, fail, fst, isDone, isErr, isFail, isJust, isLeft, isNone, isNothing, isOk, isRight, isSome, just, left, lft, none, nothing, pair, rgt, right, snd, some, unwrap, val };
package/dist/index.d.ts CHANGED
@@ -1,22 +1,22 @@
1
- type Left<A> = {
1
+ interface Left<A> {
2
2
  readonly $: "Left";
3
3
  readonly value: A;
4
- };
5
- type Right<B> = {
4
+ }
5
+ interface Right<B> {
6
6
  readonly $: "Right";
7
7
  readonly value: B;
8
- };
8
+ }
9
9
  declare const left: <A>(value: A) => Left<A>;
10
10
  declare const right: <B>(value: B) => Right<B>;
11
11
  declare const isLeft: <A, B>(e: Either<A, B>) => e is Left<A>;
12
12
  declare const isRight: <A, B>(e: Either<A, B>) => e is Right<B>;
13
- declare const getLeft: <A>(e: Left<A>) => A;
14
- declare const getRight: <B>(e: Right<B>) => B;
13
+ declare const lft: <A>(e: Left<A>) => A;
14
+ declare const rgt: <B>(e: Right<B>) => B;
15
15
  type Either<A, B> = Left<A> | Right<B>;
16
16
  declare const Either: {
17
+ new: <A, B>(value: B | null | undefined, error: A) => Either<A, B>;
17
18
  left: <A>(value: A) => Left<A>;
18
19
  right: <B>(value: B) => Right<B>;
19
- new: <A, B>(value: B | null | undefined, error: A) => Either<A, B>;
20
20
  isLeft: <A, B>(e: Either<A, B>) => e is Left<A>;
21
21
  isRight: <A, B>(e: Either<A, B>) => e is Right<B>;
22
22
  fromNullable: <A, B>(value: B | null | undefined, error: A) => Either<A, B>;
@@ -26,6 +26,7 @@ declare const Either: {
26
26
  mapLeft: <A, B, C>(e: Either<A, B>, fn: (l: A) => C) => Either<C, B>;
27
27
  bimap: <A, B, C, D>(e: Either<A, B>, fl: (l: A) => C, fr: (r: B) => D) => Either<C, D>;
28
28
  flatMap: <A, B, C>(e: Either<A, B>, fn: (value: B) => Either<A, C>) => Either<A, C>;
29
+ filter: <A, B>(e: Either<A, B>, predicate: (value: B) => boolean, onFalse: A) => Either<A, B>;
29
30
  chain: <A, B, C>(e: Either<A, B>, fn: (r: B) => Either<A, C>) => Either<A, C>;
30
31
  fold: <A, B, C>(e: Either<A, B>, onLeft: (l: A) => C, onRight: (r: B) => C) => C;
31
32
  match: <A, B, C>(e: Either<A, B>, matcher: {
@@ -33,13 +34,15 @@ declare const Either: {
33
34
  left: (value: A) => C;
34
35
  }) => C;
35
36
  swap: <A, B>(e: Either<A, B>) => Either<B, A>;
36
- getLeft: <A>(e: Left<A>) => A;
37
- getRight: <B>(e: Right<B>) => B;
37
+ lft: <A>(e: Left<A>) => A;
38
+ rgt: <B>(e: Right<B>) => B;
38
39
  getOrElse: <A, B>(e: Either<A, B>, defaultValue: B) => B;
40
+ getOrNull: <A, B>(e: Either<A, B>) => B | null;
39
41
  getOrUndefined: <A, B>(e: Either<A, B>) => B | undefined;
40
42
  getOrThrow: <A, B>(e: Either<A, B>) => B;
41
43
  zip: <E, A, B>(a: Either<E, A>, b: Either<E, B>) => Either<E, [A, B]>;
42
44
  apply: <E, A, B>(fn: Either<E, (value: A) => B>, arg: Either<E, A>) => Either<E, B>;
45
+ orElse: <E, A, B>(a: Either<E, A>, b: Either<E, B>) => Either<E, A | B>;
43
46
  tap: <A, B>(e: Either<A, B>, f: (r: B) => void) => Either<A, B>;
44
47
  tapLeft: <A, B>(e: Either<A, B>, f: (l: A) => void) => Either<A, B>;
45
48
  };
@@ -49,29 +52,26 @@ declare global {
49
52
  }
50
53
  }
51
54
 
52
- type NothingNull = null;
53
- type NothingUndefined = undefined;
54
- type Nothing = NothingNull | NothingUndefined;
55
- declare const just: <T>(value: T) => Maybe<T>;
55
+ type Nothing = null | undefined;
56
+ declare const just: <T>(value: T) => T;
56
57
  declare const nothing: () => Nothing;
57
58
  declare const isJust: <T>(m: Maybe<T>) => m is T;
58
59
  declare const isNothing: <T>(m: Maybe<T>) => m is Nothing;
59
60
  type Maybe<T> = T | Nothing;
60
61
  declare const Maybe: {
61
- just: <T>(value: T) => Maybe<T>;
62
- nothing: () => Nothing;
63
62
  new: <T>(m: T | null | undefined) => Maybe<T>;
64
- nothingNull: () => NothingNull;
65
- nothingUndefined: () => NothingUndefined;
63
+ just: <T>(value: T) => T;
64
+ nothing: () => Nothing;
65
+ nothingNull: () => null;
66
+ nothingUndefined: () => undefined;
66
67
  isJust: <T>(m: Maybe<T>) => m is T;
67
68
  isNothing: <T>(m: Maybe<T>) => m is Nothing;
68
- isNothingNull: <T>(m: Maybe<T>) => m is NothingNull;
69
- isNothingUndefined: <T>(m: Maybe<T>) => m is NothingUndefined;
69
+ isNull: <T>(m: Maybe<T>) => m is null;
70
+ isUndefined: <T>(m: Maybe<T>) => m is undefined;
70
71
  fromNullable: <T>(m: T | null | undefined) => Maybe<T>;
71
72
  fromThrowable: <T>(fn: () => T) => Maybe<T>;
73
+ fromPredicate: <T>(value: T, predicate: (value: T) => boolean) => Maybe<T>;
72
74
  fromPromise: <T>(promise: Promise<T>) => Promise<Maybe<T>>;
73
- toNullable: <T>(m: Maybe<T>) => T | null;
74
- toUndefined: <T>(m: Maybe<T>) => T | undefined;
75
75
  map: <T, U>(m: Maybe<T>, fn: (v: T) => U) => Maybe<U>;
76
76
  flatMap: <T, U>(m: Maybe<T>, fn: (v: T) => Maybe<U>) => Maybe<U>;
77
77
  filter: <T>(m: Maybe<T>, predicate: (value: T) => boolean) => Maybe<T>;
@@ -80,21 +80,23 @@ declare const Maybe: {
80
80
  nothing: () => U;
81
81
  }) => U;
82
82
  fold: <T, U>(m: Maybe<T>, onNothing: () => U, onJust: (v: T) => U) => U;
83
- getOrElse: <T>(m: Maybe<T>, d: T) => T;
83
+ getOrElse: <T>(m: Maybe<T>, defaultValue: T) => T;
84
84
  getOrUndefined: <T>(m: Maybe<T>) => T | undefined;
85
+ getOrNull: <T>(m: Maybe<T>) => T | null;
85
86
  getOrThrow: <T>(m: Maybe<T>) => T;
86
87
  zip: <T, U>(a: Maybe<T>, b: Maybe<U>) => Maybe<[T, U]>;
87
88
  apply: <T, U>(fn: Maybe<(value: T) => U>, opt: Maybe<T>) => Maybe<U>;
88
89
  orElse: <T>(opt: Maybe<T>, other: Maybe<T>) => Maybe<T>;
90
+ tap: <T>(m: Maybe<T>, fn: (v: T) => void) => Maybe<T>;
89
91
  };
90
92
 
91
- type None = {
93
+ interface None {
92
94
  readonly $: "None";
93
- };
94
- type Some<T> = {
95
+ }
96
+ interface Some<T> {
95
97
  readonly $: "Some";
96
98
  readonly value: T;
97
- };
99
+ }
98
100
  declare const none: <T>() => Option<T>;
99
101
  declare const some: <T>(value: T) => Option<T>;
100
102
  declare const isSome: <T>(option: Option<T>) => option is Some<T>;
@@ -102,9 +104,9 @@ declare const isNone: <T>(option: Option<T>) => option is None;
102
104
  declare const unwrap: <T>(option: Some<T>) => T;
103
105
  type Option<T> = None | Some<T>;
104
106
  declare const Option: {
107
+ new: <T>(value: T | null | undefined) => Option<T>;
105
108
  none: <T>() => Option<T>;
106
109
  some: <T>(value: T) => Option<T>;
107
- new: <T>(value: T | null | undefined) => Option<T>;
108
110
  isSome: <T>(option: Option<T>) => option is Some<T>;
109
111
  isNone: <T>(option: Option<T>) => option is None;
110
112
  fromNullable: <T>(value: T | null | undefined) => Option<T>;
@@ -114,6 +116,7 @@ declare const Option: {
114
116
  map: <T, U>(option: Option<T>, fn: (value: T) => U) => Option<U>;
115
117
  flatMap: <T, U>(option: Option<T>, fn: (value: T) => Option<U>) => Option<U>;
116
118
  filter: <T>(option: Option<T>, predicate: (value: T) => boolean) => Option<T>;
119
+ fold: <T, U>(option: Option<T>, onNone: () => U, onSome: (value: T) => U) => U;
117
120
  match: <T, U>(option: Option<T>, matcher: {
118
121
  some: (value: T) => U;
119
122
  none: () => U;
@@ -121,10 +124,12 @@ declare const Option: {
121
124
  unwrap: <T>(option: Some<T>) => T;
122
125
  getOrElse: <T>(option: Option<T>, defaultValue: T) => T;
123
126
  getOrUndefined: <T>(option: Option<T>) => T | undefined;
127
+ getOrNull: <T>(option: Option<T>) => T | null;
124
128
  getOrThrow: <T>(option: Option<T>) => T;
125
129
  zip: <T, U>(a: Option<T>, b: Option<U>) => Option<[T, U]>;
126
130
  apply: <T, U>(fn: Option<(value: T) => U>, opt: Option<T>) => Option<U>;
127
131
  orElse: <T>(opt: Option<T>, other: Option<T>) => Option<T>;
132
+ tap: <T>(option: Option<T>, f: (value: T) => void) => Option<T>;
128
133
  };
129
134
  declare global {
130
135
  interface Array<T> {
@@ -135,43 +140,46 @@ declare global {
135
140
  }
136
141
  }
137
142
 
143
+ declare const pair: <A, B>(a: A, b: B) => Pair<A, B>;
138
144
  declare const fst: <A, B>(p: Pair<A, B>) => A;
139
145
  declare const snd: <A, B>(p: Pair<A, B>) => B;
140
- declare const pair: <A, B>(a: A, b: B) => Pair<A, B>;
141
146
  type Pair<A, B> = readonly [A, B];
142
147
  declare const Pair: {
143
- fst: <A, B>(p: Pair<A, B>) => A;
144
- snd: <A, B>(p: Pair<A, B>) => B;
145
148
  new: <A, B>(a: A, b: B) => Pair<A, B>;
149
+ curry: <A>(a: A) => <B>(b: B) => Pair<A, B>;
146
150
  fromArray: <A, B>([a, b]: [A, B]) => Pair<A, B>;
147
151
  fromObject: <A, B>(obj: {
148
152
  fst: A;
149
153
  snd: B;
150
154
  }) => Pair<A, B>;
151
- curry: <A>(a: A) => <B>(b: B) => Pair<A, B>;
152
- mapFirst: <A, B, C>(p: Pair<A, B>, fn: (a: A) => C) => Pair<C, B>;
153
- mapSecond: <A, B, C>(p: Pair<A, B>, fn: (b: B) => C) => Pair<A, C>;
154
- map: <A, B, C, D>(p: Pair<A, B>, fnA: (a: A) => C, fnB: (b: B) => D) => Pair<C, D>;
155
- swap: <A, B>(p: Pair<A, B>) => Pair<B, A>;
156
- apply: <A, B, C>(p: Pair<(a: A) => B, C>, value: A) => Pair<B, C>;
157
- apply2: <A, B, C>(fnPair: Pair<(a: A) => B, (b: B) => C>, vPair: Pair<A, B>) => Pair<A, C>;
158
- reduce: <A, B, C>(p: Pair<A, B>, fn: (a: A, b: B) => C) => C;
159
155
  toArray: <A, B>(p: Pair<A, B>) => [A, B];
160
156
  toObject: <A, B>(p: Pair<A, B>) => {
161
157
  fst: A;
162
158
  snd: B;
163
159
  };
160
+ mapFirst: <A, B, C>(p: Pair<A, B>, fn: (a: A) => C) => Pair<C, B>;
161
+ mapSecond: <A, B, C>(p: Pair<A, B>, fn: (b: B) => C) => Pair<A, C>;
162
+ map: <A, B, C, D>(p: Pair<A, B>, fnA: (a: A) => C, fnB: (b: B) => D) => Pair<C, D>;
163
+ swap: <A, B>(p: Pair<A, B>) => Pair<B, A>;
164
+ fold: <A, B, C>(p: Pair<A, B>, fn: (first: A, second: B) => C) => C;
165
+ match: <A, B, C>(p: Pair<A, B>, matcher: {
166
+ new: (first: A, second: B) => C;
167
+ }) => C;
164
168
  eq: <A, B>(p1: Pair<A, B>, p2: Pair<A, B>) => boolean;
165
- equals: <A, B>(p1: Pair<A, B>, p2: Pair<A, B>, eqA: (a1: A, a2: A) => boolean, eqB: (b1: B, b2: B) => boolean) => boolean;
169
+ eql: <A, B>(p1: Pair<A, B>, p2: Pair<A, B>, eqA: (a1: A, a2: A) => boolean, eqB: (b1: B, b2: B) => boolean) => boolean;
170
+ fst: <A, B>(p: Pair<A, B>) => A;
171
+ snd: <A, B>(p: Pair<A, B>) => B;
172
+ app: <A, B, C>(p: Pair<(a: A) => B, C>, value: A) => Pair<B, C>;
173
+ apply: <A, B, C>(fnPair: Pair<(a: A) => B, (b: B) => C>, vPair: Pair<A, B>) => Pair<A, C>;
166
174
  zip: <A, B, C, D>(p1: Pair<A, B>, p2: Pair<C, D>) => Pair<Pair<A, C>, Pair<B, D>>;
167
175
  };
168
176
 
169
- type Done<T> = {
177
+ interface Done<T> {
170
178
  readonly v: T;
171
- };
172
- type Fail<E> = {
179
+ }
180
+ interface Fail<E> {
173
181
  readonly e: E;
174
- };
182
+ }
175
183
  declare const done: <T>(v: T) => Done<T>;
176
184
  declare const fail: <E>(e: E) => Fail<E>;
177
185
  declare const Ok: <T>(v: T) => Done<T>;
@@ -184,13 +192,9 @@ declare const val: <T>(r: Done<T>) => T;
184
192
  declare const err: <E>(r: Fail<E>) => E;
185
193
  type Result<T, E> = Done<T> | Fail<E>;
186
194
  declare const Result: {
195
+ new: <T, E>(value: T | null | undefined, error: E) => Result<T, E>;
187
196
  done: <T>(v: T) => Done<T>;
188
197
  fail: <E>(e: E) => Fail<E>;
189
- Ok: <T>(v: T) => Done<T>;
190
- Err: <E>(e: E) => Fail<E>;
191
- val: <T>(r: Done<T>) => T;
192
- err: <E>(r: Fail<E>) => E;
193
- new: <T, E>(value: T | null | undefined, error: E) => Result<T, E>;
194
198
  isDone: <T, E>(r: Result<T, E>) => r is Done<T>;
195
199
  isFail: <T, E>(r: Result<T, E>) => r is Fail<E>;
196
200
  isOk: <T, E>(r: Result<T, E>) => r is Done<T>;
@@ -202,19 +206,23 @@ declare const Result: {
202
206
  mapErr: <T, E, F>(r: Result<T, E>, fn: (b: E) => F) => Result<T, F>;
203
207
  bimap: <T, E, U, F>(r: Result<T, E>, onDone: (a: T) => U, onFail: (b: E) => F) => Result<U, F>;
204
208
  flatMap: <T, E, C>(r: Result<T, E>, fn: (a: T) => Result<C, E>) => Result<C, E>;
209
+ filter: <T, E>(r: Result<T, E>, predicate: (a: T) => boolean, onFalse: E) => Result<T, E>;
205
210
  match: <T, E, U>(r: Result<T, E>, matcher: {
206
211
  done: (a: T) => U;
207
212
  fail: (b: E) => U;
208
213
  }) => U;
209
214
  fold: <T, E, U>(r: Result<T, E>, onFail: (error: E) => U, onDone: (value: T) => U) => U;
215
+ chain: <T, E, C>(r: Result<T, E>, fn: (a: T) => Result<C, E>) => Result<C, E>;
210
216
  recover: <T, E>(r: Result<T, E>, fn: (error: E) => T) => Result<T, E>;
211
- getOrElse: <T, E>(r: Result<T, E>, d: T) => T;
217
+ val: <T>(r: Done<T>) => T;
218
+ err: <E>(r: Fail<E>) => E;
219
+ getOrElse: <T, E>(r: Result<T, E>, defaultValue: T) => T;
212
220
  getOrUndefined: <T, E>(r: Result<T, E>) => T | undefined;
221
+ getOrNull: <T, E>(r: Result<T, E>) => T | null;
213
222
  getOrThrow: <T, E>(r: Result<T, E>) => T;
214
223
  zip: <T, U, E>(a: Result<T, E>, b: Result<U, E>) => Result<[T, U], E>;
215
224
  apply: <T, U, E>(fn: Result<(a: T) => U, E>, arg: Result<T, E>) => Result<U, E>;
216
225
  orElse: <T, E>(a: Result<T, E>, b: Result<T, E>) => Result<T, E>;
217
- filter: <T, E>(r: Result<T, E>, predicate: (a: T) => boolean, onFalse: E) => Result<T, E>;
218
226
  tap: <T, E>(r: Result<T, E>, f: (a: T) => void) => Result<T, E>;
219
227
  tapErr: <T, E>(r: Result<T, E>, f: (b: E) => void) => Result<T, E>;
220
228
  };
@@ -224,4 +232,4 @@ declare global {
224
232
  }
225
233
  }
226
234
 
227
- export { type Done, Either, Err, type Fail, type Left, Maybe, type None, type Nothing, type NothingNull, type NothingUndefined, Ok, Option, Pair, Result, type Right, type Some, done, err, fail, fst, getLeft, getRight, isDone, isErr, isFail, isJust, isLeft, isNone, isNothing, isOk, isRight, isSome, just, left, none, nothing, pair, right, snd, some, unwrap, val };
235
+ export { type Done, Either, Err, type Fail, type Left, Maybe, type None, type Nothing, Ok, Option, Pair, Result, type Right, type Some, done, err, fail, fst, isDone, isErr, isFail, isJust, isLeft, isNone, isNothing, isOk, isRight, isSome, just, left, lft, none, nothing, pair, rgt, right, snd, some, unwrap, val };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var R=(t,e,o)=>new Promise((P,C)=>{var G=U=>{try{O(o.next(U))}catch(g){C(g)}},H=U=>{try{O(o.throw(U))}catch(g){C(g)}},O=U=>U.done?P(U.value):Promise.resolve(U.value).then(G,H);O((o=o.apply(t,e)).next())});var B=t=>({$:"Left",value:t}),l= exports.right =t=>({$:"Right",value:t}),E= exports.isLeft =t=>t.$==="Left",u= exports.isRight =t=>t.$==="Right",M=(t,e)=>t==null?B(e):l(t),I=(t,e)=>{try{return l(t())}catch(o){return B(e(o))}},K=(t,e)=>R(null,null,function*(){try{let o=yield t;return l(o)}catch(o){return B(e(o))}}),Q=(t,e)=>u(t)?l(e(r(t))):t,V=(t,e)=>E(t)?B(e(h(t))):t,W=(t,e,o)=>E(t)?B(e(h(t))):l(o(r(t))),X=(t,e)=>u(t)?e(r(t)):t,Y=(t,e)=>u(t)?e(r(t)):t,Z=(t,e,o)=>E(t)?e(h(t)):o(r(t)),tt=(t,e)=>u(t)?e.right(r(t)):e.left(h(t)),et=t=>u(t)?B(r(t)):l(h(t)),h= exports.getLeft =t=>t.value,r= exports.getRight =t=>t.value,ot=(t,e)=>u(t)?r(t):e,rt=t=>u(t)?r(t):void 0,nt=t=>{if(u(t))return r(t);throw h(t)},it=(t,e)=>E(t)?t:E(e)?e:l([r(t),r(e)]),st=(t,e)=>E(t)?t:E(e)?e:l(r(t)(r(e))),Tt=(t,e)=>(u(t)&&e(r(t)),t),pt=(t,e)=>(E(t)&&e(h(t)),t),at= exports.Either ={left:B,right:l,new:M,isLeft:E,isRight:u,fromNullable:M,fromThrowable:I,fromPromise:K,map:Q,mapLeft:V,bimap:W,flatMap:X,chain:Y,fold:Z,match:tt,swap:et,getLeft:h,getRight:r,getOrElse:ot,getOrUndefined:rt,getOrThrow:nt,zip:it,apply:st,tap:Tt,tapLeft:pt};Promise.prototype.toEither=function(t){return R(this,null,function*(){try{let e=yield this;return l(e)}catch(e){return B(t(e))}})};var w=t=>t,f= exports.nothing =()=>{},lt=()=>null,v=()=>{},b= exports.isJust =t=>t!=null,p= exports.isNothing =t=>t==null,ut=t=>t===null,ct=t=>t===void 0,N=t=>t,Et=t=>p(t)?null:t,xt=t=>p(t)?void 0:t,At=t=>{try{return t()}catch(e){return f()}},Bt=t=>t.then(e=>e,()=>f());var ht=(t,e)=>p(t)?f():e(t),ft=(t,e)=>p(t)?f():e(t),dt=(t,e)=>b(t)&&e(t)?t:f(),yt=(t,e)=>p(t)?e.nothing():e.some(t),mt=(t,e,o)=>p(t)?e():o(t),Ut=(t,e)=>p(t)?e:t,bt=t=>p(t)?v():t,Pt=t=>{if(p(t))throw new Error("Maybe is nothing");return t},Ot=(t,e)=>b(t)&&b(e)?[t,e]:f(),gt=(t,e)=>b(t)&&b(e)?t(e):f(),Rt=(t,e)=>p(t)?e:t,Ct= exports.Maybe ={just:w,nothing:f,new:N,nothingNull:lt,nothingUndefined:v,isJust:b,isNothing:p,isNothingNull:ut,isNothingUndefined:ct,fromNullable:N,fromThrowable:At,fromPromise:Bt,toNullable:Et,toUndefined:xt,map:ht,flatMap:ft,filter:dt,match:yt,fold:mt,getOrElse:Ut,getOrUndefined:bt,getOrThrow:Pt,zip:Ot,apply:gt,orElse:Rt};var a=()=>({$:"None"}),x= exports.some =t=>({$:"Some",value:t}),i= exports.isSome =t=>t.$==="Some",D= exports.isNone =t=>t.$==="None",L=t=>t==null?a():x(t),Mt=(t,e)=>e(t)?x(t):a(),Nt=t=>{try{return x(t())}catch(e){return a()}},k=t=>t.then(x,()=>a()),wt=(t,e)=>i(t)?x(e(T(t))):a(),vt=(t,e)=>i(t)?e(T(t)):a(),Lt=(t,e)=>i(t)&&e(T(t))?t:a(),Dt=(t,e)=>i(t)?e.some(T(t)):e.none(),T= exports.unwrap =t=>t.value,kt=(t,e)=>i(t)?T(t):e,Ft=t=>i(t)?T(t):void 0,$t=t=>{if(i(t))return T(t);throw new Error("Option is none")},St=(t,e)=>i(t)&&i(e)?x([T(t),T(e)]):a(),zt=(t,e)=>i(t)&&i(e)?x(T(t)(T(e))):a(),jt=(t,e)=>i(t)?t:e,qt= exports.Option ={none:a,some:x,new:L,isSome:i,isNone:D,fromNullable:L,fromPredicate:Mt,fromThrowable:Nt,fromPromise:k,map:wt,flatMap:vt,filter:Lt,match:Dt,unwrap:T,getOrElse:kt,getOrUndefined:Ft,getOrThrow:$t,zip:St,apply:zt,orElse:jt};Array.prototype.firstOption=function(){return this[0]?x(this[0]):a()};Promise.prototype.toOption=function(){return k(this)};var F=t=>t[0],$= exports.snd =t=>t[1],d=(t,e)=>[t,e],Jt= exports.pair =d,_t=([t,e])=>[t,e],Gt=t=>[t.fst,t.snd],Ht=t=>e=>[t,e],It=(t,e)=>d(e(t[0]),t[1]),Kt=(t,e)=>d(t[0],e(t[1])),Qt=(t,e,o)=>d(e(t[0]),o(t[1])),Vt=t=>d(t[1],t[0]),Wt=(t,e)=>d(t[0](e),t[1]),Xt=(t,e)=>d(e[0],t[1](e[1])),Yt=(t,e)=>e(t[0],t[1]),Zt=t=>[t[0],t[1]],te=t=>({fst:t[0],snd:t[1]}),ee=(t,e)=>t[0]===e[0]&&t[1]===e[1],oe=(t,e,o,P)=>o(t[0],e[0])&&P(t[1],e[1]),re=(t,e)=>d([t[0],e[0]],[t[1],e[1]]),ne= exports.Pair ={fst:F,snd:$,new:d,fromArray:_t,fromObject:Gt,curry:Ht,mapFirst:It,mapSecond:Kt,map:Qt,swap:Vt,apply:Wt,apply2:Xt,reduce:Yt,toArray:Zt,toObject:te,eq:ee,equals:oe,zip:re};var c=t=>({v:t}),y= exports.fail =t=>({e:t}),z= exports.Ok =c,j= exports.Err =y,s= exports.isDone =t=>"v"in t,A= exports.isFail =t=>"e"in t,q= exports.isOk =s,J= exports.isErr =A,S=(t,e)=>t==null?y(e):c(t),ie=(t,e)=>{try{return c(t())}catch(o){return y(e(o))}},_=(t,e)=>t.then(c,o=>y(e(o))),se=(t,e)=>s(t)?c(e(n(t))):t,Te=(t,e)=>A(t)?y(e(m(t))):t,pe=(t,e,o)=>s(t)?c(e(n(t))):y(o(m(t))),ae=(t,e)=>s(t)?e(n(t)):t,le=(t,e)=>s(t)?e.done(n(t)):e.fail(m(t)),ue=(t,e,o)=>s(t)?o(n(t)):e(m(t)),ce=(t,e)=>A(t)?c(e(m(t))):t,n= exports.val =t=>t.v,m= exports.err =t=>t.e,Ee=(t,e)=>s(t)?n(t):e,xe=t=>s(t)?n(t):void 0,Ae=t=>{if(s(t))return n(t);throw m(t)},Be=(t,e)=>A(t)?t:A(e)?e:c([n(t),n(e)]),he=(t,e)=>A(t)?t:A(e)?e:c(n(t)(n(e))),fe=(t,e)=>s(t)?t:e,de=(t,e,o)=>s(t)?e(n(t))?t:y(o):t,ye=(t,e)=>(s(t)&&e(n(t)),t),me=(t,e)=>(A(t)&&e(m(t)),t),Ue= exports.Result ={done:c,fail:y,Ok:z,Err:j,val:n,err:m,new:S,isDone:s,isFail:A,isOk:q,isErr:J,fromNullable:S,fromThrowable:ie,fromPromise:_,map:se,mapErr:Te,bimap:pe,flatMap:ae,match:le,fold:ue,recover:ce,getOrElse:Ee,getOrUndefined:xe,getOrThrow:Ae,zip:Be,apply:he,orElse:fe,filter:de,tap:ye,tapErr:me};Promise.prototype.toResult=function(t){return _(this,t)};exports.Either = at; exports.Err = j; exports.Maybe = Ct; exports.Ok = z; exports.Option = qt; exports.Pair = ne; exports.Result = Ue; exports.done = c; exports.err = m; exports.fail = y; exports.fst = F; exports.getLeft = h; exports.getRight = r; exports.isDone = s; exports.isErr = J; exports.isFail = A; exports.isJust = b; exports.isLeft = E; exports.isNone = D; exports.isNothing = p; exports.isOk = q; exports.isRight = u; exports.isSome = i; exports.just = w; exports.left = B; exports.none = a; exports.nothing = f; exports.pair = Jt; exports.right = l; exports.snd = $; exports.some = x; exports.unwrap = T; exports.val = n;
1
+ 'use strict';var y=t=>({$:"Left",value:t}),B=t=>({$:"Right",value:t}),A=t=>t.$==="Left",a=t=>t.$==="Right",R=(t,e)=>t==null?y(e):B(t),$=(t,e)=>{try{return B(t())}catch(o){return y(e(o))}},C=(t,e)=>t.then(B,o=>y(e(o))),S=(t,e)=>a(t)?B(e(r(t))):t,z=(t,e)=>A(t)?y(e(m(t))):t,j=(t,e,o)=>A(t)?y(e(m(t))):B(o(r(t))),q=(t,e)=>a(t)?e(r(t)):t,J=(t,e,o)=>a(t)?e(r(t))?t:y(o):t,G=(t,e)=>a(t)?e(r(t)):t,H=(t,e,o)=>A(t)?e(m(t)):o(r(t)),I=(t,e)=>a(t)?e.right(r(t)):e.left(m(t)),K=t=>a(t)?y(r(t)):B(m(t)),m=t=>t.value,r=t=>t.value,Q=(t,e)=>a(t)?r(t):e,V=t=>a(t)?r(t):null,W=t=>a(t)?r(t):void 0,X=t=>{if(a(t))return r(t);throw m(t)},Y=(t,e)=>A(t)?t:A(e)?e:B([r(t),r(e)]),Z=(t,e)=>A(t)?t:A(e)?e:B(r(t)(r(e))),_=(t,e)=>a(t)?t:e,tt=(t,e)=>(a(t)&&e(r(t)),t),et=(t,e)=>(A(t)&&e(m(t)),t),ot={new:R,left:y,right:B,isLeft:A,isRight:a,fromNullable:R,fromThrowable:$,fromPromise:C,map:S,mapLeft:z,bimap:j,flatMap:q,filter:J,chain:G,fold:H,match:I,swap:K,lft:m,rgt:r,getOrElse:Q,getOrNull:V,getOrUndefined:W,getOrThrow:X,zip:Y,apply:Z,orElse:_,tap:tt,tapLeft:et};Promise.prototype.toEither=function(t){return C(this,t)};var P=t=>t,f=()=>{},rt=()=>null,nt=()=>{},b=t=>t!=null,c=t=>t==null,it=t=>t===null,st=t=>t===void 0,g=t=>t,Tt=t=>{try{return t()}catch(e){return f()}},pt=t=>t.then(P,()=>f()),lt=(t,e)=>e(t)?t:f(),at=(t,e)=>c(t)?f():e(t),ut=(t,e)=>c(t)?f():e(t),ct=(t,e)=>b(t)&&e(t)?t:f(),Et=(t,e)=>c(t)?e.nothing():e.some(t),xt=(t,e,o)=>c(t)?e():o(t),At=(t,e)=>c(t)?e:t,Bt=t=>c(t)?void 0:t,ft=t=>c(t)?null:t,ht=t=>{if(c(t))throw new Error("Maybe is nothing");return t},dt=(t,e)=>b(t)&&b(e)?[t,e]:f(),yt=(t,e)=>b(t)&&b(e)?t(e):f(),mt=(t,e)=>c(t)?e:t,Ot=(t,e)=>(b(t)&&e(t),t),Ut={new:g,just:P,nothing:f,nothingNull:rt,nothingUndefined:nt,isJust:b,isNothing:c,isNull:it,isUndefined:st,fromNullable:g,fromThrowable:Tt,fromPredicate:lt,fromPromise:pt,map:at,flatMap:ut,filter:ct,match:Et,fold:xt,getOrElse:At,getOrUndefined:Bt,getOrNull:ft,getOrThrow:ht,zip:dt,apply:yt,orElse:mt,tap:Ot};var u=()=>({$:"None"}),h=t=>({$:"Some",value:t}),T=t=>t.$==="Some",w=t=>t.$==="None",M=t=>t==null?u():h(t),bt=(t,e)=>e(t)?h(t):u(),Pt=t=>{try{return h(t())}catch(e){return u()}},v=t=>t.then(h,()=>u()),Rt=(t,e)=>T(t)?h(e(p(t))):u(),Ct=(t,e)=>T(t)?e(p(t)):u(),gt=(t,e)=>T(t)&&e(p(t))?t:u(),Mt=(t,e,o)=>T(t)?o(p(t)):e(),wt=(t,e)=>T(t)?e.some(p(t)):e.none(),p=t=>t.value,vt=(t,e)=>T(t)?p(t):e,Nt=t=>T(t)?p(t):void 0,Dt=t=>T(t)?p(t):null,kt=t=>{if(T(t))return p(t);throw new Error("Option is none")},Lt=(t,e)=>T(t)&&T(e)?h([p(t),p(e)]):u(),Ft=(t,e)=>T(t)&&T(e)?h(p(t)(p(e))):u(),$t=(t,e)=>T(t)?t:e,St=(t,e)=>(T(t)&&e(p(t)),t),zt={new:M,none:u,some:h,isSome:T,isNone:w,fromNullable:M,fromPredicate:bt,fromThrowable:Pt,fromPromise:v,map:Rt,flatMap:Ct,filter:gt,fold:Mt,match:wt,unwrap:p,getOrElse:vt,getOrUndefined:Nt,getOrNull:Dt,getOrThrow:kt,zip:Lt,apply:Ft,orElse:$t,tap:St};Array.prototype.firstOption=function(){return this[0]?h(this[0]):u()};Promise.prototype.toOption=function(){return v(this)};var E=(t,e)=>[t,e],jt=E,qt=t=>e=>[t,e],Jt=([t,e])=>E(t,e),Gt=t=>E(t.fst,t.snd),Ht=t=>[i(t),n(t)],It=t=>({fst:i(t),snd:n(t)}),Kt=(t,e)=>E(e(i(t)),n(t)),Qt=(t,e)=>E(i(t),e(n(t))),Vt=(t,e,o)=>E(e(i(t)),o(n(t))),Wt=t=>E(n(t),i(t)),Xt=(t,e)=>e(i(t),n(t)),Yt=(t,e)=>e.new(i(t),n(t)),Zt=(t,e)=>i(t)===i(e)&&n(t)===n(e),_t=(t,e,o,F)=>o(i(t),i(e))&&F(n(t),n(e)),i=t=>t[0],n=t=>t[1],te=(t,e)=>E(i(t)(e),n(t)),ee=(t,e)=>E(i(e),n(t)(n(e))),oe=(t,e)=>E([i(t),i(e)],[n(t),n(e)]),re={new:E,curry:qt,fromArray:Jt,fromObject:Gt,toArray:Ht,toObject:It,mapFirst:Kt,mapSecond:Qt,map:Vt,swap:Wt,fold:Xt,match:Yt,eq:Zt,eql:_t,fst:i,snd:n,app:te,apply:ee,zip:oe};var x=t=>({v:t}),O=t=>({e:t}),ne=x,ie=O,l=t=>"v"in t,d=t=>"e"in t,D=l,k=d,N=(t,e)=>t==null?O(e):x(t),se=(t,e)=>{try{return x(t())}catch(o){return O(e(o))}},L=(t,e)=>t.then(x,o=>O(e(o))),Te=(t,e)=>l(t)?x(e(s(t))):t,pe=(t,e)=>d(t)?O(e(U(t))):t,le=(t,e,o)=>l(t)?x(e(s(t))):O(o(U(t))),ae=(t,e)=>l(t)?e(s(t)):t,ue=(t,e)=>l(t)?e.done(s(t)):e.fail(U(t)),ce=(t,e,o)=>l(t)?o(s(t)):e(U(t)),Ee=(t,e)=>l(t)?e(s(t)):t,xe=(t,e,o)=>l(t)?e(s(t))?t:O(o):t,Ae=(t,e)=>d(t)?x(e(U(t))):t,s=t=>t.v,U=t=>t.e,Be=(t,e)=>l(t)?s(t):e,fe=t=>l(t)?s(t):void 0,he=t=>l(t)?s(t):null,de=t=>{if(l(t))return s(t);throw U(t)},ye=(t,e)=>d(t)?t:d(e)?e:x([s(t),s(e)]),me=(t,e)=>d(t)?t:d(e)?e:x(s(t)(s(e))),Oe=(t,e)=>l(t)?t:e,Ue=(t,e)=>(l(t)&&e(s(t)),t),be=(t,e)=>(d(t)&&e(U(t)),t),Pe={new:N,done:x,fail:O,isDone:l,isFail:d,isOk:D,isErr:k,fromNullable:N,fromThrowable:se,fromPromise:L,map:Te,mapErr:pe,bimap:le,flatMap:ae,filter:xe,match:ue,fold:ce,chain:Ee,recover:Ae,val:s,err:U,getOrElse:Be,getOrUndefined:fe,getOrNull:he,getOrThrow:de,zip:ye,apply:me,orElse:Oe,tap:Ue,tapErr:be};Promise.prototype.toResult=function(t){return L(this,t)};exports.Either=ot;exports.Err=ie;exports.Maybe=Ut;exports.Ok=ne;exports.Option=zt;exports.Pair=re;exports.Result=Pe;exports.done=x;exports.err=U;exports.fail=O;exports.fst=i;exports.isDone=l;exports.isErr=k;exports.isFail=d;exports.isJust=b;exports.isLeft=A;exports.isNone=w;exports.isNothing=c;exports.isOk=D;exports.isRight=a;exports.isSome=T;exports.just=P;exports.left=y;exports.lft=m;exports.none=u;exports.nothing=f;exports.pair=jt;exports.rgt=r;exports.right=B;exports.snd=n;exports.some=h;exports.unwrap=p;exports.val=s;
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- var R=(t,e,o)=>new Promise((P,C)=>{var G=U=>{try{O(o.next(U))}catch(g){C(g)}},H=U=>{try{O(o.throw(U))}catch(g){C(g)}},O=U=>U.done?P(U.value):Promise.resolve(U.value).then(G,H);O((o=o.apply(t,e)).next())});var B=t=>({$:"Left",value:t}),l=t=>({$:"Right",value:t}),E=t=>t.$==="Left",u=t=>t.$==="Right",M=(t,e)=>t==null?B(e):l(t),I=(t,e)=>{try{return l(t())}catch(o){return B(e(o))}},K=(t,e)=>R(null,null,function*(){try{let o=yield t;return l(o)}catch(o){return B(e(o))}}),Q=(t,e)=>u(t)?l(e(r(t))):t,V=(t,e)=>E(t)?B(e(h(t))):t,W=(t,e,o)=>E(t)?B(e(h(t))):l(o(r(t))),X=(t,e)=>u(t)?e(r(t)):t,Y=(t,e)=>u(t)?e(r(t)):t,Z=(t,e,o)=>E(t)?e(h(t)):o(r(t)),tt=(t,e)=>u(t)?e.right(r(t)):e.left(h(t)),et=t=>u(t)?B(r(t)):l(h(t)),h=t=>t.value,r=t=>t.value,ot=(t,e)=>u(t)?r(t):e,rt=t=>u(t)?r(t):void 0,nt=t=>{if(u(t))return r(t);throw h(t)},it=(t,e)=>E(t)?t:E(e)?e:l([r(t),r(e)]),st=(t,e)=>E(t)?t:E(e)?e:l(r(t)(r(e))),Tt=(t,e)=>(u(t)&&e(r(t)),t),pt=(t,e)=>(E(t)&&e(h(t)),t),at={left:B,right:l,new:M,isLeft:E,isRight:u,fromNullable:M,fromThrowable:I,fromPromise:K,map:Q,mapLeft:V,bimap:W,flatMap:X,chain:Y,fold:Z,match:tt,swap:et,getLeft:h,getRight:r,getOrElse:ot,getOrUndefined:rt,getOrThrow:nt,zip:it,apply:st,tap:Tt,tapLeft:pt};Promise.prototype.toEither=function(t){return R(this,null,function*(){try{let e=yield this;return l(e)}catch(e){return B(t(e))}})};var w=t=>t,f=()=>{},lt=()=>null,v=()=>{},b=t=>t!=null,p=t=>t==null,ut=t=>t===null,ct=t=>t===void 0,N=t=>t,Et=t=>p(t)?null:t,xt=t=>p(t)?void 0:t,At=t=>{try{return t()}catch(e){return f()}},Bt=t=>t.then(e=>e,()=>f());var ht=(t,e)=>p(t)?f():e(t),ft=(t,e)=>p(t)?f():e(t),dt=(t,e)=>b(t)&&e(t)?t:f(),yt=(t,e)=>p(t)?e.nothing():e.some(t),mt=(t,e,o)=>p(t)?e():o(t),Ut=(t,e)=>p(t)?e:t,bt=t=>p(t)?v():t,Pt=t=>{if(p(t))throw new Error("Maybe is nothing");return t},Ot=(t,e)=>b(t)&&b(e)?[t,e]:f(),gt=(t,e)=>b(t)&&b(e)?t(e):f(),Rt=(t,e)=>p(t)?e:t,Ct={just:w,nothing:f,new:N,nothingNull:lt,nothingUndefined:v,isJust:b,isNothing:p,isNothingNull:ut,isNothingUndefined:ct,fromNullable:N,fromThrowable:At,fromPromise:Bt,toNullable:Et,toUndefined:xt,map:ht,flatMap:ft,filter:dt,match:yt,fold:mt,getOrElse:Ut,getOrUndefined:bt,getOrThrow:Pt,zip:Ot,apply:gt,orElse:Rt};var a=()=>({$:"None"}),x=t=>({$:"Some",value:t}),i=t=>t.$==="Some",D=t=>t.$==="None",L=t=>t==null?a():x(t),Mt=(t,e)=>e(t)?x(t):a(),Nt=t=>{try{return x(t())}catch(e){return a()}},k=t=>t.then(x,()=>a()),wt=(t,e)=>i(t)?x(e(T(t))):a(),vt=(t,e)=>i(t)?e(T(t)):a(),Lt=(t,e)=>i(t)&&e(T(t))?t:a(),Dt=(t,e)=>i(t)?e.some(T(t)):e.none(),T=t=>t.value,kt=(t,e)=>i(t)?T(t):e,Ft=t=>i(t)?T(t):void 0,$t=t=>{if(i(t))return T(t);throw new Error("Option is none")},St=(t,e)=>i(t)&&i(e)?x([T(t),T(e)]):a(),zt=(t,e)=>i(t)&&i(e)?x(T(t)(T(e))):a(),jt=(t,e)=>i(t)?t:e,qt={none:a,some:x,new:L,isSome:i,isNone:D,fromNullable:L,fromPredicate:Mt,fromThrowable:Nt,fromPromise:k,map:wt,flatMap:vt,filter:Lt,match:Dt,unwrap:T,getOrElse:kt,getOrUndefined:Ft,getOrThrow:$t,zip:St,apply:zt,orElse:jt};Array.prototype.firstOption=function(){return this[0]?x(this[0]):a()};Promise.prototype.toOption=function(){return k(this)};var F=t=>t[0],$=t=>t[1],d=(t,e)=>[t,e],Jt=d,_t=([t,e])=>[t,e],Gt=t=>[t.fst,t.snd],Ht=t=>e=>[t,e],It=(t,e)=>d(e(t[0]),t[1]),Kt=(t,e)=>d(t[0],e(t[1])),Qt=(t,e,o)=>d(e(t[0]),o(t[1])),Vt=t=>d(t[1],t[0]),Wt=(t,e)=>d(t[0](e),t[1]),Xt=(t,e)=>d(e[0],t[1](e[1])),Yt=(t,e)=>e(t[0],t[1]),Zt=t=>[t[0],t[1]],te=t=>({fst:t[0],snd:t[1]}),ee=(t,e)=>t[0]===e[0]&&t[1]===e[1],oe=(t,e,o,P)=>o(t[0],e[0])&&P(t[1],e[1]),re=(t,e)=>d([t[0],e[0]],[t[1],e[1]]),ne={fst:F,snd:$,new:d,fromArray:_t,fromObject:Gt,curry:Ht,mapFirst:It,mapSecond:Kt,map:Qt,swap:Vt,apply:Wt,apply2:Xt,reduce:Yt,toArray:Zt,toObject:te,eq:ee,equals:oe,zip:re};var c=t=>({v:t}),y=t=>({e:t}),z=c,j=y,s=t=>"v"in t,A=t=>"e"in t,q=s,J=A,S=(t,e)=>t==null?y(e):c(t),ie=(t,e)=>{try{return c(t())}catch(o){return y(e(o))}},_=(t,e)=>t.then(c,o=>y(e(o))),se=(t,e)=>s(t)?c(e(n(t))):t,Te=(t,e)=>A(t)?y(e(m(t))):t,pe=(t,e,o)=>s(t)?c(e(n(t))):y(o(m(t))),ae=(t,e)=>s(t)?e(n(t)):t,le=(t,e)=>s(t)?e.done(n(t)):e.fail(m(t)),ue=(t,e,o)=>s(t)?o(n(t)):e(m(t)),ce=(t,e)=>A(t)?c(e(m(t))):t,n=t=>t.v,m=t=>t.e,Ee=(t,e)=>s(t)?n(t):e,xe=t=>s(t)?n(t):void 0,Ae=t=>{if(s(t))return n(t);throw m(t)},Be=(t,e)=>A(t)?t:A(e)?e:c([n(t),n(e)]),he=(t,e)=>A(t)?t:A(e)?e:c(n(t)(n(e))),fe=(t,e)=>s(t)?t:e,de=(t,e,o)=>s(t)?e(n(t))?t:y(o):t,ye=(t,e)=>(s(t)&&e(n(t)),t),me=(t,e)=>(A(t)&&e(m(t)),t),Ue={done:c,fail:y,Ok:z,Err:j,val:n,err:m,new:S,isDone:s,isFail:A,isOk:q,isErr:J,fromNullable:S,fromThrowable:ie,fromPromise:_,map:se,mapErr:Te,bimap:pe,flatMap:ae,match:le,fold:ue,recover:ce,getOrElse:Ee,getOrUndefined:xe,getOrThrow:Ae,zip:Be,apply:he,orElse:fe,filter:de,tap:ye,tapErr:me};Promise.prototype.toResult=function(t){return _(this,t)};export{at as Either,j as Err,Ct as Maybe,z as Ok,qt as Option,ne as Pair,Ue as Result,c as done,m as err,y as fail,F as fst,h as getLeft,r as getRight,s as isDone,J as isErr,A as isFail,b as isJust,E as isLeft,D as isNone,p as isNothing,q as isOk,u as isRight,i as isSome,w as just,B as left,a as none,f as nothing,Jt as pair,l as right,$ as snd,x as some,T as unwrap,n as val};
1
+ var y=t=>({$:"Left",value:t}),B=t=>({$:"Right",value:t}),A=t=>t.$==="Left",a=t=>t.$==="Right",R=(t,e)=>t==null?y(e):B(t),$=(t,e)=>{try{return B(t())}catch(o){return y(e(o))}},C=(t,e)=>t.then(B,o=>y(e(o))),S=(t,e)=>a(t)?B(e(r(t))):t,z=(t,e)=>A(t)?y(e(m(t))):t,j=(t,e,o)=>A(t)?y(e(m(t))):B(o(r(t))),q=(t,e)=>a(t)?e(r(t)):t,J=(t,e,o)=>a(t)?e(r(t))?t:y(o):t,G=(t,e)=>a(t)?e(r(t)):t,H=(t,e,o)=>A(t)?e(m(t)):o(r(t)),I=(t,e)=>a(t)?e.right(r(t)):e.left(m(t)),K=t=>a(t)?y(r(t)):B(m(t)),m=t=>t.value,r=t=>t.value,Q=(t,e)=>a(t)?r(t):e,V=t=>a(t)?r(t):null,W=t=>a(t)?r(t):void 0,X=t=>{if(a(t))return r(t);throw m(t)},Y=(t,e)=>A(t)?t:A(e)?e:B([r(t),r(e)]),Z=(t,e)=>A(t)?t:A(e)?e:B(r(t)(r(e))),_=(t,e)=>a(t)?t:e,tt=(t,e)=>(a(t)&&e(r(t)),t),et=(t,e)=>(A(t)&&e(m(t)),t),ot={new:R,left:y,right:B,isLeft:A,isRight:a,fromNullable:R,fromThrowable:$,fromPromise:C,map:S,mapLeft:z,bimap:j,flatMap:q,filter:J,chain:G,fold:H,match:I,swap:K,lft:m,rgt:r,getOrElse:Q,getOrNull:V,getOrUndefined:W,getOrThrow:X,zip:Y,apply:Z,orElse:_,tap:tt,tapLeft:et};Promise.prototype.toEither=function(t){return C(this,t)};var P=t=>t,f=()=>{},rt=()=>null,nt=()=>{},b=t=>t!=null,c=t=>t==null,it=t=>t===null,st=t=>t===void 0,g=t=>t,Tt=t=>{try{return t()}catch(e){return f()}},pt=t=>t.then(P,()=>f()),lt=(t,e)=>e(t)?t:f(),at=(t,e)=>c(t)?f():e(t),ut=(t,e)=>c(t)?f():e(t),ct=(t,e)=>b(t)&&e(t)?t:f(),Et=(t,e)=>c(t)?e.nothing():e.some(t),xt=(t,e,o)=>c(t)?e():o(t),At=(t,e)=>c(t)?e:t,Bt=t=>c(t)?void 0:t,ft=t=>c(t)?null:t,ht=t=>{if(c(t))throw new Error("Maybe is nothing");return t},dt=(t,e)=>b(t)&&b(e)?[t,e]:f(),yt=(t,e)=>b(t)&&b(e)?t(e):f(),mt=(t,e)=>c(t)?e:t,Ot=(t,e)=>(b(t)&&e(t),t),Ut={new:g,just:P,nothing:f,nothingNull:rt,nothingUndefined:nt,isJust:b,isNothing:c,isNull:it,isUndefined:st,fromNullable:g,fromThrowable:Tt,fromPredicate:lt,fromPromise:pt,map:at,flatMap:ut,filter:ct,match:Et,fold:xt,getOrElse:At,getOrUndefined:Bt,getOrNull:ft,getOrThrow:ht,zip:dt,apply:yt,orElse:mt,tap:Ot};var u=()=>({$:"None"}),h=t=>({$:"Some",value:t}),T=t=>t.$==="Some",w=t=>t.$==="None",M=t=>t==null?u():h(t),bt=(t,e)=>e(t)?h(t):u(),Pt=t=>{try{return h(t())}catch(e){return u()}},v=t=>t.then(h,()=>u()),Rt=(t,e)=>T(t)?h(e(p(t))):u(),Ct=(t,e)=>T(t)?e(p(t)):u(),gt=(t,e)=>T(t)&&e(p(t))?t:u(),Mt=(t,e,o)=>T(t)?o(p(t)):e(),wt=(t,e)=>T(t)?e.some(p(t)):e.none(),p=t=>t.value,vt=(t,e)=>T(t)?p(t):e,Nt=t=>T(t)?p(t):void 0,Dt=t=>T(t)?p(t):null,kt=t=>{if(T(t))return p(t);throw new Error("Option is none")},Lt=(t,e)=>T(t)&&T(e)?h([p(t),p(e)]):u(),Ft=(t,e)=>T(t)&&T(e)?h(p(t)(p(e))):u(),$t=(t,e)=>T(t)?t:e,St=(t,e)=>(T(t)&&e(p(t)),t),zt={new:M,none:u,some:h,isSome:T,isNone:w,fromNullable:M,fromPredicate:bt,fromThrowable:Pt,fromPromise:v,map:Rt,flatMap:Ct,filter:gt,fold:Mt,match:wt,unwrap:p,getOrElse:vt,getOrUndefined:Nt,getOrNull:Dt,getOrThrow:kt,zip:Lt,apply:Ft,orElse:$t,tap:St};Array.prototype.firstOption=function(){return this[0]?h(this[0]):u()};Promise.prototype.toOption=function(){return v(this)};var E=(t,e)=>[t,e],jt=E,qt=t=>e=>[t,e],Jt=([t,e])=>E(t,e),Gt=t=>E(t.fst,t.snd),Ht=t=>[i(t),n(t)],It=t=>({fst:i(t),snd:n(t)}),Kt=(t,e)=>E(e(i(t)),n(t)),Qt=(t,e)=>E(i(t),e(n(t))),Vt=(t,e,o)=>E(e(i(t)),o(n(t))),Wt=t=>E(n(t),i(t)),Xt=(t,e)=>e(i(t),n(t)),Yt=(t,e)=>e.new(i(t),n(t)),Zt=(t,e)=>i(t)===i(e)&&n(t)===n(e),_t=(t,e,o,F)=>o(i(t),i(e))&&F(n(t),n(e)),i=t=>t[0],n=t=>t[1],te=(t,e)=>E(i(t)(e),n(t)),ee=(t,e)=>E(i(e),n(t)(n(e))),oe=(t,e)=>E([i(t),i(e)],[n(t),n(e)]),re={new:E,curry:qt,fromArray:Jt,fromObject:Gt,toArray:Ht,toObject:It,mapFirst:Kt,mapSecond:Qt,map:Vt,swap:Wt,fold:Xt,match:Yt,eq:Zt,eql:_t,fst:i,snd:n,app:te,apply:ee,zip:oe};var x=t=>({v:t}),O=t=>({e:t}),ne=x,ie=O,l=t=>"v"in t,d=t=>"e"in t,D=l,k=d,N=(t,e)=>t==null?O(e):x(t),se=(t,e)=>{try{return x(t())}catch(o){return O(e(o))}},L=(t,e)=>t.then(x,o=>O(e(o))),Te=(t,e)=>l(t)?x(e(s(t))):t,pe=(t,e)=>d(t)?O(e(U(t))):t,le=(t,e,o)=>l(t)?x(e(s(t))):O(o(U(t))),ae=(t,e)=>l(t)?e(s(t)):t,ue=(t,e)=>l(t)?e.done(s(t)):e.fail(U(t)),ce=(t,e,o)=>l(t)?o(s(t)):e(U(t)),Ee=(t,e)=>l(t)?e(s(t)):t,xe=(t,e,o)=>l(t)?e(s(t))?t:O(o):t,Ae=(t,e)=>d(t)?x(e(U(t))):t,s=t=>t.v,U=t=>t.e,Be=(t,e)=>l(t)?s(t):e,fe=t=>l(t)?s(t):void 0,he=t=>l(t)?s(t):null,de=t=>{if(l(t))return s(t);throw U(t)},ye=(t,e)=>d(t)?t:d(e)?e:x([s(t),s(e)]),me=(t,e)=>d(t)?t:d(e)?e:x(s(t)(s(e))),Oe=(t,e)=>l(t)?t:e,Ue=(t,e)=>(l(t)&&e(s(t)),t),be=(t,e)=>(d(t)&&e(U(t)),t),Pe={new:N,done:x,fail:O,isDone:l,isFail:d,isOk:D,isErr:k,fromNullable:N,fromThrowable:se,fromPromise:L,map:Te,mapErr:pe,bimap:le,flatMap:ae,filter:xe,match:ue,fold:ce,chain:Ee,recover:Ae,val:s,err:U,getOrElse:Be,getOrUndefined:fe,getOrNull:he,getOrThrow:de,zip:ye,apply:me,orElse:Oe,tap:Ue,tapErr:be};Promise.prototype.toResult=function(t){return L(this,t)};export{ot as Either,ie as Err,Ut as Maybe,ne as Ok,zt as Option,re as Pair,Pe as Result,x as done,U as err,O as fail,i as fst,l as isDone,k as isErr,d as isFail,b as isJust,A as isLeft,w as isNone,c as isNothing,D as isOk,a as isRight,T as isSome,P as just,y as left,m as lft,u as none,f as nothing,jt as pair,r as rgt,B as right,n as snd,h as some,p as unwrap,s as val};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lite-fp",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "Functional programming utilities.",
5
5
  "license": "MIT",
6
6
  "main": "./dist/index.js",