decoders 2.0.0-beta3 → 2.0.0-beta4
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/CHANGELOG.md +4 -0
- package/_esm/core/tuple.js +7 -7
- package/_esm/core/tuple.js.flow +21 -26
- package/_esm/index.js.flow +1 -1
- package/_esm/result.js +5 -2
- package/_esm/result.js.flow +6 -2
- package/core/tuple.js +6 -6
- package/core/tuple.js.flow +21 -26
- package/index.js.flow +1 -1
- package/package.json +1 -1
- package/result.js +9 -4
- package/result.js.flow +6 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
## v2.0.0-beta
|
|
2
2
|
|
|
3
|
+
Upgrading to v2 _can_, but doesn't _have_ to be a breaking change for you. If upgrading
|
|
4
|
+
causes errors for you, please see the [migration guide](./MIGRATING-v2.md) for
|
|
5
|
+
instructions.
|
|
6
|
+
|
|
3
7
|
Potentially breaking changes:
|
|
4
8
|
|
|
5
9
|
- Drop support for all Node versions below 12.x
|
package/_esm/core/tuple.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { annotate } from '../annotate';
|
|
2
2
|
import { compose, predicate } from './composition';
|
|
3
|
-
import { err,
|
|
3
|
+
import { err, ok, okOrErrValue, unwrap } from '../result';
|
|
4
4
|
import { poja } from './array';
|
|
5
5
|
|
|
6
6
|
var ntuple = function ntuple(n) {
|
|
@@ -24,7 +24,7 @@ export function tuple1(decoder1) {
|
|
|
24
24
|
} catch (e) {
|
|
25
25
|
// If a decoder error has happened while unwrapping all the
|
|
26
26
|
// results, try to construct a good error message
|
|
27
|
-
return err(annotate(
|
|
27
|
+
return err(annotate([okOrErrValue(result1)]));
|
|
28
28
|
}
|
|
29
29
|
});
|
|
30
30
|
}
|
|
@@ -45,7 +45,7 @@ export function tuple2(decoder1, decoder2) {
|
|
|
45
45
|
} catch (e) {
|
|
46
46
|
// If a decoder error has happened while unwrapping all the
|
|
47
47
|
// results, try to construct a good error message
|
|
48
|
-
return err(annotate([
|
|
48
|
+
return err(annotate([okOrErrValue(result1), okOrErrValue(result2)]));
|
|
49
49
|
}
|
|
50
50
|
});
|
|
51
51
|
}
|
|
@@ -68,7 +68,7 @@ export function tuple3(decoder1, decoder2, decoder3) {
|
|
|
68
68
|
} catch (e) {
|
|
69
69
|
// If a decoder error has happened while unwrapping all the
|
|
70
70
|
// results, try to construct a good error message
|
|
71
|
-
return err(annotate([
|
|
71
|
+
return err(annotate([okOrErrValue(result1), okOrErrValue(result2), okOrErrValue(result3)]));
|
|
72
72
|
}
|
|
73
73
|
});
|
|
74
74
|
}
|
|
@@ -93,7 +93,7 @@ export function tuple4(decoder1, decoder2, decoder3, decoder4) {
|
|
|
93
93
|
} catch (e) {
|
|
94
94
|
// If a decoder error has happened while unwrapping all the
|
|
95
95
|
// results, try to construct a good error message
|
|
96
|
-
return err(annotate([
|
|
96
|
+
return err(annotate([okOrErrValue(result1), okOrErrValue(result2), okOrErrValue(result3), okOrErrValue(result4)]));
|
|
97
97
|
}
|
|
98
98
|
});
|
|
99
99
|
}
|
|
@@ -120,7 +120,7 @@ export function tuple5(decoder1, decoder2, decoder3, decoder4, decoder5) {
|
|
|
120
120
|
} catch (e) {
|
|
121
121
|
// If a decoder error has happened while unwrapping all the
|
|
122
122
|
// results, try to construct a good error message
|
|
123
|
-
return err(annotate([
|
|
123
|
+
return err(annotate([okOrErrValue(result1), okOrErrValue(result2), okOrErrValue(result3), okOrErrValue(result4), okOrErrValue(result5)]));
|
|
124
124
|
}
|
|
125
125
|
});
|
|
126
126
|
}
|
|
@@ -149,7 +149,7 @@ export function tuple6(decoder1, decoder2, decoder3, decoder4, decoder5, decoder
|
|
|
149
149
|
} catch (e) {
|
|
150
150
|
// If a decoder error has happened while unwrapping all the
|
|
151
151
|
// results, try to construct a good error message
|
|
152
|
-
return err(annotate([
|
|
152
|
+
return err(annotate([okOrErrValue(result1), okOrErrValue(result2), okOrErrValue(result3), okOrErrValue(result4), okOrErrValue(result5), okOrErrValue(result6)]));
|
|
153
153
|
}
|
|
154
154
|
});
|
|
155
155
|
}
|
package/_esm/core/tuple.js.flow
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { annotate } from '../annotate';
|
|
4
4
|
import { compose, predicate } from './composition';
|
|
5
|
-
import { err,
|
|
5
|
+
import { err, ok, okOrErrValue, unwrap } from '../result';
|
|
6
6
|
import { poja } from './array';
|
|
7
7
|
import type { Decoder } from '../_types';
|
|
8
8
|
|
|
@@ -26,7 +26,7 @@ export function tuple1<T>(decoder1: Decoder<T>): Decoder<[T]> {
|
|
|
26
26
|
} catch (e) {
|
|
27
27
|
// If a decoder error has happened while unwrapping all the
|
|
28
28
|
// results, try to construct a good error message
|
|
29
|
-
return err(annotate(
|
|
29
|
+
return err(annotate([okOrErrValue(result1)]));
|
|
30
30
|
}
|
|
31
31
|
});
|
|
32
32
|
}
|
|
@@ -49,12 +49,7 @@ export function tuple2<T1, T2>(
|
|
|
49
49
|
} catch (e) {
|
|
50
50
|
// If a decoder error has happened while unwrapping all the
|
|
51
51
|
// results, try to construct a good error message
|
|
52
|
-
return err(
|
|
53
|
-
annotate([
|
|
54
|
-
isErr(result1) ? errValue(result1) : value(result1),
|
|
55
|
-
isErr(result2) ? errValue(result2) : value(result2),
|
|
56
|
-
]),
|
|
57
|
-
);
|
|
52
|
+
return err(annotate([okOrErrValue(result1), okOrErrValue(result2)]));
|
|
58
53
|
}
|
|
59
54
|
});
|
|
60
55
|
}
|
|
@@ -81,9 +76,9 @@ export function tuple3<T1, T2, T3>(
|
|
|
81
76
|
// results, try to construct a good error message
|
|
82
77
|
return err(
|
|
83
78
|
annotate([
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
79
|
+
okOrErrValue(result1),
|
|
80
|
+
okOrErrValue(result2),
|
|
81
|
+
okOrErrValue(result3),
|
|
87
82
|
]),
|
|
88
83
|
);
|
|
89
84
|
}
|
|
@@ -119,10 +114,10 @@ export function tuple4<T1, T2, T3, T4>(
|
|
|
119
114
|
// results, try to construct a good error message
|
|
120
115
|
return err(
|
|
121
116
|
annotate([
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
117
|
+
okOrErrValue(result1),
|
|
118
|
+
okOrErrValue(result2),
|
|
119
|
+
okOrErrValue(result3),
|
|
120
|
+
okOrErrValue(result4),
|
|
126
121
|
]),
|
|
127
122
|
);
|
|
128
123
|
}
|
|
@@ -161,11 +156,11 @@ export function tuple5<T1, T2, T3, T4, T5>(
|
|
|
161
156
|
// results, try to construct a good error message
|
|
162
157
|
return err(
|
|
163
158
|
annotate([
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
159
|
+
okOrErrValue(result1),
|
|
160
|
+
okOrErrValue(result2),
|
|
161
|
+
okOrErrValue(result3),
|
|
162
|
+
okOrErrValue(result4),
|
|
163
|
+
okOrErrValue(result5),
|
|
169
164
|
]),
|
|
170
165
|
);
|
|
171
166
|
}
|
|
@@ -207,12 +202,12 @@ export function tuple6<T1, T2, T3, T4, T5, T6>(
|
|
|
207
202
|
// results, try to construct a good error message
|
|
208
203
|
return err(
|
|
209
204
|
annotate([
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
205
|
+
okOrErrValue(result1),
|
|
206
|
+
okOrErrValue(result2),
|
|
207
|
+
okOrErrValue(result3),
|
|
208
|
+
okOrErrValue(result4),
|
|
209
|
+
okOrErrValue(result5),
|
|
210
|
+
okOrErrValue(result6),
|
|
216
211
|
]),
|
|
217
212
|
);
|
|
218
213
|
}
|
package/_esm/index.js.flow
CHANGED
package/_esm/result.js
CHANGED
|
@@ -35,12 +35,15 @@ export function isErr(result) {
|
|
|
35
35
|
export function withDefault(result, defaultValue) {
|
|
36
36
|
return result.type === 'ok' ? result.value : defaultValue;
|
|
37
37
|
}
|
|
38
|
-
export function
|
|
38
|
+
export function okValue(result) {
|
|
39
39
|
return result.type === 'ok' ? result.value : undefined;
|
|
40
40
|
}
|
|
41
41
|
export function errValue(result) {
|
|
42
42
|
return result.type === 'err' ? result.error : undefined;
|
|
43
43
|
}
|
|
44
|
+
export function okOrErrValue(result) {
|
|
45
|
+
return result.type === 'ok' ? result.value : result.error;
|
|
46
|
+
}
|
|
44
47
|
/**
|
|
45
48
|
* Unwrap the value from this Result instance if this is an "Ok" result.
|
|
46
49
|
* Otherwise, will throw the "Err" error via a runtime exception.
|
|
@@ -127,7 +130,7 @@ export function orElse(result1, lazyResult2) {
|
|
|
127
130
|
* Transform an Ok result. Will not touch Err results.
|
|
128
131
|
*/
|
|
129
132
|
|
|
130
|
-
export function
|
|
133
|
+
export function mapOk(result, mapper) {
|
|
131
134
|
return result.type === 'ok' ? ok(mapper(result.value)) : result;
|
|
132
135
|
}
|
|
133
136
|
/**
|
package/_esm/result.js.flow
CHANGED
|
@@ -43,7 +43,7 @@ export function withDefault<T>(result: Result<T, mixed>, defaultValue: T): T {
|
|
|
43
43
|
return result.type === 'ok' ? result.value : defaultValue;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
export function
|
|
46
|
+
export function okValue<T>(result: Result<T, mixed>): void | T {
|
|
47
47
|
return result.type === 'ok' ? result.value : undefined;
|
|
48
48
|
}
|
|
49
49
|
|
|
@@ -51,6 +51,10 @@ export function errValue<E>(result: Result<mixed, E>): void | E {
|
|
|
51
51
|
return result.type === 'err' ? result.error : undefined;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
+
export function okOrErrValue<T, E>(result: Result<T, E>): T | E {
|
|
55
|
+
return result.type === 'ok' ? result.value : result.error;
|
|
56
|
+
}
|
|
57
|
+
|
|
54
58
|
/**
|
|
55
59
|
* Unwrap the value from this Result instance if this is an "Ok" result.
|
|
56
60
|
* Otherwise, will throw the "Err" error via a runtime exception.
|
|
@@ -148,7 +152,7 @@ export function orElse<T, E, E2>(
|
|
|
148
152
|
/**
|
|
149
153
|
* Transform an Ok result. Will not touch Err results.
|
|
150
154
|
*/
|
|
151
|
-
export function
|
|
155
|
+
export function mapOk<T, E, T2>(
|
|
152
156
|
result: Result<T, E>,
|
|
153
157
|
mapper: (value: T) => T2,
|
|
154
158
|
): Result<T2, E> {
|
package/core/tuple.js
CHANGED
|
@@ -37,7 +37,7 @@ function tuple1(decoder1) {
|
|
|
37
37
|
} catch (e) {
|
|
38
38
|
// If a decoder error has happened while unwrapping all the
|
|
39
39
|
// results, try to construct a good error message
|
|
40
|
-
return (0, _result.err)((0, _annotate.annotate)((0, _result.
|
|
40
|
+
return (0, _result.err)((0, _annotate.annotate)([(0, _result.okOrErrValue)(result1)]));
|
|
41
41
|
}
|
|
42
42
|
});
|
|
43
43
|
}
|
|
@@ -59,7 +59,7 @@ function tuple2(decoder1, decoder2) {
|
|
|
59
59
|
} catch (e) {
|
|
60
60
|
// If a decoder error has happened while unwrapping all the
|
|
61
61
|
// results, try to construct a good error message
|
|
62
|
-
return (0, _result.err)((0, _annotate.annotate)([(0, _result.
|
|
62
|
+
return (0, _result.err)((0, _annotate.annotate)([(0, _result.okOrErrValue)(result1), (0, _result.okOrErrValue)(result2)]));
|
|
63
63
|
}
|
|
64
64
|
});
|
|
65
65
|
}
|
|
@@ -83,7 +83,7 @@ function tuple3(decoder1, decoder2, decoder3) {
|
|
|
83
83
|
} catch (e) {
|
|
84
84
|
// If a decoder error has happened while unwrapping all the
|
|
85
85
|
// results, try to construct a good error message
|
|
86
|
-
return (0, _result.err)((0, _annotate.annotate)([(0, _result.
|
|
86
|
+
return (0, _result.err)((0, _annotate.annotate)([(0, _result.okOrErrValue)(result1), (0, _result.okOrErrValue)(result2), (0, _result.okOrErrValue)(result3)]));
|
|
87
87
|
}
|
|
88
88
|
});
|
|
89
89
|
}
|
|
@@ -109,7 +109,7 @@ function tuple4(decoder1, decoder2, decoder3, decoder4) {
|
|
|
109
109
|
} catch (e) {
|
|
110
110
|
// If a decoder error has happened while unwrapping all the
|
|
111
111
|
// results, try to construct a good error message
|
|
112
|
-
return (0, _result.err)((0, _annotate.annotate)([(0, _result.
|
|
112
|
+
return (0, _result.err)((0, _annotate.annotate)([(0, _result.okOrErrValue)(result1), (0, _result.okOrErrValue)(result2), (0, _result.okOrErrValue)(result3), (0, _result.okOrErrValue)(result4)]));
|
|
113
113
|
}
|
|
114
114
|
});
|
|
115
115
|
}
|
|
@@ -137,7 +137,7 @@ function tuple5(decoder1, decoder2, decoder3, decoder4, decoder5) {
|
|
|
137
137
|
} catch (e) {
|
|
138
138
|
// If a decoder error has happened while unwrapping all the
|
|
139
139
|
// results, try to construct a good error message
|
|
140
|
-
return (0, _result.err)((0, _annotate.annotate)([(0, _result.
|
|
140
|
+
return (0, _result.err)((0, _annotate.annotate)([(0, _result.okOrErrValue)(result1), (0, _result.okOrErrValue)(result2), (0, _result.okOrErrValue)(result3), (0, _result.okOrErrValue)(result4), (0, _result.okOrErrValue)(result5)]));
|
|
141
141
|
}
|
|
142
142
|
});
|
|
143
143
|
}
|
|
@@ -167,7 +167,7 @@ function tuple6(decoder1, decoder2, decoder3, decoder4, decoder5, decoder6) {
|
|
|
167
167
|
} catch (e) {
|
|
168
168
|
// If a decoder error has happened while unwrapping all the
|
|
169
169
|
// results, try to construct a good error message
|
|
170
|
-
return (0, _result.err)((0, _annotate.annotate)([(0, _result.
|
|
170
|
+
return (0, _result.err)((0, _annotate.annotate)([(0, _result.okOrErrValue)(result1), (0, _result.okOrErrValue)(result2), (0, _result.okOrErrValue)(result3), (0, _result.okOrErrValue)(result4), (0, _result.okOrErrValue)(result5), (0, _result.okOrErrValue)(result6)]));
|
|
171
171
|
}
|
|
172
172
|
});
|
|
173
173
|
}
|
package/core/tuple.js.flow
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { annotate } from '../annotate';
|
|
4
4
|
import { compose, predicate } from './composition';
|
|
5
|
-
import { err,
|
|
5
|
+
import { err, ok, okOrErrValue, unwrap } from '../result';
|
|
6
6
|
import { poja } from './array';
|
|
7
7
|
import type { Decoder } from '../_types';
|
|
8
8
|
|
|
@@ -26,7 +26,7 @@ export function tuple1<T>(decoder1: Decoder<T>): Decoder<[T]> {
|
|
|
26
26
|
} catch (e) {
|
|
27
27
|
// If a decoder error has happened while unwrapping all the
|
|
28
28
|
// results, try to construct a good error message
|
|
29
|
-
return err(annotate(
|
|
29
|
+
return err(annotate([okOrErrValue(result1)]));
|
|
30
30
|
}
|
|
31
31
|
});
|
|
32
32
|
}
|
|
@@ -49,12 +49,7 @@ export function tuple2<T1, T2>(
|
|
|
49
49
|
} catch (e) {
|
|
50
50
|
// If a decoder error has happened while unwrapping all the
|
|
51
51
|
// results, try to construct a good error message
|
|
52
|
-
return err(
|
|
53
|
-
annotate([
|
|
54
|
-
isErr(result1) ? errValue(result1) : value(result1),
|
|
55
|
-
isErr(result2) ? errValue(result2) : value(result2),
|
|
56
|
-
]),
|
|
57
|
-
);
|
|
52
|
+
return err(annotate([okOrErrValue(result1), okOrErrValue(result2)]));
|
|
58
53
|
}
|
|
59
54
|
});
|
|
60
55
|
}
|
|
@@ -81,9 +76,9 @@ export function tuple3<T1, T2, T3>(
|
|
|
81
76
|
// results, try to construct a good error message
|
|
82
77
|
return err(
|
|
83
78
|
annotate([
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
79
|
+
okOrErrValue(result1),
|
|
80
|
+
okOrErrValue(result2),
|
|
81
|
+
okOrErrValue(result3),
|
|
87
82
|
]),
|
|
88
83
|
);
|
|
89
84
|
}
|
|
@@ -119,10 +114,10 @@ export function tuple4<T1, T2, T3, T4>(
|
|
|
119
114
|
// results, try to construct a good error message
|
|
120
115
|
return err(
|
|
121
116
|
annotate([
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
117
|
+
okOrErrValue(result1),
|
|
118
|
+
okOrErrValue(result2),
|
|
119
|
+
okOrErrValue(result3),
|
|
120
|
+
okOrErrValue(result4),
|
|
126
121
|
]),
|
|
127
122
|
);
|
|
128
123
|
}
|
|
@@ -161,11 +156,11 @@ export function tuple5<T1, T2, T3, T4, T5>(
|
|
|
161
156
|
// results, try to construct a good error message
|
|
162
157
|
return err(
|
|
163
158
|
annotate([
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
159
|
+
okOrErrValue(result1),
|
|
160
|
+
okOrErrValue(result2),
|
|
161
|
+
okOrErrValue(result3),
|
|
162
|
+
okOrErrValue(result4),
|
|
163
|
+
okOrErrValue(result5),
|
|
169
164
|
]),
|
|
170
165
|
);
|
|
171
166
|
}
|
|
@@ -207,12 +202,12 @@ export function tuple6<T1, T2, T3, T4, T5, T6>(
|
|
|
207
202
|
// results, try to construct a good error message
|
|
208
203
|
return err(
|
|
209
204
|
annotate([
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
205
|
+
okOrErrValue(result1),
|
|
206
|
+
okOrErrValue(result2),
|
|
207
|
+
okOrErrValue(result3),
|
|
208
|
+
okOrErrValue(result4),
|
|
209
|
+
okOrErrValue(result5),
|
|
210
|
+
okOrErrValue(result6),
|
|
216
211
|
]),
|
|
217
212
|
);
|
|
218
213
|
}
|
package/index.js.flow
CHANGED
package/package.json
CHANGED
package/result.js
CHANGED
|
@@ -8,13 +8,14 @@ exports.errValue = errValue;
|
|
|
8
8
|
exports.expect = expect;
|
|
9
9
|
exports.isErr = isErr;
|
|
10
10
|
exports.isOk = isOk;
|
|
11
|
-
exports.map = map;
|
|
12
11
|
exports.mapError = mapError;
|
|
12
|
+
exports.mapOk = mapOk;
|
|
13
13
|
exports.ok = ok;
|
|
14
|
+
exports.okOrErrValue = okOrErrValue;
|
|
15
|
+
exports.okValue = okValue;
|
|
14
16
|
exports.orElse = orElse;
|
|
15
17
|
exports.toString = toString;
|
|
16
18
|
exports.unwrap = unwrap;
|
|
17
|
-
exports.value = value;
|
|
18
19
|
exports.withDefault = withDefault;
|
|
19
20
|
|
|
20
21
|
/**
|
|
@@ -60,13 +61,17 @@ function withDefault(result, defaultValue) {
|
|
|
60
61
|
return result.type === 'ok' ? result.value : defaultValue;
|
|
61
62
|
}
|
|
62
63
|
|
|
63
|
-
function
|
|
64
|
+
function okValue(result) {
|
|
64
65
|
return result.type === 'ok' ? result.value : undefined;
|
|
65
66
|
}
|
|
66
67
|
|
|
67
68
|
function errValue(result) {
|
|
68
69
|
return result.type === 'err' ? result.error : undefined;
|
|
69
70
|
}
|
|
71
|
+
|
|
72
|
+
function okOrErrValue(result) {
|
|
73
|
+
return result.type === 'ok' ? result.value : result.error;
|
|
74
|
+
}
|
|
70
75
|
/**
|
|
71
76
|
* Unwrap the value from this Result instance if this is an "Ok" result.
|
|
72
77
|
* Otherwise, will throw the "Err" error via a runtime exception.
|
|
@@ -159,7 +164,7 @@ function orElse(result1, lazyResult2) {
|
|
|
159
164
|
*/
|
|
160
165
|
|
|
161
166
|
|
|
162
|
-
function
|
|
167
|
+
function mapOk(result, mapper) {
|
|
163
168
|
return result.type === 'ok' ? ok(mapper(result.value)) : result;
|
|
164
169
|
}
|
|
165
170
|
/**
|
package/result.js.flow
CHANGED
|
@@ -43,7 +43,7 @@ export function withDefault<T>(result: Result<T, mixed>, defaultValue: T): T {
|
|
|
43
43
|
return result.type === 'ok' ? result.value : defaultValue;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
export function
|
|
46
|
+
export function okValue<T>(result: Result<T, mixed>): void | T {
|
|
47
47
|
return result.type === 'ok' ? result.value : undefined;
|
|
48
48
|
}
|
|
49
49
|
|
|
@@ -51,6 +51,10 @@ export function errValue<E>(result: Result<mixed, E>): void | E {
|
|
|
51
51
|
return result.type === 'err' ? result.error : undefined;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
+
export function okOrErrValue<T, E>(result: Result<T, E>): T | E {
|
|
55
|
+
return result.type === 'ok' ? result.value : result.error;
|
|
56
|
+
}
|
|
57
|
+
|
|
54
58
|
/**
|
|
55
59
|
* Unwrap the value from this Result instance if this is an "Ok" result.
|
|
56
60
|
* Otherwise, will throw the "Err" error via a runtime exception.
|
|
@@ -148,7 +152,7 @@ export function orElse<T, E, E2>(
|
|
|
148
152
|
/**
|
|
149
153
|
* Transform an Ok result. Will not touch Err results.
|
|
150
154
|
*/
|
|
151
|
-
export function
|
|
155
|
+
export function mapOk<T, E, T2>(
|
|
152
156
|
result: Result<T, E>,
|
|
153
157
|
mapper: (value: T) => T2,
|
|
154
158
|
): Result<T2, E> {
|