lite-fp 0.4.1 → 0.5.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 +44 -16
- package/dist/index.d.ts +44 -16
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -8,6 +8,10 @@ type Right<B> = {
|
|
|
8
8
|
};
|
|
9
9
|
declare const left: <A>(value: A) => Left<A>;
|
|
10
10
|
declare const right: <B>(value: B) => Right<B>;
|
|
11
|
+
declare const isLeft: <A, B>(e: Either<A, B>) => e is Left<A>;
|
|
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;
|
|
11
15
|
type Either<A, B> = Left<A> | Right<B>;
|
|
12
16
|
declare const Either: {
|
|
13
17
|
left: <A>(value: A) => Left<A>;
|
|
@@ -29,7 +33,11 @@ declare const Either: {
|
|
|
29
33
|
left: (value: A) => C;
|
|
30
34
|
}) => C;
|
|
31
35
|
swap: <A, B>(e: Either<A, B>) => Either<B, A>;
|
|
36
|
+
getLeft: <A>(e: Left<A>) => A;
|
|
37
|
+
getRight: <B>(e: Right<B>) => B;
|
|
32
38
|
getOrElse: <A, B>(e: Either<A, B>, defaultValue: B) => B;
|
|
39
|
+
getOrUndefined: <A, B>(e: Either<A, B>) => B | undefined;
|
|
40
|
+
getOrThrow: <A, B>(e: Either<A, B>) => B;
|
|
33
41
|
zip: <E, A, B>(a: Either<E, A>, b: Either<E, B>) => Either<E, [A, B]>;
|
|
34
42
|
apply: <E, A, B>(fn: Either<E, (value: A) => B>, arg: Either<E, A>) => Either<E, B>;
|
|
35
43
|
tap: <A, B>(e: Either<A, B>, f: (r: B) => void) => Either<A, B>;
|
|
@@ -46,18 +54,22 @@ type NothingUndefined = undefined;
|
|
|
46
54
|
type Nothing = NothingNull | NothingUndefined;
|
|
47
55
|
declare const just: <T>(value: T) => Maybe<T>;
|
|
48
56
|
declare const nothing: () => Nothing;
|
|
57
|
+
declare const isJust: <T>(m: Maybe<T>) => m is T;
|
|
58
|
+
declare const isNothing: <T>(m: Maybe<T>) => m is Nothing;
|
|
49
59
|
type Maybe<T> = T | Nothing;
|
|
50
60
|
declare const Maybe: {
|
|
51
61
|
just: <T>(value: T) => Maybe<T>;
|
|
52
62
|
nothing: () => Nothing;
|
|
53
|
-
new: <T>(
|
|
63
|
+
new: <T>(m: T | null | undefined) => Maybe<T>;
|
|
54
64
|
nothingNull: () => NothingNull;
|
|
55
65
|
nothingUndefined: () => NothingUndefined;
|
|
56
|
-
|
|
66
|
+
isJust: <T>(m: Maybe<T>) => m is T;
|
|
57
67
|
isNothing: <T>(m: Maybe<T>) => m is Nothing;
|
|
58
68
|
isNothingNull: <T>(m: Maybe<T>) => m is NothingNull;
|
|
59
69
|
isNothingUndefined: <T>(m: Maybe<T>) => m is NothingUndefined;
|
|
60
|
-
fromNullable: <T>(
|
|
70
|
+
fromNullable: <T>(m: T | null | undefined) => Maybe<T>;
|
|
71
|
+
fromThrowable: <T>(fn: () => T) => Maybe<T>;
|
|
72
|
+
fromPromise: <T>(promise: Promise<T>) => Promise<Maybe<T>>;
|
|
61
73
|
toNullable: <T>(m: Maybe<T>) => T | null;
|
|
62
74
|
toUndefined: <T>(m: Maybe<T>) => T | undefined;
|
|
63
75
|
map: <T, U>(m: Maybe<T>, fn: (v: T) => U) => Maybe<U>;
|
|
@@ -67,11 +79,10 @@ declare const Maybe: {
|
|
|
67
79
|
some: (v: T) => U;
|
|
68
80
|
nothing: () => U;
|
|
69
81
|
}) => U;
|
|
82
|
+
fold: <T, U>(m: Maybe<T>, onNothing: () => U, onJust: (v: T) => U) => U;
|
|
70
83
|
getOrElse: <T>(m: Maybe<T>, d: T) => T;
|
|
71
84
|
getOrUndefined: <T>(m: Maybe<T>) => T | undefined;
|
|
72
|
-
getOrThrow: <T>(m: Maybe<T
|
|
73
|
-
fromThrowable: <T>(fn: () => T) => Maybe<T>;
|
|
74
|
-
fromPromise: <T>(promise: Promise<T>) => Promise<Maybe<T>>;
|
|
85
|
+
getOrThrow: <T>(m: Maybe<T>) => T;
|
|
75
86
|
zip: <T, U>(a: Maybe<T>, b: Maybe<U>) => Maybe<[T, U]>;
|
|
76
87
|
apply: <T, U>(fn: Maybe<(value: T) => U>, opt: Maybe<T>) => Maybe<U>;
|
|
77
88
|
orElse: <T>(opt: Maybe<T>, other: Maybe<T>) => Maybe<T>;
|
|
@@ -86,6 +97,9 @@ type Some<T> = {
|
|
|
86
97
|
};
|
|
87
98
|
declare const none: <T>() => Option<T>;
|
|
88
99
|
declare const some: <T>(value: T) => Option<T>;
|
|
100
|
+
declare const isSome: <T>(option: Option<T>) => option is Some<T>;
|
|
101
|
+
declare const isNone: <T>(option: Option<T>) => option is None;
|
|
102
|
+
declare const unwrap: <T>(option: Some<T>) => T;
|
|
89
103
|
type Option<T> = None | Some<T>;
|
|
90
104
|
declare const Option: {
|
|
91
105
|
none: <T>() => Option<T>;
|
|
@@ -104,9 +118,10 @@ declare const Option: {
|
|
|
104
118
|
some: (value: T) => U;
|
|
105
119
|
none: () => U;
|
|
106
120
|
}) => U;
|
|
121
|
+
unwrap: <T>(option: Some<T>) => T;
|
|
107
122
|
getOrElse: <T>(option: Option<T>, defaultValue: T) => T;
|
|
108
123
|
getOrUndefined: <T>(option: Option<T>) => T | undefined;
|
|
109
|
-
getOrThrow: <T>(option: Option<T
|
|
124
|
+
getOrThrow: <T>(option: Option<T>) => T;
|
|
110
125
|
zip: <T, U>(a: Option<T>, b: Option<U>) => Option<[T, U]>;
|
|
111
126
|
apply: <T, U>(fn: Option<(value: T) => U>, opt: Option<T>) => Option<U>;
|
|
112
127
|
orElse: <T>(opt: Option<T>, other: Option<T>) => Option<T>;
|
|
@@ -120,6 +135,9 @@ declare global {
|
|
|
120
135
|
}
|
|
121
136
|
}
|
|
122
137
|
|
|
138
|
+
declare const fst: <A, B>(p: Pair<A, B>) => A;
|
|
139
|
+
declare const snd: <A, B>(p: Pair<A, B>) => B;
|
|
140
|
+
declare const pair: <A, B>(a: A, b: B) => Pair<A, B>;
|
|
123
141
|
type Pair<A, B> = readonly [A, B];
|
|
124
142
|
declare const Pair: {
|
|
125
143
|
fst: <A, B>(p: Pair<A, B>) => A;
|
|
@@ -147,7 +165,6 @@ declare const Pair: {
|
|
|
147
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;
|
|
148
166
|
zip: <A, B, C, D>(p1: Pair<A, B>, p2: Pair<C, D>) => Pair<Pair<A, C>, Pair<B, D>>;
|
|
149
167
|
};
|
|
150
|
-
declare const pair: <A, B>(a: A, b: B) => Pair<A, B>;
|
|
151
168
|
|
|
152
169
|
type Done<T> = {
|
|
153
170
|
readonly v: T;
|
|
@@ -155,14 +172,24 @@ type Done<T> = {
|
|
|
155
172
|
type Fail<E> = {
|
|
156
173
|
readonly e: E;
|
|
157
174
|
};
|
|
158
|
-
declare const done: <T>(
|
|
159
|
-
declare const fail: <E>(
|
|
175
|
+
declare const done: <T>(v: T) => Done<T>;
|
|
176
|
+
declare const fail: <E>(e: E) => Fail<E>;
|
|
177
|
+
declare const Ok: <T>(v: T) => Done<T>;
|
|
178
|
+
declare const Err: <E>(e: E) => Fail<E>;
|
|
179
|
+
declare const isDone: <T, E>(r: Result<T, E>) => r is Done<T>;
|
|
180
|
+
declare const isFail: <T, E>(r: Result<T, E>) => r is Fail<E>;
|
|
181
|
+
declare const isOk: <T, E>(r: Result<T, E>) => r is Done<T>;
|
|
182
|
+
declare const isErr: <T, E>(r: Result<T, E>) => r is Fail<E>;
|
|
183
|
+
declare const val: <T>(r: Done<T>) => T;
|
|
184
|
+
declare const err: <E>(r: Fail<E>) => E;
|
|
160
185
|
type Result<T, E> = Done<T> | Fail<E>;
|
|
161
186
|
declare const Result: {
|
|
162
|
-
done: <T>(
|
|
163
|
-
fail: <E>(
|
|
164
|
-
|
|
165
|
-
Err: <E>(
|
|
187
|
+
done: <T>(v: T) => Done<T>;
|
|
188
|
+
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;
|
|
166
193
|
new: <T, E>(value: T | null | undefined, error: E) => Result<T, E>;
|
|
167
194
|
isDone: <T, E>(r: Result<T, E>) => r is Done<T>;
|
|
168
195
|
isFail: <T, E>(r: Result<T, E>) => r is Fail<E>;
|
|
@@ -182,7 +209,8 @@ declare const Result: {
|
|
|
182
209
|
fold: <T, E, U>(r: Result<T, E>, onFail: (error: E) => U, onDone: (value: T) => U) => U;
|
|
183
210
|
recover: <T, E>(r: Result<T, E>, fn: (error: E) => T) => Result<T, E>;
|
|
184
211
|
getOrElse: <T, E>(r: Result<T, E>, d: T) => T;
|
|
185
|
-
|
|
212
|
+
getOrUndefined: <T, E>(r: Result<T, E>) => T | undefined;
|
|
213
|
+
getOrThrow: <T, E>(r: Result<T, E>) => T;
|
|
186
214
|
zip: <T, U, E>(a: Result<T, E>, b: Result<U, E>) => Result<[T, U], E>;
|
|
187
215
|
apply: <T, U, E>(fn: Result<(a: T) => U, E>, arg: Result<T, E>) => Result<U, E>;
|
|
188
216
|
orElse: <T, E>(a: Result<T, E>, b: Result<T, E>) => Result<T, E>;
|
|
@@ -196,4 +224,4 @@ declare global {
|
|
|
196
224
|
}
|
|
197
225
|
}
|
|
198
226
|
|
|
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 };
|
|
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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -8,6 +8,10 @@ type Right<B> = {
|
|
|
8
8
|
};
|
|
9
9
|
declare const left: <A>(value: A) => Left<A>;
|
|
10
10
|
declare const right: <B>(value: B) => Right<B>;
|
|
11
|
+
declare const isLeft: <A, B>(e: Either<A, B>) => e is Left<A>;
|
|
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;
|
|
11
15
|
type Either<A, B> = Left<A> | Right<B>;
|
|
12
16
|
declare const Either: {
|
|
13
17
|
left: <A>(value: A) => Left<A>;
|
|
@@ -29,7 +33,11 @@ declare const Either: {
|
|
|
29
33
|
left: (value: A) => C;
|
|
30
34
|
}) => C;
|
|
31
35
|
swap: <A, B>(e: Either<A, B>) => Either<B, A>;
|
|
36
|
+
getLeft: <A>(e: Left<A>) => A;
|
|
37
|
+
getRight: <B>(e: Right<B>) => B;
|
|
32
38
|
getOrElse: <A, B>(e: Either<A, B>, defaultValue: B) => B;
|
|
39
|
+
getOrUndefined: <A, B>(e: Either<A, B>) => B | undefined;
|
|
40
|
+
getOrThrow: <A, B>(e: Either<A, B>) => B;
|
|
33
41
|
zip: <E, A, B>(a: Either<E, A>, b: Either<E, B>) => Either<E, [A, B]>;
|
|
34
42
|
apply: <E, A, B>(fn: Either<E, (value: A) => B>, arg: Either<E, A>) => Either<E, B>;
|
|
35
43
|
tap: <A, B>(e: Either<A, B>, f: (r: B) => void) => Either<A, B>;
|
|
@@ -46,18 +54,22 @@ type NothingUndefined = undefined;
|
|
|
46
54
|
type Nothing = NothingNull | NothingUndefined;
|
|
47
55
|
declare const just: <T>(value: T) => Maybe<T>;
|
|
48
56
|
declare const nothing: () => Nothing;
|
|
57
|
+
declare const isJust: <T>(m: Maybe<T>) => m is T;
|
|
58
|
+
declare const isNothing: <T>(m: Maybe<T>) => m is Nothing;
|
|
49
59
|
type Maybe<T> = T | Nothing;
|
|
50
60
|
declare const Maybe: {
|
|
51
61
|
just: <T>(value: T) => Maybe<T>;
|
|
52
62
|
nothing: () => Nothing;
|
|
53
|
-
new: <T>(
|
|
63
|
+
new: <T>(m: T | null | undefined) => Maybe<T>;
|
|
54
64
|
nothingNull: () => NothingNull;
|
|
55
65
|
nothingUndefined: () => NothingUndefined;
|
|
56
|
-
|
|
66
|
+
isJust: <T>(m: Maybe<T>) => m is T;
|
|
57
67
|
isNothing: <T>(m: Maybe<T>) => m is Nothing;
|
|
58
68
|
isNothingNull: <T>(m: Maybe<T>) => m is NothingNull;
|
|
59
69
|
isNothingUndefined: <T>(m: Maybe<T>) => m is NothingUndefined;
|
|
60
|
-
fromNullable: <T>(
|
|
70
|
+
fromNullable: <T>(m: T | null | undefined) => Maybe<T>;
|
|
71
|
+
fromThrowable: <T>(fn: () => T) => Maybe<T>;
|
|
72
|
+
fromPromise: <T>(promise: Promise<T>) => Promise<Maybe<T>>;
|
|
61
73
|
toNullable: <T>(m: Maybe<T>) => T | null;
|
|
62
74
|
toUndefined: <T>(m: Maybe<T>) => T | undefined;
|
|
63
75
|
map: <T, U>(m: Maybe<T>, fn: (v: T) => U) => Maybe<U>;
|
|
@@ -67,11 +79,10 @@ declare const Maybe: {
|
|
|
67
79
|
some: (v: T) => U;
|
|
68
80
|
nothing: () => U;
|
|
69
81
|
}) => U;
|
|
82
|
+
fold: <T, U>(m: Maybe<T>, onNothing: () => U, onJust: (v: T) => U) => U;
|
|
70
83
|
getOrElse: <T>(m: Maybe<T>, d: T) => T;
|
|
71
84
|
getOrUndefined: <T>(m: Maybe<T>) => T | undefined;
|
|
72
|
-
getOrThrow: <T>(m: Maybe<T
|
|
73
|
-
fromThrowable: <T>(fn: () => T) => Maybe<T>;
|
|
74
|
-
fromPromise: <T>(promise: Promise<T>) => Promise<Maybe<T>>;
|
|
85
|
+
getOrThrow: <T>(m: Maybe<T>) => T;
|
|
75
86
|
zip: <T, U>(a: Maybe<T>, b: Maybe<U>) => Maybe<[T, U]>;
|
|
76
87
|
apply: <T, U>(fn: Maybe<(value: T) => U>, opt: Maybe<T>) => Maybe<U>;
|
|
77
88
|
orElse: <T>(opt: Maybe<T>, other: Maybe<T>) => Maybe<T>;
|
|
@@ -86,6 +97,9 @@ type Some<T> = {
|
|
|
86
97
|
};
|
|
87
98
|
declare const none: <T>() => Option<T>;
|
|
88
99
|
declare const some: <T>(value: T) => Option<T>;
|
|
100
|
+
declare const isSome: <T>(option: Option<T>) => option is Some<T>;
|
|
101
|
+
declare const isNone: <T>(option: Option<T>) => option is None;
|
|
102
|
+
declare const unwrap: <T>(option: Some<T>) => T;
|
|
89
103
|
type Option<T> = None | Some<T>;
|
|
90
104
|
declare const Option: {
|
|
91
105
|
none: <T>() => Option<T>;
|
|
@@ -104,9 +118,10 @@ declare const Option: {
|
|
|
104
118
|
some: (value: T) => U;
|
|
105
119
|
none: () => U;
|
|
106
120
|
}) => U;
|
|
121
|
+
unwrap: <T>(option: Some<T>) => T;
|
|
107
122
|
getOrElse: <T>(option: Option<T>, defaultValue: T) => T;
|
|
108
123
|
getOrUndefined: <T>(option: Option<T>) => T | undefined;
|
|
109
|
-
getOrThrow: <T>(option: Option<T
|
|
124
|
+
getOrThrow: <T>(option: Option<T>) => T;
|
|
110
125
|
zip: <T, U>(a: Option<T>, b: Option<U>) => Option<[T, U]>;
|
|
111
126
|
apply: <T, U>(fn: Option<(value: T) => U>, opt: Option<T>) => Option<U>;
|
|
112
127
|
orElse: <T>(opt: Option<T>, other: Option<T>) => Option<T>;
|
|
@@ -120,6 +135,9 @@ declare global {
|
|
|
120
135
|
}
|
|
121
136
|
}
|
|
122
137
|
|
|
138
|
+
declare const fst: <A, B>(p: Pair<A, B>) => A;
|
|
139
|
+
declare const snd: <A, B>(p: Pair<A, B>) => B;
|
|
140
|
+
declare const pair: <A, B>(a: A, b: B) => Pair<A, B>;
|
|
123
141
|
type Pair<A, B> = readonly [A, B];
|
|
124
142
|
declare const Pair: {
|
|
125
143
|
fst: <A, B>(p: Pair<A, B>) => A;
|
|
@@ -147,7 +165,6 @@ declare const Pair: {
|
|
|
147
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;
|
|
148
166
|
zip: <A, B, C, D>(p1: Pair<A, B>, p2: Pair<C, D>) => Pair<Pair<A, C>, Pair<B, D>>;
|
|
149
167
|
};
|
|
150
|
-
declare const pair: <A, B>(a: A, b: B) => Pair<A, B>;
|
|
151
168
|
|
|
152
169
|
type Done<T> = {
|
|
153
170
|
readonly v: T;
|
|
@@ -155,14 +172,24 @@ type Done<T> = {
|
|
|
155
172
|
type Fail<E> = {
|
|
156
173
|
readonly e: E;
|
|
157
174
|
};
|
|
158
|
-
declare const done: <T>(
|
|
159
|
-
declare const fail: <E>(
|
|
175
|
+
declare const done: <T>(v: T) => Done<T>;
|
|
176
|
+
declare const fail: <E>(e: E) => Fail<E>;
|
|
177
|
+
declare const Ok: <T>(v: T) => Done<T>;
|
|
178
|
+
declare const Err: <E>(e: E) => Fail<E>;
|
|
179
|
+
declare const isDone: <T, E>(r: Result<T, E>) => r is Done<T>;
|
|
180
|
+
declare const isFail: <T, E>(r: Result<T, E>) => r is Fail<E>;
|
|
181
|
+
declare const isOk: <T, E>(r: Result<T, E>) => r is Done<T>;
|
|
182
|
+
declare const isErr: <T, E>(r: Result<T, E>) => r is Fail<E>;
|
|
183
|
+
declare const val: <T>(r: Done<T>) => T;
|
|
184
|
+
declare const err: <E>(r: Fail<E>) => E;
|
|
160
185
|
type Result<T, E> = Done<T> | Fail<E>;
|
|
161
186
|
declare const Result: {
|
|
162
|
-
done: <T>(
|
|
163
|
-
fail: <E>(
|
|
164
|
-
|
|
165
|
-
Err: <E>(
|
|
187
|
+
done: <T>(v: T) => Done<T>;
|
|
188
|
+
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;
|
|
166
193
|
new: <T, E>(value: T | null | undefined, error: E) => Result<T, E>;
|
|
167
194
|
isDone: <T, E>(r: Result<T, E>) => r is Done<T>;
|
|
168
195
|
isFail: <T, E>(r: Result<T, E>) => r is Fail<E>;
|
|
@@ -182,7 +209,8 @@ declare const Result: {
|
|
|
182
209
|
fold: <T, E, U>(r: Result<T, E>, onFail: (error: E) => U, onDone: (value: T) => U) => U;
|
|
183
210
|
recover: <T, E>(r: Result<T, E>, fn: (error: E) => T) => Result<T, E>;
|
|
184
211
|
getOrElse: <T, E>(r: Result<T, E>, d: T) => T;
|
|
185
|
-
|
|
212
|
+
getOrUndefined: <T, E>(r: Result<T, E>) => T | undefined;
|
|
213
|
+
getOrThrow: <T, E>(r: Result<T, E>) => T;
|
|
186
214
|
zip: <T, U, E>(a: Result<T, E>, b: Result<U, E>) => Result<[T, U], E>;
|
|
187
215
|
apply: <T, U, E>(fn: Result<(a: T) => U, E>, arg: Result<T, E>) => Result<U, E>;
|
|
188
216
|
orElse: <T, E>(a: Result<T, E>, b: Result<T, E>) => Result<T, E>;
|
|
@@ -196,4 +224,4 @@ declare global {
|
|
|
196
224
|
}
|
|
197
225
|
}
|
|
198
226
|
|
|
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 };
|
|
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 };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
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;
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
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};
|