lite-fp 0.4.0 → 0.4.1
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 +199 -0
- package/dist/index.d.ts +199 -0
- package/dist/index.js +1 -0
- package/dist/index.mjs +1 -0
- package/package.json +1 -1
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
type Left<A> = {
|
|
2
|
+
readonly $: "Left";
|
|
3
|
+
readonly value: A;
|
|
4
|
+
};
|
|
5
|
+
type Right<B> = {
|
|
6
|
+
readonly $: "Right";
|
|
7
|
+
readonly value: B;
|
|
8
|
+
};
|
|
9
|
+
declare const left: <A>(value: A) => Left<A>;
|
|
10
|
+
declare const right: <B>(value: B) => Right<B>;
|
|
11
|
+
type Either<A, B> = Left<A> | Right<B>;
|
|
12
|
+
declare const Either: {
|
|
13
|
+
left: <A>(value: A) => Left<A>;
|
|
14
|
+
right: <B>(value: B) => Right<B>;
|
|
15
|
+
new: <A, B>(value: B | null | undefined, error: A) => Either<A, B>;
|
|
16
|
+
isLeft: <A, B>(e: Either<A, B>) => e is Left<A>;
|
|
17
|
+
isRight: <A, B>(e: Either<A, B>) => e is Right<B>;
|
|
18
|
+
fromNullable: <A, B>(value: B | null | undefined, error: A) => Either<A, B>;
|
|
19
|
+
fromThrowable: <A, B>(fn: () => B, onError: (e: unknown) => A) => Either<A, B>;
|
|
20
|
+
fromPromise: <A, B>(promise: Promise<B>, onError: (e: unknown) => A) => Promise<Either<A, B>>;
|
|
21
|
+
map: <A, B, C>(e: Either<A, B>, fn: (r: B) => C) => Either<A, C>;
|
|
22
|
+
mapLeft: <A, B, C>(e: Either<A, B>, fn: (l: A) => C) => Either<C, B>;
|
|
23
|
+
bimap: <A, B, C, D>(e: Either<A, B>, fl: (l: A) => C, fr: (r: B) => D) => Either<C, D>;
|
|
24
|
+
flatMap: <A, B, C>(e: Either<A, B>, fn: (value: B) => Either<A, C>) => Either<A, C>;
|
|
25
|
+
chain: <A, B, C>(e: Either<A, B>, fn: (r: B) => Either<A, C>) => Either<A, C>;
|
|
26
|
+
fold: <A, B, C>(e: Either<A, B>, onLeft: (l: A) => C, onRight: (r: B) => C) => C;
|
|
27
|
+
match: <A, B, C>(e: Either<A, B>, matcher: {
|
|
28
|
+
right: (value: B) => C;
|
|
29
|
+
left: (value: A) => C;
|
|
30
|
+
}) => C;
|
|
31
|
+
swap: <A, B>(e: Either<A, B>) => Either<B, A>;
|
|
32
|
+
getOrElse: <A, B>(e: Either<A, B>, defaultValue: B) => B;
|
|
33
|
+
zip: <E, A, B>(a: Either<E, A>, b: Either<E, B>) => Either<E, [A, B]>;
|
|
34
|
+
apply: <E, A, B>(fn: Either<E, (value: A) => B>, arg: Either<E, A>) => Either<E, B>;
|
|
35
|
+
tap: <A, B>(e: Either<A, B>, f: (r: B) => void) => Either<A, B>;
|
|
36
|
+
tapLeft: <A, B>(e: Either<A, B>, f: (l: A) => void) => Either<A, B>;
|
|
37
|
+
};
|
|
38
|
+
declare global {
|
|
39
|
+
interface Promise<T> {
|
|
40
|
+
toEither<A>(onError: (e: unknown) => A): Promise<Either<A, T>>;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
type NothingNull = null;
|
|
45
|
+
type NothingUndefined = undefined;
|
|
46
|
+
type Nothing = NothingNull | NothingUndefined;
|
|
47
|
+
declare const just: <T>(value: T) => Maybe<T>;
|
|
48
|
+
declare const nothing: () => Nothing;
|
|
49
|
+
type Maybe<T> = T | Nothing;
|
|
50
|
+
declare const Maybe: {
|
|
51
|
+
just: <T>(value: T) => Maybe<T>;
|
|
52
|
+
nothing: () => Nothing;
|
|
53
|
+
new: <T>(v: T | null | undefined) => Maybe<T>;
|
|
54
|
+
nothingNull: () => NothingNull;
|
|
55
|
+
nothingUndefined: () => NothingUndefined;
|
|
56
|
+
isSome: <T>(m: Maybe<T>) => m is T;
|
|
57
|
+
isNothing: <T>(m: Maybe<T>) => m is Nothing;
|
|
58
|
+
isNothingNull: <T>(m: Maybe<T>) => m is NothingNull;
|
|
59
|
+
isNothingUndefined: <T>(m: Maybe<T>) => m is NothingUndefined;
|
|
60
|
+
fromNullable: <T>(v: T | null | undefined) => Maybe<T>;
|
|
61
|
+
toNullable: <T>(m: Maybe<T>) => T | null;
|
|
62
|
+
toUndefined: <T>(m: Maybe<T>) => T | undefined;
|
|
63
|
+
map: <T, U>(m: Maybe<T>, fn: (v: T) => U) => Maybe<U>;
|
|
64
|
+
flatMap: <T, U>(m: Maybe<T>, fn: (v: T) => Maybe<U>) => Maybe<U>;
|
|
65
|
+
filter: <T>(m: Maybe<T>, predicate: (value: T) => boolean) => Maybe<T>;
|
|
66
|
+
match: <T, U>(m: Maybe<T>, matcher: {
|
|
67
|
+
some: (v: T) => U;
|
|
68
|
+
nothing: () => U;
|
|
69
|
+
}) => U;
|
|
70
|
+
getOrElse: <T>(m: Maybe<T>, d: T) => T;
|
|
71
|
+
getOrUndefined: <T>(m: Maybe<T>) => T | undefined;
|
|
72
|
+
getOrThrow: <T>(m: Maybe<T>, error: Error) => T;
|
|
73
|
+
fromThrowable: <T>(fn: () => T) => Maybe<T>;
|
|
74
|
+
fromPromise: <T>(promise: Promise<T>) => Promise<Maybe<T>>;
|
|
75
|
+
zip: <T, U>(a: Maybe<T>, b: Maybe<U>) => Maybe<[T, U]>;
|
|
76
|
+
apply: <T, U>(fn: Maybe<(value: T) => U>, opt: Maybe<T>) => Maybe<U>;
|
|
77
|
+
orElse: <T>(opt: Maybe<T>, other: Maybe<T>) => Maybe<T>;
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
type None = {
|
|
81
|
+
readonly $: "None";
|
|
82
|
+
};
|
|
83
|
+
type Some<T> = {
|
|
84
|
+
readonly $: "Some";
|
|
85
|
+
readonly value: T;
|
|
86
|
+
};
|
|
87
|
+
declare const none: <T>() => Option<T>;
|
|
88
|
+
declare const some: <T>(value: T) => Option<T>;
|
|
89
|
+
type Option<T> = None | Some<T>;
|
|
90
|
+
declare const Option: {
|
|
91
|
+
none: <T>() => Option<T>;
|
|
92
|
+
some: <T>(value: T) => Option<T>;
|
|
93
|
+
new: <T>(value: T | null | undefined) => Option<T>;
|
|
94
|
+
isSome: <T>(option: Option<T>) => option is Some<T>;
|
|
95
|
+
isNone: <T>(option: Option<T>) => option is None;
|
|
96
|
+
fromNullable: <T>(value: T | null | undefined) => Option<T>;
|
|
97
|
+
fromPredicate: <T>(value: T, predicate: (value: T) => boolean) => Option<T>;
|
|
98
|
+
fromThrowable: <T>(fn: () => T) => Option<T>;
|
|
99
|
+
fromPromise: <T>(promise: Promise<T>) => Promise<Option<T>>;
|
|
100
|
+
map: <T, U>(option: Option<T>, fn: (value: T) => U) => Option<U>;
|
|
101
|
+
flatMap: <T, U>(option: Option<T>, fn: (value: T) => Option<U>) => Option<U>;
|
|
102
|
+
filter: <T>(option: Option<T>, predicate: (value: T) => boolean) => Option<T>;
|
|
103
|
+
match: <T, U>(option: Option<T>, matcher: {
|
|
104
|
+
some: (value: T) => U;
|
|
105
|
+
none: () => U;
|
|
106
|
+
}) => U;
|
|
107
|
+
getOrElse: <T>(option: Option<T>, defaultValue: T) => T;
|
|
108
|
+
getOrUndefined: <T>(option: Option<T>) => T | undefined;
|
|
109
|
+
getOrThrow: <T>(option: Option<T>, error: Error) => T;
|
|
110
|
+
zip: <T, U>(a: Option<T>, b: Option<U>) => Option<[T, U]>;
|
|
111
|
+
apply: <T, U>(fn: Option<(value: T) => U>, opt: Option<T>) => Option<U>;
|
|
112
|
+
orElse: <T>(opt: Option<T>, other: Option<T>) => Option<T>;
|
|
113
|
+
};
|
|
114
|
+
declare global {
|
|
115
|
+
interface Array<T> {
|
|
116
|
+
firstOption(): Option<T>;
|
|
117
|
+
}
|
|
118
|
+
interface Promise<T> {
|
|
119
|
+
toOption(): Promise<Option<T>>;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
type Pair<A, B> = readonly [A, B];
|
|
124
|
+
declare const Pair: {
|
|
125
|
+
fst: <A, B>(p: Pair<A, B>) => A;
|
|
126
|
+
snd: <A, B>(p: Pair<A, B>) => B;
|
|
127
|
+
new: <A, B>(a: A, b: B) => Pair<A, B>;
|
|
128
|
+
fromArray: <A, B>([a, b]: [A, B]) => Pair<A, B>;
|
|
129
|
+
fromObject: <A, B>(obj: {
|
|
130
|
+
fst: A;
|
|
131
|
+
snd: B;
|
|
132
|
+
}) => Pair<A, B>;
|
|
133
|
+
curry: <A>(a: A) => <B>(b: B) => Pair<A, B>;
|
|
134
|
+
mapFirst: <A, B, C>(p: Pair<A, B>, fn: (a: A) => C) => Pair<C, B>;
|
|
135
|
+
mapSecond: <A, B, C>(p: Pair<A, B>, fn: (b: B) => C) => Pair<A, C>;
|
|
136
|
+
map: <A, B, C, D>(p: Pair<A, B>, fnA: (a: A) => C, fnB: (b: B) => D) => Pair<C, D>;
|
|
137
|
+
swap: <A, B>(p: Pair<A, B>) => Pair<B, A>;
|
|
138
|
+
apply: <A, B, C>(p: Pair<(a: A) => B, C>, value: A) => Pair<B, C>;
|
|
139
|
+
apply2: <A, B, C>(fnPair: Pair<(a: A) => B, (b: B) => C>, vPair: Pair<A, B>) => Pair<A, C>;
|
|
140
|
+
reduce: <A, B, C>(p: Pair<A, B>, fn: (a: A, b: B) => C) => C;
|
|
141
|
+
toArray: <A, B>(p: Pair<A, B>) => [A, B];
|
|
142
|
+
toObject: <A, B>(p: Pair<A, B>) => {
|
|
143
|
+
fst: A;
|
|
144
|
+
snd: B;
|
|
145
|
+
};
|
|
146
|
+
eq: <A, B>(p1: Pair<A, B>, p2: Pair<A, B>) => boolean;
|
|
147
|
+
equals: <A, B>(p1: Pair<A, B>, p2: Pair<A, B>, eqA: (a1: A, a2: A) => boolean, eqB: (b1: B, b2: B) => boolean) => boolean;
|
|
148
|
+
zip: <A, B, C, D>(p1: Pair<A, B>, p2: Pair<C, D>) => Pair<Pair<A, C>, Pair<B, D>>;
|
|
149
|
+
};
|
|
150
|
+
declare const pair: <A, B>(a: A, b: B) => Pair<A, B>;
|
|
151
|
+
|
|
152
|
+
type Done<T> = {
|
|
153
|
+
readonly v: T;
|
|
154
|
+
};
|
|
155
|
+
type Fail<E> = {
|
|
156
|
+
readonly e: E;
|
|
157
|
+
};
|
|
158
|
+
declare const done: <T>(value: T) => Done<T>;
|
|
159
|
+
declare const fail: <E>(error: E) => Fail<E>;
|
|
160
|
+
type Result<T, E> = Done<T> | Fail<E>;
|
|
161
|
+
declare const Result: {
|
|
162
|
+
done: <T>(value: T) => Done<T>;
|
|
163
|
+
fail: <E>(error: E) => Fail<E>;
|
|
164
|
+
OK: <T>(value: T) => Done<T>;
|
|
165
|
+
Err: <E>(error: E) => Fail<E>;
|
|
166
|
+
new: <T, E>(value: T | null | undefined, error: E) => Result<T, E>;
|
|
167
|
+
isDone: <T, E>(r: Result<T, E>) => r is Done<T>;
|
|
168
|
+
isFail: <T, E>(r: Result<T, E>) => r is Fail<E>;
|
|
169
|
+
isOk: <T, E>(r: Result<T, E>) => r is Done<T>;
|
|
170
|
+
isErr: <T, E>(r: Result<T, E>) => r is Fail<E>;
|
|
171
|
+
fromNullable: <T, E>(value: T | null | undefined, error: E) => Result<T, E>;
|
|
172
|
+
fromThrowable: <T, E>(fn: () => T, onError: (e: unknown) => E) => Result<T, E>;
|
|
173
|
+
fromPromise: <T, E>(promise: Promise<T>, onError: (e: unknown) => E) => Promise<Result<T, E>>;
|
|
174
|
+
map: <T, E, U>(r: Result<T, E>, fn: (a: T) => U) => Result<U, E>;
|
|
175
|
+
mapErr: <T, E, F>(r: Result<T, E>, fn: (b: E) => F) => Result<T, F>;
|
|
176
|
+
bimap: <T, E, U, F>(r: Result<T, E>, onDone: (a: T) => U, onFail: (b: E) => F) => Result<U, F>;
|
|
177
|
+
flatMap: <T, E, C>(r: Result<T, E>, fn: (a: T) => Result<C, E>) => Result<C, E>;
|
|
178
|
+
match: <T, E, U>(r: Result<T, E>, matcher: {
|
|
179
|
+
done: (a: T) => U;
|
|
180
|
+
fail: (b: E) => U;
|
|
181
|
+
}) => U;
|
|
182
|
+
fold: <T, E, U>(r: Result<T, E>, onFail: (error: E) => U, onDone: (value: T) => U) => U;
|
|
183
|
+
recover: <T, E>(r: Result<T, E>, fn: (error: E) => T) => Result<T, E>;
|
|
184
|
+
getOrElse: <T, E>(r: Result<T, E>, d: T) => T;
|
|
185
|
+
getOrThrow: <T, E>(r: Result<T, E>, onError: (b: E) => never) => T;
|
|
186
|
+
zip: <T, U, E>(a: Result<T, E>, b: Result<U, E>) => Result<[T, U], E>;
|
|
187
|
+
apply: <T, U, E>(fn: Result<(a: T) => U, E>, arg: Result<T, E>) => Result<U, E>;
|
|
188
|
+
orElse: <T, E>(a: Result<T, E>, b: Result<T, E>) => Result<T, E>;
|
|
189
|
+
filter: <T, E>(r: Result<T, E>, predicate: (a: T) => boolean, onFalse: E) => Result<T, E>;
|
|
190
|
+
tap: <T, E>(r: Result<T, E>, f: (a: T) => void) => Result<T, E>;
|
|
191
|
+
tapErr: <T, E>(r: Result<T, E>, f: (b: E) => void) => Result<T, E>;
|
|
192
|
+
};
|
|
193
|
+
declare global {
|
|
194
|
+
interface Promise<T> {
|
|
195
|
+
toResult<E = unknown>(onError: (e: unknown) => E): Promise<Result<T, E>>;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
export { type Done, Either, type Fail, type Left, Maybe, type None, type Nothing, type NothingNull, type NothingUndefined, Option, Pair, Result, type Right, type Some, done, fail, just, left, none, nothing, pair, right, some };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
type Left<A> = {
|
|
2
|
+
readonly $: "Left";
|
|
3
|
+
readonly value: A;
|
|
4
|
+
};
|
|
5
|
+
type Right<B> = {
|
|
6
|
+
readonly $: "Right";
|
|
7
|
+
readonly value: B;
|
|
8
|
+
};
|
|
9
|
+
declare const left: <A>(value: A) => Left<A>;
|
|
10
|
+
declare const right: <B>(value: B) => Right<B>;
|
|
11
|
+
type Either<A, B> = Left<A> | Right<B>;
|
|
12
|
+
declare const Either: {
|
|
13
|
+
left: <A>(value: A) => Left<A>;
|
|
14
|
+
right: <B>(value: B) => Right<B>;
|
|
15
|
+
new: <A, B>(value: B | null | undefined, error: A) => Either<A, B>;
|
|
16
|
+
isLeft: <A, B>(e: Either<A, B>) => e is Left<A>;
|
|
17
|
+
isRight: <A, B>(e: Either<A, B>) => e is Right<B>;
|
|
18
|
+
fromNullable: <A, B>(value: B | null | undefined, error: A) => Either<A, B>;
|
|
19
|
+
fromThrowable: <A, B>(fn: () => B, onError: (e: unknown) => A) => Either<A, B>;
|
|
20
|
+
fromPromise: <A, B>(promise: Promise<B>, onError: (e: unknown) => A) => Promise<Either<A, B>>;
|
|
21
|
+
map: <A, B, C>(e: Either<A, B>, fn: (r: B) => C) => Either<A, C>;
|
|
22
|
+
mapLeft: <A, B, C>(e: Either<A, B>, fn: (l: A) => C) => Either<C, B>;
|
|
23
|
+
bimap: <A, B, C, D>(e: Either<A, B>, fl: (l: A) => C, fr: (r: B) => D) => Either<C, D>;
|
|
24
|
+
flatMap: <A, B, C>(e: Either<A, B>, fn: (value: B) => Either<A, C>) => Either<A, C>;
|
|
25
|
+
chain: <A, B, C>(e: Either<A, B>, fn: (r: B) => Either<A, C>) => Either<A, C>;
|
|
26
|
+
fold: <A, B, C>(e: Either<A, B>, onLeft: (l: A) => C, onRight: (r: B) => C) => C;
|
|
27
|
+
match: <A, B, C>(e: Either<A, B>, matcher: {
|
|
28
|
+
right: (value: B) => C;
|
|
29
|
+
left: (value: A) => C;
|
|
30
|
+
}) => C;
|
|
31
|
+
swap: <A, B>(e: Either<A, B>) => Either<B, A>;
|
|
32
|
+
getOrElse: <A, B>(e: Either<A, B>, defaultValue: B) => B;
|
|
33
|
+
zip: <E, A, B>(a: Either<E, A>, b: Either<E, B>) => Either<E, [A, B]>;
|
|
34
|
+
apply: <E, A, B>(fn: Either<E, (value: A) => B>, arg: Either<E, A>) => Either<E, B>;
|
|
35
|
+
tap: <A, B>(e: Either<A, B>, f: (r: B) => void) => Either<A, B>;
|
|
36
|
+
tapLeft: <A, B>(e: Either<A, B>, f: (l: A) => void) => Either<A, B>;
|
|
37
|
+
};
|
|
38
|
+
declare global {
|
|
39
|
+
interface Promise<T> {
|
|
40
|
+
toEither<A>(onError: (e: unknown) => A): Promise<Either<A, T>>;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
type NothingNull = null;
|
|
45
|
+
type NothingUndefined = undefined;
|
|
46
|
+
type Nothing = NothingNull | NothingUndefined;
|
|
47
|
+
declare const just: <T>(value: T) => Maybe<T>;
|
|
48
|
+
declare const nothing: () => Nothing;
|
|
49
|
+
type Maybe<T> = T | Nothing;
|
|
50
|
+
declare const Maybe: {
|
|
51
|
+
just: <T>(value: T) => Maybe<T>;
|
|
52
|
+
nothing: () => Nothing;
|
|
53
|
+
new: <T>(v: T | null | undefined) => Maybe<T>;
|
|
54
|
+
nothingNull: () => NothingNull;
|
|
55
|
+
nothingUndefined: () => NothingUndefined;
|
|
56
|
+
isSome: <T>(m: Maybe<T>) => m is T;
|
|
57
|
+
isNothing: <T>(m: Maybe<T>) => m is Nothing;
|
|
58
|
+
isNothingNull: <T>(m: Maybe<T>) => m is NothingNull;
|
|
59
|
+
isNothingUndefined: <T>(m: Maybe<T>) => m is NothingUndefined;
|
|
60
|
+
fromNullable: <T>(v: T | null | undefined) => Maybe<T>;
|
|
61
|
+
toNullable: <T>(m: Maybe<T>) => T | null;
|
|
62
|
+
toUndefined: <T>(m: Maybe<T>) => T | undefined;
|
|
63
|
+
map: <T, U>(m: Maybe<T>, fn: (v: T) => U) => Maybe<U>;
|
|
64
|
+
flatMap: <T, U>(m: Maybe<T>, fn: (v: T) => Maybe<U>) => Maybe<U>;
|
|
65
|
+
filter: <T>(m: Maybe<T>, predicate: (value: T) => boolean) => Maybe<T>;
|
|
66
|
+
match: <T, U>(m: Maybe<T>, matcher: {
|
|
67
|
+
some: (v: T) => U;
|
|
68
|
+
nothing: () => U;
|
|
69
|
+
}) => U;
|
|
70
|
+
getOrElse: <T>(m: Maybe<T>, d: T) => T;
|
|
71
|
+
getOrUndefined: <T>(m: Maybe<T>) => T | undefined;
|
|
72
|
+
getOrThrow: <T>(m: Maybe<T>, error: Error) => T;
|
|
73
|
+
fromThrowable: <T>(fn: () => T) => Maybe<T>;
|
|
74
|
+
fromPromise: <T>(promise: Promise<T>) => Promise<Maybe<T>>;
|
|
75
|
+
zip: <T, U>(a: Maybe<T>, b: Maybe<U>) => Maybe<[T, U]>;
|
|
76
|
+
apply: <T, U>(fn: Maybe<(value: T) => U>, opt: Maybe<T>) => Maybe<U>;
|
|
77
|
+
orElse: <T>(opt: Maybe<T>, other: Maybe<T>) => Maybe<T>;
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
type None = {
|
|
81
|
+
readonly $: "None";
|
|
82
|
+
};
|
|
83
|
+
type Some<T> = {
|
|
84
|
+
readonly $: "Some";
|
|
85
|
+
readonly value: T;
|
|
86
|
+
};
|
|
87
|
+
declare const none: <T>() => Option<T>;
|
|
88
|
+
declare const some: <T>(value: T) => Option<T>;
|
|
89
|
+
type Option<T> = None | Some<T>;
|
|
90
|
+
declare const Option: {
|
|
91
|
+
none: <T>() => Option<T>;
|
|
92
|
+
some: <T>(value: T) => Option<T>;
|
|
93
|
+
new: <T>(value: T | null | undefined) => Option<T>;
|
|
94
|
+
isSome: <T>(option: Option<T>) => option is Some<T>;
|
|
95
|
+
isNone: <T>(option: Option<T>) => option is None;
|
|
96
|
+
fromNullable: <T>(value: T | null | undefined) => Option<T>;
|
|
97
|
+
fromPredicate: <T>(value: T, predicate: (value: T) => boolean) => Option<T>;
|
|
98
|
+
fromThrowable: <T>(fn: () => T) => Option<T>;
|
|
99
|
+
fromPromise: <T>(promise: Promise<T>) => Promise<Option<T>>;
|
|
100
|
+
map: <T, U>(option: Option<T>, fn: (value: T) => U) => Option<U>;
|
|
101
|
+
flatMap: <T, U>(option: Option<T>, fn: (value: T) => Option<U>) => Option<U>;
|
|
102
|
+
filter: <T>(option: Option<T>, predicate: (value: T) => boolean) => Option<T>;
|
|
103
|
+
match: <T, U>(option: Option<T>, matcher: {
|
|
104
|
+
some: (value: T) => U;
|
|
105
|
+
none: () => U;
|
|
106
|
+
}) => U;
|
|
107
|
+
getOrElse: <T>(option: Option<T>, defaultValue: T) => T;
|
|
108
|
+
getOrUndefined: <T>(option: Option<T>) => T | undefined;
|
|
109
|
+
getOrThrow: <T>(option: Option<T>, error: Error) => T;
|
|
110
|
+
zip: <T, U>(a: Option<T>, b: Option<U>) => Option<[T, U]>;
|
|
111
|
+
apply: <T, U>(fn: Option<(value: T) => U>, opt: Option<T>) => Option<U>;
|
|
112
|
+
orElse: <T>(opt: Option<T>, other: Option<T>) => Option<T>;
|
|
113
|
+
};
|
|
114
|
+
declare global {
|
|
115
|
+
interface Array<T> {
|
|
116
|
+
firstOption(): Option<T>;
|
|
117
|
+
}
|
|
118
|
+
interface Promise<T> {
|
|
119
|
+
toOption(): Promise<Option<T>>;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
type Pair<A, B> = readonly [A, B];
|
|
124
|
+
declare const Pair: {
|
|
125
|
+
fst: <A, B>(p: Pair<A, B>) => A;
|
|
126
|
+
snd: <A, B>(p: Pair<A, B>) => B;
|
|
127
|
+
new: <A, B>(a: A, b: B) => Pair<A, B>;
|
|
128
|
+
fromArray: <A, B>([a, b]: [A, B]) => Pair<A, B>;
|
|
129
|
+
fromObject: <A, B>(obj: {
|
|
130
|
+
fst: A;
|
|
131
|
+
snd: B;
|
|
132
|
+
}) => Pair<A, B>;
|
|
133
|
+
curry: <A>(a: A) => <B>(b: B) => Pair<A, B>;
|
|
134
|
+
mapFirst: <A, B, C>(p: Pair<A, B>, fn: (a: A) => C) => Pair<C, B>;
|
|
135
|
+
mapSecond: <A, B, C>(p: Pair<A, B>, fn: (b: B) => C) => Pair<A, C>;
|
|
136
|
+
map: <A, B, C, D>(p: Pair<A, B>, fnA: (a: A) => C, fnB: (b: B) => D) => Pair<C, D>;
|
|
137
|
+
swap: <A, B>(p: Pair<A, B>) => Pair<B, A>;
|
|
138
|
+
apply: <A, B, C>(p: Pair<(a: A) => B, C>, value: A) => Pair<B, C>;
|
|
139
|
+
apply2: <A, B, C>(fnPair: Pair<(a: A) => B, (b: B) => C>, vPair: Pair<A, B>) => Pair<A, C>;
|
|
140
|
+
reduce: <A, B, C>(p: Pair<A, B>, fn: (a: A, b: B) => C) => C;
|
|
141
|
+
toArray: <A, B>(p: Pair<A, B>) => [A, B];
|
|
142
|
+
toObject: <A, B>(p: Pair<A, B>) => {
|
|
143
|
+
fst: A;
|
|
144
|
+
snd: B;
|
|
145
|
+
};
|
|
146
|
+
eq: <A, B>(p1: Pair<A, B>, p2: Pair<A, B>) => boolean;
|
|
147
|
+
equals: <A, B>(p1: Pair<A, B>, p2: Pair<A, B>, eqA: (a1: A, a2: A) => boolean, eqB: (b1: B, b2: B) => boolean) => boolean;
|
|
148
|
+
zip: <A, B, C, D>(p1: Pair<A, B>, p2: Pair<C, D>) => Pair<Pair<A, C>, Pair<B, D>>;
|
|
149
|
+
};
|
|
150
|
+
declare const pair: <A, B>(a: A, b: B) => Pair<A, B>;
|
|
151
|
+
|
|
152
|
+
type Done<T> = {
|
|
153
|
+
readonly v: T;
|
|
154
|
+
};
|
|
155
|
+
type Fail<E> = {
|
|
156
|
+
readonly e: E;
|
|
157
|
+
};
|
|
158
|
+
declare const done: <T>(value: T) => Done<T>;
|
|
159
|
+
declare const fail: <E>(error: E) => Fail<E>;
|
|
160
|
+
type Result<T, E> = Done<T> | Fail<E>;
|
|
161
|
+
declare const Result: {
|
|
162
|
+
done: <T>(value: T) => Done<T>;
|
|
163
|
+
fail: <E>(error: E) => Fail<E>;
|
|
164
|
+
OK: <T>(value: T) => Done<T>;
|
|
165
|
+
Err: <E>(error: E) => Fail<E>;
|
|
166
|
+
new: <T, E>(value: T | null | undefined, error: E) => Result<T, E>;
|
|
167
|
+
isDone: <T, E>(r: Result<T, E>) => r is Done<T>;
|
|
168
|
+
isFail: <T, E>(r: Result<T, E>) => r is Fail<E>;
|
|
169
|
+
isOk: <T, E>(r: Result<T, E>) => r is Done<T>;
|
|
170
|
+
isErr: <T, E>(r: Result<T, E>) => r is Fail<E>;
|
|
171
|
+
fromNullable: <T, E>(value: T | null | undefined, error: E) => Result<T, E>;
|
|
172
|
+
fromThrowable: <T, E>(fn: () => T, onError: (e: unknown) => E) => Result<T, E>;
|
|
173
|
+
fromPromise: <T, E>(promise: Promise<T>, onError: (e: unknown) => E) => Promise<Result<T, E>>;
|
|
174
|
+
map: <T, E, U>(r: Result<T, E>, fn: (a: T) => U) => Result<U, E>;
|
|
175
|
+
mapErr: <T, E, F>(r: Result<T, E>, fn: (b: E) => F) => Result<T, F>;
|
|
176
|
+
bimap: <T, E, U, F>(r: Result<T, E>, onDone: (a: T) => U, onFail: (b: E) => F) => Result<U, F>;
|
|
177
|
+
flatMap: <T, E, C>(r: Result<T, E>, fn: (a: T) => Result<C, E>) => Result<C, E>;
|
|
178
|
+
match: <T, E, U>(r: Result<T, E>, matcher: {
|
|
179
|
+
done: (a: T) => U;
|
|
180
|
+
fail: (b: E) => U;
|
|
181
|
+
}) => U;
|
|
182
|
+
fold: <T, E, U>(r: Result<T, E>, onFail: (error: E) => U, onDone: (value: T) => U) => U;
|
|
183
|
+
recover: <T, E>(r: Result<T, E>, fn: (error: E) => T) => Result<T, E>;
|
|
184
|
+
getOrElse: <T, E>(r: Result<T, E>, d: T) => T;
|
|
185
|
+
getOrThrow: <T, E>(r: Result<T, E>, onError: (b: E) => never) => T;
|
|
186
|
+
zip: <T, U, E>(a: Result<T, E>, b: Result<U, E>) => Result<[T, U], E>;
|
|
187
|
+
apply: <T, U, E>(fn: Result<(a: T) => U, E>, arg: Result<T, E>) => Result<U, E>;
|
|
188
|
+
orElse: <T, E>(a: Result<T, E>, b: Result<T, E>) => Result<T, E>;
|
|
189
|
+
filter: <T, E>(r: Result<T, E>, predicate: (a: T) => boolean, onFalse: E) => Result<T, E>;
|
|
190
|
+
tap: <T, E>(r: Result<T, E>, f: (a: T) => void) => Result<T, E>;
|
|
191
|
+
tapErr: <T, E>(r: Result<T, E>, f: (b: E) => void) => Result<T, E>;
|
|
192
|
+
};
|
|
193
|
+
declare global {
|
|
194
|
+
interface Promise<T> {
|
|
195
|
+
toResult<E = unknown>(onError: (e: unknown) => E): Promise<Result<T, E>>;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
export { type Done, Either, type Fail, type Left, Maybe, type None, type Nothing, type NothingNull, type NothingUndefined, Option, Pair, Result, type Right, type Some, done, fail, just, left, none, nothing, pair, right, some };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var h=(e,t,o)=>new Promise((x,f)=>{var O=E=>{try{A(o.next(E))}catch(B){f(B)}},g=E=>{try{A(o.throw(E))}catch(B){f(B)}},A=E=>E.done?x(E.value):Promise.resolve(E.value).then(O,g);A((o=o.apply(e,t)).next())});var T=e=>({$:"Left",value:e}),i= exports.right =e=>({$:"Right",value:e}),C=e=>e.$==="Left",M=e=>e.$==="Right",y=(e,t)=>e==null?T(t):i(e),$=(e,t)=>{try{return i(e())}catch(o){return T(t(o))}},N=(e,t)=>h(null,null,function*(){try{let o=yield e;return i(o)}catch(o){return T(t(o))}}),w=(e,t)=>e.$==="Right"?i(t(e.value)):e,L=(e,t)=>e.$==="Left"?T(t(e.value)):e,S=(e,t,o)=>e.$==="Left"?T(t(e.value)):i(o(e.value)),D=(e,t)=>e.$==="Right"?t(e.value):e,k=(e,t)=>e.$==="Right"?t(e.value):e,F=(e,t,o)=>e.$==="Left"?t(e.value):o(e.value),z=(e,t)=>e.$==="Right"?t.right(e.value):t.left(e.value),j=e=>e.$==="Right"?T(e.value):i(e.value),q=(e,t)=>e.$==="Right"?e.value:t,K=(e,t)=>e.$==="Left"?e:t.$==="Left"?t:i([e.value,t.value]),_=(e,t)=>e.$==="Left"?e:t.$==="Left"?t:i(e.value(t.value)),G=(e,t)=>(e.$==="Right"&&t(e.value),e),H=(e,t)=>(e.$==="Left"&&t(e.value),e),I= exports.Either ={left:T,right:i,new:y,isLeft:C,isRight:M,fromNullable:y,fromThrowable:$,fromPromise:N,map:w,mapLeft:L,bimap:S,flatMap:D,chain:k,fold:F,match:z,swap:j,getOrElse:q,zip:K,apply:_,tap:G,tapLeft:H};Promise.prototype.toEither=function(e){return h(this,null,function*(){try{let t=yield this;return i(t)}catch(t){return T(e(t))}})};var d=e=>e,a= exports.nothing =()=>{},J=()=>null,v=()=>{},Q=e=>e!=null,V=e=>e==null,W=e=>e===null,X=e=>e===void 0,m=e=>e,Y=e=>e==null?null:e,Z=e=>e==null?void 0:e,ee=e=>{try{return e()}catch(t){return a()}},te=e=>e.then(t=>t,()=>a());var oe=(e,t)=>e==null?a():t(e),re=(e,t)=>e==null?a():t(e),ne=(e,t)=>e!=null&&t(e)?e:a(),ie=(e,t)=>e==null?t.nothing():t.some(e),se=(e,t)=>e==null?t:e,le=e=>e==null?v():e,Te=(e,t)=>{if(e!=null)return e;throw t},ae=(e,t)=>e!=null&&t!=null?[e,t]:a(),pe=(e,t)=>e!=null&&t!=null?e(t):a(),ue=(e,t)=>e!=null?e:t,ce= exports.Maybe ={just:d,nothing:a,new:m,nothingNull:J,nothingUndefined:v,isSome:Q,isNothing:V,isNothingNull:W,isNothingUndefined:X,fromNullable:m,toNullable:Y,toUndefined:Z,map:oe,flatMap:re,filter:ne,match:ie,getOrElse:se,getOrUndefined:le,getOrThrow:Te,fromThrowable:ee,fromPromise:te,zip:ae,apply:pe,orElse:ue};var r=()=>({$:"None"}),l= exports.some =e=>({$:"Some",value:e}),Ee=e=>e.$==="Some",xe=e=>e.$==="None",b=e=>e==null?r():l(e),Ae=(e,t)=>t(e)?l(e):r(),Be=e=>{try{return l(e())}catch(t){return r()}},U=e=>e.then(l,()=>r()),he=(e,t)=>e.$==="Some"?l(t(e.value)):r(),fe=(e,t)=>e.$==="Some"?t(e.value):r(),ye=(e,t)=>e.$==="Some"&&t(e.value)?e:r(),me=(e,t)=>e.$==="Some"?t.some(e.value):t.none(),de=(e,t)=>e.$==="Some"?e.value:t,ve=e=>e.$==="Some"?e.value:void 0,be=(e,t)=>{if(e.$==="Some")return e.value;throw t},Ue=(e,t)=>e.$==="Some"&&t.$==="Some"?l([e.value,t.value]):r(),Pe=(e,t)=>e.$==="Some"&&t.$==="Some"?l(e.value(t.value)):r(),Re=(e,t)=>e.$==="Some"?e:t,Oe= exports.Option ={none:r,some:l,new:b,isSome:Ee,isNone:xe,fromNullable:b,fromPredicate:Ae,fromThrowable:Be,fromPromise:U,map:he,flatMap:fe,filter:ye,match:me,getOrElse:de,getOrUndefined:ve,getOrThrow:be,zip:Ue,apply:Pe,orElse:Re};Array.prototype.firstOption=function(){return this[0]?l(this[0]):r()};Promise.prototype.toOption=function(){return U(this)};var ge=e=>e[0],Ce=e=>e[1],p=(e,t)=>[e,t],Me=([e,t])=>[e,t],$e=e=>[e.fst,e.snd],Ne=e=>t=>[e,t],we=(e,t)=>p(t(e[0]),e[1]),Le=(e,t)=>p(e[0],t(e[1])),Se=(e,t,o)=>p(t(e[0]),o(e[1])),De=e=>p(e[1],e[0]),ke=(e,t)=>p(e[0](t),e[1]),Fe=(e,t)=>p(t[0],e[1](t[1])),ze=(e,t)=>t(e[0],e[1]),je=e=>[e[0],e[1]],qe=e=>({fst:e[0],snd:e[1]}),Ke=(e,t)=>e[0]===t[0]&&e[1]===t[1],_e=(e,t,o,x)=>o(e[0],t[0])&&x(e[1],t[1]),Ge=(e,t)=>p([e[0],t[0]],[e[1],t[1]]),He= exports.Pair ={fst:ge,snd:Ce,new:p,fromArray:Me,fromObject:$e,curry:Ne,mapFirst:we,mapSecond:Le,map:Se,swap:De,apply:ke,apply2:Fe,reduce:ze,toArray:je,toObject:qe,eq:Ke,equals:_e,zip:Ge},Ie= exports.pair =p;var s=e=>({v:e}),u= exports.fail =e=>({e}),n=e=>"value"in e,c=e=>"error"in e,P=(e,t)=>e==null?u(t):s(e),Je=(e,t)=>{try{return s(e())}catch(o){return u(t(o))}},R=(e,t)=>e.then(s,o=>u(t(o))),Qe=(e,t)=>n(e)?s(t(e.v)):e,Ve=(e,t)=>c(e)?u(t(e.e)):e,We=(e,t,o)=>n(e)?s(t(e.v)):u(o(e.e)),Xe=(e,t)=>n(e)?t(e.v):e,Ye=(e,t)=>n(e)?t.done(e.v):t.fail(e.e),Ze=(e,t,o)=>n(e)?o(e.v):t(e.e),et=(e,t)=>c(e)?s(t(e.e)):e,tt=(e,t)=>n(e)?e.v:t;var ot=(e,t)=>n(e)?e.v:t(e.e),rt=(e,t)=>c(e)?e:c(t)?t:s([e.v,t.v]),nt=(e,t)=>c(e)?e:c(t)?t:s(e.v(t.v)),it=(e,t)=>n(e)?e:t,st=(e,t,o)=>n(e)?t(e.v)?e:u(o):e,lt=(e,t)=>(n(e)&&t(e.v),e),Tt=(e,t)=>(c(e)&&t(e.e),e),at= exports.Result ={done:s,fail:u,OK:s,Err:u,new:P,isDone:n,isFail:c,isOk:n,isErr:c,fromNullable:P,fromThrowable:Je,fromPromise:R,map:Qe,mapErr:Ve,bimap:We,flatMap:Xe,match:Ye,fold:Ze,recover:et,getOrElse:tt,getOrThrow:ot,zip:rt,apply:nt,orElse:it,filter:st,tap:lt,tapErr:Tt};Promise.prototype.toResult=function(e){return R(this,e)};exports.Either = I; exports.Maybe = ce; exports.Option = Oe; exports.Pair = He; exports.Result = at; exports.done = s; exports.fail = u; exports.just = d; exports.left = T; exports.none = r; exports.nothing = a; exports.pair = Ie; exports.right = i; exports.some = l;
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var h=(e,t,o)=>new Promise((x,f)=>{var O=E=>{try{A(o.next(E))}catch(B){f(B)}},g=E=>{try{A(o.throw(E))}catch(B){f(B)}},A=E=>E.done?x(E.value):Promise.resolve(E.value).then(O,g);A((o=o.apply(e,t)).next())});var T=e=>({$:"Left",value:e}),i=e=>({$:"Right",value:e}),C=e=>e.$==="Left",M=e=>e.$==="Right",y=(e,t)=>e==null?T(t):i(e),$=(e,t)=>{try{return i(e())}catch(o){return T(t(o))}},N=(e,t)=>h(null,null,function*(){try{let o=yield e;return i(o)}catch(o){return T(t(o))}}),w=(e,t)=>e.$==="Right"?i(t(e.value)):e,L=(e,t)=>e.$==="Left"?T(t(e.value)):e,S=(e,t,o)=>e.$==="Left"?T(t(e.value)):i(o(e.value)),D=(e,t)=>e.$==="Right"?t(e.value):e,k=(e,t)=>e.$==="Right"?t(e.value):e,F=(e,t,o)=>e.$==="Left"?t(e.value):o(e.value),z=(e,t)=>e.$==="Right"?t.right(e.value):t.left(e.value),j=e=>e.$==="Right"?T(e.value):i(e.value),q=(e,t)=>e.$==="Right"?e.value:t,K=(e,t)=>e.$==="Left"?e:t.$==="Left"?t:i([e.value,t.value]),_=(e,t)=>e.$==="Left"?e:t.$==="Left"?t:i(e.value(t.value)),G=(e,t)=>(e.$==="Right"&&t(e.value),e),H=(e,t)=>(e.$==="Left"&&t(e.value),e),I={left:T,right:i,new:y,isLeft:C,isRight:M,fromNullable:y,fromThrowable:$,fromPromise:N,map:w,mapLeft:L,bimap:S,flatMap:D,chain:k,fold:F,match:z,swap:j,getOrElse:q,zip:K,apply:_,tap:G,tapLeft:H};Promise.prototype.toEither=function(e){return h(this,null,function*(){try{let t=yield this;return i(t)}catch(t){return T(e(t))}})};var d=e=>e,a=()=>{},J=()=>null,v=()=>{},Q=e=>e!=null,V=e=>e==null,W=e=>e===null,X=e=>e===void 0,m=e=>e,Y=e=>e==null?null:e,Z=e=>e==null?void 0:e,ee=e=>{try{return e()}catch(t){return a()}},te=e=>e.then(t=>t,()=>a());var oe=(e,t)=>e==null?a():t(e),re=(e,t)=>e==null?a():t(e),ne=(e,t)=>e!=null&&t(e)?e:a(),ie=(e,t)=>e==null?t.nothing():t.some(e),se=(e,t)=>e==null?t:e,le=e=>e==null?v():e,Te=(e,t)=>{if(e!=null)return e;throw t},ae=(e,t)=>e!=null&&t!=null?[e,t]:a(),pe=(e,t)=>e!=null&&t!=null?e(t):a(),ue=(e,t)=>e!=null?e:t,ce={just:d,nothing:a,new:m,nothingNull:J,nothingUndefined:v,isSome:Q,isNothing:V,isNothingNull:W,isNothingUndefined:X,fromNullable:m,toNullable:Y,toUndefined:Z,map:oe,flatMap:re,filter:ne,match:ie,getOrElse:se,getOrUndefined:le,getOrThrow:Te,fromThrowable:ee,fromPromise:te,zip:ae,apply:pe,orElse:ue};var r=()=>({$:"None"}),l=e=>({$:"Some",value:e}),Ee=e=>e.$==="Some",xe=e=>e.$==="None",b=e=>e==null?r():l(e),Ae=(e,t)=>t(e)?l(e):r(),Be=e=>{try{return l(e())}catch(t){return r()}},U=e=>e.then(l,()=>r()),he=(e,t)=>e.$==="Some"?l(t(e.value)):r(),fe=(e,t)=>e.$==="Some"?t(e.value):r(),ye=(e,t)=>e.$==="Some"&&t(e.value)?e:r(),me=(e,t)=>e.$==="Some"?t.some(e.value):t.none(),de=(e,t)=>e.$==="Some"?e.value:t,ve=e=>e.$==="Some"?e.value:void 0,be=(e,t)=>{if(e.$==="Some")return e.value;throw t},Ue=(e,t)=>e.$==="Some"&&t.$==="Some"?l([e.value,t.value]):r(),Pe=(e,t)=>e.$==="Some"&&t.$==="Some"?l(e.value(t.value)):r(),Re=(e,t)=>e.$==="Some"?e:t,Oe={none:r,some:l,new:b,isSome:Ee,isNone:xe,fromNullable:b,fromPredicate:Ae,fromThrowable:Be,fromPromise:U,map:he,flatMap:fe,filter:ye,match:me,getOrElse:de,getOrUndefined:ve,getOrThrow:be,zip:Ue,apply:Pe,orElse:Re};Array.prototype.firstOption=function(){return this[0]?l(this[0]):r()};Promise.prototype.toOption=function(){return U(this)};var ge=e=>e[0],Ce=e=>e[1],p=(e,t)=>[e,t],Me=([e,t])=>[e,t],$e=e=>[e.fst,e.snd],Ne=e=>t=>[e,t],we=(e,t)=>p(t(e[0]),e[1]),Le=(e,t)=>p(e[0],t(e[1])),Se=(e,t,o)=>p(t(e[0]),o(e[1])),De=e=>p(e[1],e[0]),ke=(e,t)=>p(e[0](t),e[1]),Fe=(e,t)=>p(t[0],e[1](t[1])),ze=(e,t)=>t(e[0],e[1]),je=e=>[e[0],e[1]],qe=e=>({fst:e[0],snd:e[1]}),Ke=(e,t)=>e[0]===t[0]&&e[1]===t[1],_e=(e,t,o,x)=>o(e[0],t[0])&&x(e[1],t[1]),Ge=(e,t)=>p([e[0],t[0]],[e[1],t[1]]),He={fst:ge,snd:Ce,new:p,fromArray:Me,fromObject:$e,curry:Ne,mapFirst:we,mapSecond:Le,map:Se,swap:De,apply:ke,apply2:Fe,reduce:ze,toArray:je,toObject:qe,eq:Ke,equals:_e,zip:Ge},Ie=p;var s=e=>({v:e}),u=e=>({e}),n=e=>"value"in e,c=e=>"error"in e,P=(e,t)=>e==null?u(t):s(e),Je=(e,t)=>{try{return s(e())}catch(o){return u(t(o))}},R=(e,t)=>e.then(s,o=>u(t(o))),Qe=(e,t)=>n(e)?s(t(e.v)):e,Ve=(e,t)=>c(e)?u(t(e.e)):e,We=(e,t,o)=>n(e)?s(t(e.v)):u(o(e.e)),Xe=(e,t)=>n(e)?t(e.v):e,Ye=(e,t)=>n(e)?t.done(e.v):t.fail(e.e),Ze=(e,t,o)=>n(e)?o(e.v):t(e.e),et=(e,t)=>c(e)?s(t(e.e)):e,tt=(e,t)=>n(e)?e.v:t;var ot=(e,t)=>n(e)?e.v:t(e.e),rt=(e,t)=>c(e)?e:c(t)?t:s([e.v,t.v]),nt=(e,t)=>c(e)?e:c(t)?t:s(e.v(t.v)),it=(e,t)=>n(e)?e:t,st=(e,t,o)=>n(e)?t(e.v)?e:u(o):e,lt=(e,t)=>(n(e)&&t(e.v),e),Tt=(e,t)=>(c(e)&&t(e.e),e),at={done:s,fail:u,OK:s,Err:u,new:P,isDone:n,isFail:c,isOk:n,isErr:c,fromNullable:P,fromThrowable:Je,fromPromise:R,map:Qe,mapErr:Ve,bimap:We,flatMap:Xe,match:Ye,fold:Ze,recover:et,getOrElse:tt,getOrThrow:ot,zip:rt,apply:nt,orElse:it,filter:st,tap:lt,tapErr:Tt};Promise.prototype.toResult=function(e){return R(this,e)};export{I as Either,ce as Maybe,Oe as Option,He as Pair,at as Result,s as done,u as fail,d as just,T as left,r as none,a as nothing,Ie as pair,i as right,l as some};
|