decoders 2.0.0-beta8 → 2.0.0-beta9
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 +11 -2
- package/README.md +234 -72
- package/_utils.js +1 -1
- package/_utils.js.flow +3 -3
- package/_utils.mjs +1 -1
- package/core/array.d.ts +3 -0
- package/core/array.js +12 -1
- package/core/array.js.flow +9 -2
- package/core/array.mjs +11 -2
- package/core/boolean.js +3 -3
- package/core/boolean.js.flow +2 -2
- package/core/boolean.mjs +2 -2
- package/core/composition.d.ts +5 -1
- package/core/composition.js +33 -5
- package/core/composition.js.flow +31 -5
- package/core/composition.mjs +31 -5
- package/core/date.js +3 -3
- package/core/date.js.flow +2 -2
- package/core/date.mjs +2 -2
- package/core/dispatch.d.ts +1 -1
- package/core/dispatch.js +8 -6
- package/core/dispatch.js.flow +9 -8
- package/core/dispatch.mjs +6 -5
- package/core/either.d.ts +63 -58
- package/core/either.js +30 -42
- package/core/either.js.flow +38 -84
- package/core/either.mjs +34 -34
- package/core/instanceOf.d.ts +1 -1
- package/core/json.js +3 -3
- package/core/json.js.flow +3 -3
- package/core/json.mjs +3 -3
- package/core/object.d.ts +5 -0
- package/core/object.js +59 -2
- package/core/object.js.flow +77 -21
- package/core/object.mjs +56 -3
- package/core/string.d.ts +3 -0
- package/core/string.js +15 -3
- package/core/string.js.flow +15 -2
- package/core/string.mjs +12 -3
- package/core/tuple.d.ts +28 -28
- package/core/tuple.js +28 -151
- package/core/tuple.js.flow +31 -191
- package/core/tuple.mjs +27 -141
- package/index.d.ts +17 -18
- package/index.js +33 -43
- package/index.js.flow +17 -18
- package/index.mjs +8 -9
- package/package.json +1 -1
- package/result.d.ts +2 -2
- package/result.js +9 -9
- package/result.js.flow +11 -11
- package/result.mjs +9 -9
- package/core/mapping.d.ts +0 -6
- package/core/mapping.js +0 -67
- package/core/mapping.js.flow +0 -62
- package/core/mapping.mjs +0 -58
package/core/tuple.js.flow
CHANGED
|
@@ -2,210 +2,50 @@
|
|
|
2
2
|
|
|
3
3
|
import { annotate } from '../annotate';
|
|
4
4
|
import { compose, predicate } from './composition';
|
|
5
|
-
import { err, ok
|
|
5
|
+
import { err, ok } from '../result';
|
|
6
6
|
import { poja } from './array';
|
|
7
|
+
import type { _Any } from '../_utils';
|
|
7
8
|
import type { Decoder } from '../_types';
|
|
8
|
-
import type { Result } from '../result';
|
|
9
|
-
|
|
10
|
-
function okOrErr<T, E>(result: Result<T, E>): T | E {
|
|
11
|
-
return result.type === 'ok' ? result.value : result.error;
|
|
12
|
-
}
|
|
13
9
|
|
|
14
10
|
const ntuple = (n: number) =>
|
|
15
11
|
predicate(poja, (arr) => arr.length === n, `Must be a ${n}-tuple`);
|
|
16
12
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const result1 = decoder1(blob1);
|
|
26
|
-
try {
|
|
27
|
-
return ok([unwrap(result1)]);
|
|
28
|
-
} catch (e) {
|
|
29
|
-
// If a decoder error has happened while unwrapping all the
|
|
30
|
-
// results, try to construct a good error message
|
|
31
|
-
return err(annotate([okOrErr(result1)]));
|
|
32
|
-
}
|
|
33
|
-
});
|
|
13
|
+
// prettier-ignore
|
|
14
|
+
interface TupleFuncSignature {
|
|
15
|
+
<A>(a: Decoder<A>): Decoder<[A]>;
|
|
16
|
+
<A, B>(a: Decoder<A>, b: Decoder<B>): Decoder<[A, B]>;
|
|
17
|
+
<A, B, C>(a: Decoder<A>, b: Decoder<B>, c: Decoder<C>): Decoder<[A, B, C]>;
|
|
18
|
+
<A, B, C, D>(a: Decoder<A>, b: Decoder<B>, c: Decoder<C>, d: Decoder<D>): Decoder<[A, B, C, D]>;
|
|
19
|
+
<A, B, C, D, E>(a: Decoder<A>, b: Decoder<B>, c: Decoder<C>, d: Decoder<D>, e: Decoder<E>): Decoder<[A, B, C, D, E]>;
|
|
20
|
+
<A, B, C, D, E, F>(a: Decoder<A>, b: Decoder<B>, c: Decoder<C>, d: Decoder<D>, e: Decoder<E>, f: Decoder<F>): Decoder<[A, B, C, D, E, F]>;
|
|
34
21
|
}
|
|
35
22
|
|
|
36
23
|
/**
|
|
37
|
-
*
|
|
38
|
-
* for T1 and T2. Err otherwise.
|
|
24
|
+
* Accepts n-tuples [A, B, C, ...] matching the given decoders A, B, C, ...
|
|
39
25
|
*/
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
26
|
+
function _tuple(...decoders: $ReadOnlyArray<Decoder<mixed>>): Decoder<mixed> {
|
|
27
|
+
return compose(ntuple(decoders.length), (blobs: $ReadOnlyArray<mixed>) => {
|
|
28
|
+
let allOk = true;
|
|
29
|
+
|
|
30
|
+
const rvs = decoders.map((decoder, i) => {
|
|
31
|
+
const blob = blobs[i];
|
|
32
|
+
const result = decoder(blob);
|
|
33
|
+
if (result.ok) {
|
|
34
|
+
return result.value;
|
|
35
|
+
} else {
|
|
36
|
+
allOk = false;
|
|
37
|
+
return result.error;
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
if (allOk) {
|
|
42
|
+
return ok(rvs);
|
|
43
|
+
} else {
|
|
52
44
|
// If a decoder error has happened while unwrapping all the
|
|
53
45
|
// results, try to construct a good error message
|
|
54
|
-
return err(annotate(
|
|
46
|
+
return err(annotate(rvs));
|
|
55
47
|
}
|
|
56
48
|
});
|
|
57
49
|
}
|
|
58
50
|
|
|
59
|
-
|
|
60
|
-
* Builds a Decoder that returns Ok for 3-tuples of [T1, T2, T3], given
|
|
61
|
-
* Decoders for T1, T2, and T3. Err otherwise.
|
|
62
|
-
*/
|
|
63
|
-
export function tuple3<T1, T2, T3>(
|
|
64
|
-
decoder1: Decoder<T1>,
|
|
65
|
-
decoder2: Decoder<T2>,
|
|
66
|
-
decoder3: Decoder<T3>,
|
|
67
|
-
): Decoder<[T1, T2, T3]> {
|
|
68
|
-
return compose(ntuple(3), (blobs: $ReadOnlyArray<mixed>) => {
|
|
69
|
-
const [blob1, blob2, blob3] = blobs;
|
|
70
|
-
|
|
71
|
-
const result1 = decoder1(blob1);
|
|
72
|
-
const result2 = decoder2(blob2);
|
|
73
|
-
const result3 = decoder3(blob3);
|
|
74
|
-
try {
|
|
75
|
-
return ok([unwrap(result1), unwrap(result2), unwrap(result3)]);
|
|
76
|
-
} catch (e) {
|
|
77
|
-
// If a decoder error has happened while unwrapping all the
|
|
78
|
-
// results, try to construct a good error message
|
|
79
|
-
return err(annotate([okOrErr(result1), okOrErr(result2), okOrErr(result3)]));
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Builds a Decoder that returns Ok for 4-tuples of [T1, T2, T3, T4], given
|
|
86
|
-
* Decoders for T1, T2, T3, and T4. Err otherwise.
|
|
87
|
-
*/
|
|
88
|
-
export function tuple4<T1, T2, T3, T4>(
|
|
89
|
-
decoder1: Decoder<T1>,
|
|
90
|
-
decoder2: Decoder<T2>,
|
|
91
|
-
decoder3: Decoder<T3>,
|
|
92
|
-
decoder4: Decoder<T4>,
|
|
93
|
-
): Decoder<[T1, T2, T3, T4]> {
|
|
94
|
-
return compose(ntuple(4), (blobs: $ReadOnlyArray<mixed>) => {
|
|
95
|
-
const [blob1, blob2, blob3, blob4] = blobs;
|
|
96
|
-
|
|
97
|
-
const result1 = decoder1(blob1);
|
|
98
|
-
const result2 = decoder2(blob2);
|
|
99
|
-
const result3 = decoder3(blob3);
|
|
100
|
-
const result4 = decoder4(blob4);
|
|
101
|
-
try {
|
|
102
|
-
return ok([
|
|
103
|
-
unwrap(result1),
|
|
104
|
-
unwrap(result2),
|
|
105
|
-
unwrap(result3),
|
|
106
|
-
unwrap(result4),
|
|
107
|
-
]);
|
|
108
|
-
} catch (e) {
|
|
109
|
-
// If a decoder error has happened while unwrapping all the
|
|
110
|
-
// results, try to construct a good error message
|
|
111
|
-
return err(
|
|
112
|
-
annotate([
|
|
113
|
-
okOrErr(result1),
|
|
114
|
-
okOrErr(result2),
|
|
115
|
-
okOrErr(result3),
|
|
116
|
-
okOrErr(result4),
|
|
117
|
-
]),
|
|
118
|
-
);
|
|
119
|
-
}
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* Builds a Decoder that returns Ok for 5-tuples of [T1, T2, T3, T4, T5], given
|
|
125
|
-
* Decoders for T1, T2, T3, T4, and T5. Err otherwise.
|
|
126
|
-
*/
|
|
127
|
-
export function tuple5<T1, T2, T3, T4, T5>(
|
|
128
|
-
decoder1: Decoder<T1>,
|
|
129
|
-
decoder2: Decoder<T2>,
|
|
130
|
-
decoder3: Decoder<T3>,
|
|
131
|
-
decoder4: Decoder<T4>,
|
|
132
|
-
decoder5: Decoder<T5>,
|
|
133
|
-
): Decoder<[T1, T2, T3, T4, T5]> {
|
|
134
|
-
return compose(ntuple(5), (blobs: $ReadOnlyArray<mixed>) => {
|
|
135
|
-
const [blob1, blob2, blob3, blob4, blob5] = blobs;
|
|
136
|
-
|
|
137
|
-
const result1 = decoder1(blob1);
|
|
138
|
-
const result2 = decoder2(blob2);
|
|
139
|
-
const result3 = decoder3(blob3);
|
|
140
|
-
const result4 = decoder4(blob4);
|
|
141
|
-
const result5 = decoder5(blob5);
|
|
142
|
-
try {
|
|
143
|
-
return ok([
|
|
144
|
-
unwrap(result1),
|
|
145
|
-
unwrap(result2),
|
|
146
|
-
unwrap(result3),
|
|
147
|
-
unwrap(result4),
|
|
148
|
-
unwrap(result5),
|
|
149
|
-
]);
|
|
150
|
-
} catch (e) {
|
|
151
|
-
// If a decoder error has happened while unwrapping all the
|
|
152
|
-
// results, try to construct a good error message
|
|
153
|
-
return err(
|
|
154
|
-
annotate([
|
|
155
|
-
okOrErr(result1),
|
|
156
|
-
okOrErr(result2),
|
|
157
|
-
okOrErr(result3),
|
|
158
|
-
okOrErr(result4),
|
|
159
|
-
okOrErr(result5),
|
|
160
|
-
]),
|
|
161
|
-
);
|
|
162
|
-
}
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
/**
|
|
167
|
-
* Builds a Decoder that returns Ok for 5-tuples of [T1, T2, T3, T4, T5], given
|
|
168
|
-
* Decoders for T1, T2, T3, T4, T5, and T6. Err otherwise.
|
|
169
|
-
*/
|
|
170
|
-
export function tuple6<T1, T2, T3, T4, T5, T6>(
|
|
171
|
-
decoder1: Decoder<T1>,
|
|
172
|
-
decoder2: Decoder<T2>,
|
|
173
|
-
decoder3: Decoder<T3>,
|
|
174
|
-
decoder4: Decoder<T4>,
|
|
175
|
-
decoder5: Decoder<T5>,
|
|
176
|
-
decoder6: Decoder<T6>,
|
|
177
|
-
): Decoder<[T1, T2, T3, T4, T5, T6]> {
|
|
178
|
-
return compose(ntuple(6), (blobs: $ReadOnlyArray<mixed>) => {
|
|
179
|
-
const [blob1, blob2, blob3, blob4, blob5, blob6] = blobs;
|
|
180
|
-
|
|
181
|
-
const result1 = decoder1(blob1);
|
|
182
|
-
const result2 = decoder2(blob2);
|
|
183
|
-
const result3 = decoder3(blob3);
|
|
184
|
-
const result4 = decoder4(blob4);
|
|
185
|
-
const result5 = decoder5(blob5);
|
|
186
|
-
const result6 = decoder6(blob6);
|
|
187
|
-
try {
|
|
188
|
-
return ok([
|
|
189
|
-
unwrap(result1),
|
|
190
|
-
unwrap(result2),
|
|
191
|
-
unwrap(result3),
|
|
192
|
-
unwrap(result4),
|
|
193
|
-
unwrap(result5),
|
|
194
|
-
unwrap(result6),
|
|
195
|
-
]);
|
|
196
|
-
} catch (e) {
|
|
197
|
-
// If a decoder error has happened while unwrapping all the
|
|
198
|
-
// results, try to construct a good error message
|
|
199
|
-
return err(
|
|
200
|
-
annotate([
|
|
201
|
-
okOrErr(result1),
|
|
202
|
-
okOrErr(result2),
|
|
203
|
-
okOrErr(result3),
|
|
204
|
-
okOrErr(result4),
|
|
205
|
-
okOrErr(result5),
|
|
206
|
-
okOrErr(result6),
|
|
207
|
-
]),
|
|
208
|
-
);
|
|
209
|
-
}
|
|
210
|
-
});
|
|
211
|
-
}
|
|
51
|
+
export const tuple: TupleFuncSignature = (_tuple: _Any);
|
package/core/tuple.mjs
CHANGED
|
@@ -1,159 +1,45 @@
|
|
|
1
1
|
import { annotate } from '../annotate.mjs';
|
|
2
2
|
import { compose, predicate } from './composition.mjs';
|
|
3
|
-
import { err, ok
|
|
3
|
+
import { err, ok } from '../result.mjs';
|
|
4
4
|
import { poja } from './array.mjs';
|
|
5
5
|
|
|
6
|
-
function okOrErr(result) {
|
|
7
|
-
return result.type === 'ok' ? result.value : result.error;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
6
|
var ntuple = function ntuple(n) {
|
|
11
7
|
return predicate(poja, function (arr) {
|
|
12
8
|
return arr.length === n;
|
|
13
9
|
}, "Must be a " + n + "-tuple");
|
|
14
|
-
};
|
|
15
|
-
/**
|
|
16
|
-
* Builds a Decoder that returns Ok for 1-tuple of [T], given a Decoder for T.
|
|
17
|
-
* Err otherwise.
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
export function tuple1(decoder1) {
|
|
22
|
-
return compose(ntuple(1), function (blobs) {
|
|
23
|
-
var blob1 = blobs[0];
|
|
24
|
-
var result1 = decoder1(blob1);
|
|
25
|
-
|
|
26
|
-
try {
|
|
27
|
-
return ok([unwrap(result1)]);
|
|
28
|
-
} catch (e) {
|
|
29
|
-
// If a decoder error has happened while unwrapping all the
|
|
30
|
-
// results, try to construct a good error message
|
|
31
|
-
return err(annotate([okOrErr(result1)]));
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Builds a Decoder that returns Ok for 2-tuples of [T1, T2], given Decoders
|
|
37
|
-
* for T1 and T2. Err otherwise.
|
|
38
|
-
*/
|
|
39
|
-
|
|
40
|
-
export function tuple2(decoder1, decoder2) {
|
|
41
|
-
return compose(ntuple(2), function (blobs) {
|
|
42
|
-
var blob1 = blobs[0],
|
|
43
|
-
blob2 = blobs[1];
|
|
44
|
-
var result1 = decoder1(blob1);
|
|
45
|
-
var result2 = decoder2(blob2);
|
|
46
|
-
|
|
47
|
-
try {
|
|
48
|
-
return ok([unwrap(result1), unwrap(result2)]);
|
|
49
|
-
} catch (e) {
|
|
50
|
-
// If a decoder error has happened while unwrapping all the
|
|
51
|
-
// results, try to construct a good error message
|
|
52
|
-
return err(annotate([okOrErr(result1), okOrErr(result2)]));
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Builds a Decoder that returns Ok for 3-tuples of [T1, T2, T3], given
|
|
58
|
-
* Decoders for T1, T2, and T3. Err otherwise.
|
|
59
|
-
*/
|
|
10
|
+
}; // prettier-ignore
|
|
60
11
|
|
|
61
|
-
export function tuple3(decoder1, decoder2, decoder3) {
|
|
62
|
-
return compose(ntuple(3), function (blobs) {
|
|
63
|
-
var blob1 = blobs[0],
|
|
64
|
-
blob2 = blobs[1],
|
|
65
|
-
blob3 = blobs[2];
|
|
66
|
-
var result1 = decoder1(blob1);
|
|
67
|
-
var result2 = decoder2(blob2);
|
|
68
|
-
var result3 = decoder3(blob3);
|
|
69
12
|
|
|
70
|
-
try {
|
|
71
|
-
return ok([unwrap(result1), unwrap(result2), unwrap(result3)]);
|
|
72
|
-
} catch (e) {
|
|
73
|
-
// If a decoder error has happened while unwrapping all the
|
|
74
|
-
// results, try to construct a good error message
|
|
75
|
-
return err(annotate([okOrErr(result1), okOrErr(result2), okOrErr(result3)]));
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
13
|
/**
|
|
80
|
-
*
|
|
81
|
-
* Decoders for T1, T2, T3, and T4. Err otherwise.
|
|
14
|
+
* Accepts n-tuples [A, B, C, ...] matching the given decoders A, B, C, ...
|
|
82
15
|
*/
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
var
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
16
|
+
function _tuple() {
|
|
17
|
+
for (var _len = arguments.length, decoders = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
18
|
+
decoders[_key] = arguments[_key];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return compose(ntuple(decoders.length), function (blobs) {
|
|
22
|
+
var allOk = true;
|
|
23
|
+
var rvs = decoders.map(function (decoder, i) {
|
|
24
|
+
var blob = blobs[i];
|
|
25
|
+
var result = decoder(blob);
|
|
26
|
+
|
|
27
|
+
if (result.ok) {
|
|
28
|
+
return result.value;
|
|
29
|
+
} else {
|
|
30
|
+
allOk = false;
|
|
31
|
+
return result.error;
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
if (allOk) {
|
|
36
|
+
return ok(rvs);
|
|
37
|
+
} else {
|
|
98
38
|
// If a decoder error has happened while unwrapping all the
|
|
99
39
|
// results, try to construct a good error message
|
|
100
|
-
return err(annotate(
|
|
40
|
+
return err(annotate(rvs));
|
|
101
41
|
}
|
|
102
42
|
});
|
|
103
43
|
}
|
|
104
|
-
/**
|
|
105
|
-
* Builds a Decoder that returns Ok for 5-tuples of [T1, T2, T3, T4, T5], given
|
|
106
|
-
* Decoders for T1, T2, T3, T4, and T5. Err otherwise.
|
|
107
|
-
*/
|
|
108
44
|
|
|
109
|
-
export
|
|
110
|
-
return compose(ntuple(5), function (blobs) {
|
|
111
|
-
var blob1 = blobs[0],
|
|
112
|
-
blob2 = blobs[1],
|
|
113
|
-
blob3 = blobs[2],
|
|
114
|
-
blob4 = blobs[3],
|
|
115
|
-
blob5 = blobs[4];
|
|
116
|
-
var result1 = decoder1(blob1);
|
|
117
|
-
var result2 = decoder2(blob2);
|
|
118
|
-
var result3 = decoder3(blob3);
|
|
119
|
-
var result4 = decoder4(blob4);
|
|
120
|
-
var result5 = decoder5(blob5);
|
|
121
|
-
|
|
122
|
-
try {
|
|
123
|
-
return ok([unwrap(result1), unwrap(result2), unwrap(result3), unwrap(result4), unwrap(result5)]);
|
|
124
|
-
} catch (e) {
|
|
125
|
-
// If a decoder error has happened while unwrapping all the
|
|
126
|
-
// results, try to construct a good error message
|
|
127
|
-
return err(annotate([okOrErr(result1), okOrErr(result2), okOrErr(result3), okOrErr(result4), okOrErr(result5)]));
|
|
128
|
-
}
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* Builds a Decoder that returns Ok for 5-tuples of [T1, T2, T3, T4, T5], given
|
|
133
|
-
* Decoders for T1, T2, T3, T4, T5, and T6. Err otherwise.
|
|
134
|
-
*/
|
|
135
|
-
|
|
136
|
-
export function tuple6(decoder1, decoder2, decoder3, decoder4, decoder5, decoder6) {
|
|
137
|
-
return compose(ntuple(6), function (blobs) {
|
|
138
|
-
var blob1 = blobs[0],
|
|
139
|
-
blob2 = blobs[1],
|
|
140
|
-
blob3 = blobs[2],
|
|
141
|
-
blob4 = blobs[3],
|
|
142
|
-
blob5 = blobs[4],
|
|
143
|
-
blob6 = blobs[5];
|
|
144
|
-
var result1 = decoder1(blob1);
|
|
145
|
-
var result2 = decoder2(blob2);
|
|
146
|
-
var result3 = decoder3(blob3);
|
|
147
|
-
var result4 = decoder4(blob4);
|
|
148
|
-
var result5 = decoder5(blob5);
|
|
149
|
-
var result6 = decoder6(blob6);
|
|
150
|
-
|
|
151
|
-
try {
|
|
152
|
-
return ok([unwrap(result1), unwrap(result2), unwrap(result3), unwrap(result4), unwrap(result5), unwrap(result6)]);
|
|
153
|
-
} catch (e) {
|
|
154
|
-
// If a decoder error has happened while unwrapping all the
|
|
155
|
-
// results, try to construct a good error message
|
|
156
|
-
return err(annotate([okOrErr(result1), okOrErr(result2), okOrErr(result3), okOrErr(result4), okOrErr(result5), okOrErr(result6)]));
|
|
157
|
-
}
|
|
158
|
-
});
|
|
159
|
-
}
|
|
45
|
+
export var tuple = _tuple;
|
package/index.d.ts
CHANGED
|
@@ -12,32 +12,31 @@ export { JSONValue, JSONObject, JSONArray } from './core/json';
|
|
|
12
12
|
|
|
13
13
|
export { guard } from './_guard';
|
|
14
14
|
|
|
15
|
-
export { compose,
|
|
15
|
+
export { compose, predicate, prep, transform } from './core/composition';
|
|
16
16
|
|
|
17
|
-
export { array, nonEmptyArray, poja } from './core/array';
|
|
17
|
+
export { array, nonEmptyArray, poja, set } from './core/array';
|
|
18
18
|
export { boolean, numericBoolean, truthy } from './core/boolean';
|
|
19
19
|
export { constant, hardcoded, mixed, null_, undefined_, unknown } from './core/constants';
|
|
20
20
|
export { date, iso8601 } from './core/date';
|
|
21
21
|
export { describe } from './core/describe';
|
|
22
|
-
export {
|
|
22
|
+
export { dict, exact, inexact, mapping, object, pojo } from './core/object';
|
|
23
|
+
export { either, oneOf } from './core/either';
|
|
23
24
|
export {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
} from './core/
|
|
25
|
+
email,
|
|
26
|
+
httpsUrl,
|
|
27
|
+
nonEmptyString,
|
|
28
|
+
regex,
|
|
29
|
+
string,
|
|
30
|
+
url,
|
|
31
|
+
uuid,
|
|
32
|
+
uuidv1,
|
|
33
|
+
uuidv4,
|
|
34
|
+
} from './core/string';
|
|
34
35
|
export { fail } from './core/fail';
|
|
35
36
|
export { instanceOf } from './core/instanceOf';
|
|
37
|
+
export { integer, number, positiveInteger, positiveNumber } from './core/number';
|
|
36
38
|
export { json, jsonObject, jsonArray } from './core/json';
|
|
37
39
|
export { lazy } from './core/lazy';
|
|
38
|
-
export { mapping, dict } from './core/mapping';
|
|
39
|
-
export { integer, number, positiveInteger, positiveNumber } from './core/number';
|
|
40
|
-
export { exact, inexact, object, pojo } from './core/object';
|
|
41
40
|
export { maybe, nullable, optional } from './core/optional';
|
|
42
|
-
export {
|
|
43
|
-
export {
|
|
41
|
+
export { taggedUnion } from './core/dispatch';
|
|
42
|
+
export { tuple } from './core/tuple';
|
package/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
|
-
exports.
|
|
4
|
+
exports.uuidv4 = exports.uuidv1 = exports.uuid = exports.url = exports.unknown = exports.undefined_ = exports.tuple = exports.truthy = exports.transform = exports.taggedUnion = exports.string = exports.set = exports.regex = exports.prep = exports.predicate = exports.positiveNumber = exports.positiveInteger = exports.pojo = exports.poja = exports.optional = exports.oneOf = exports.object = exports.numericBoolean = exports.number = exports.nullable = exports.null_ = exports.nonEmptyString = exports.nonEmptyArray = exports.mixed = exports.maybe = exports.mapping = exports.lazy = exports.jsonObject = exports.jsonArray = exports.json = exports.iso8601 = exports.integer = exports.instanceOf = exports.inexact = exports.httpsUrl = exports.hardcoded = exports.guard = exports.fail = exports.exact = exports.email = exports.either = exports.dict = exports.describe = exports.date = exports.constant = exports.compose = exports["boolean"] = exports.array = void 0;
|
|
5
5
|
|
|
6
6
|
var _guard = require("./_guard");
|
|
7
7
|
|
|
@@ -10,14 +10,16 @@ exports.guard = _guard.guard;
|
|
|
10
10
|
var _composition = require("./core/composition");
|
|
11
11
|
|
|
12
12
|
exports.compose = _composition.compose;
|
|
13
|
-
exports.map = _composition.map;
|
|
14
13
|
exports.predicate = _composition.predicate;
|
|
14
|
+
exports.prep = _composition.prep;
|
|
15
|
+
exports.transform = _composition.transform;
|
|
15
16
|
|
|
16
17
|
var _array = require("./core/array");
|
|
17
18
|
|
|
18
19
|
exports.array = _array.array;
|
|
19
20
|
exports.nonEmptyArray = _array.nonEmptyArray;
|
|
20
21
|
exports.poja = _array.poja;
|
|
22
|
+
exports.set = _array.set;
|
|
21
23
|
|
|
22
24
|
var _boolean = require("./core/boolean");
|
|
23
25
|
|
|
@@ -43,22 +45,32 @@ var _describe = require("./core/describe");
|
|
|
43
45
|
|
|
44
46
|
exports.describe = _describe.describe;
|
|
45
47
|
|
|
46
|
-
var
|
|
48
|
+
var _object = require("./core/object");
|
|
47
49
|
|
|
48
|
-
exports.
|
|
50
|
+
exports.dict = _object.dict;
|
|
51
|
+
exports.exact = _object.exact;
|
|
52
|
+
exports.inexact = _object.inexact;
|
|
53
|
+
exports.mapping = _object.mapping;
|
|
54
|
+
exports.object = _object.object;
|
|
55
|
+
exports.pojo = _object.pojo;
|
|
49
56
|
|
|
50
57
|
var _either = require("./core/either");
|
|
51
58
|
|
|
52
59
|
exports.either = _either.either;
|
|
53
|
-
exports.either3 = _either.either3;
|
|
54
|
-
exports.either4 = _either.either4;
|
|
55
|
-
exports.either5 = _either.either5;
|
|
56
|
-
exports.either6 = _either.either6;
|
|
57
|
-
exports.either7 = _either.either7;
|
|
58
|
-
exports.either8 = _either.either8;
|
|
59
|
-
exports.either9 = _either.either9;
|
|
60
60
|
exports.oneOf = _either.oneOf;
|
|
61
61
|
|
|
62
|
+
var _string = require("./core/string");
|
|
63
|
+
|
|
64
|
+
exports.email = _string.email;
|
|
65
|
+
exports.httpsUrl = _string.httpsUrl;
|
|
66
|
+
exports.nonEmptyString = _string.nonEmptyString;
|
|
67
|
+
exports.regex = _string.regex;
|
|
68
|
+
exports.string = _string.string;
|
|
69
|
+
exports.url = _string.url;
|
|
70
|
+
exports.uuid = _string.uuid;
|
|
71
|
+
exports.uuidv1 = _string.uuidv1;
|
|
72
|
+
exports.uuidv4 = _string.uuidv4;
|
|
73
|
+
|
|
62
74
|
var _fail = require("./core/fail");
|
|
63
75
|
|
|
64
76
|
exports.fail = _fail.fail;
|
|
@@ -67,6 +79,13 @@ var _instanceOf = require("./core/instanceOf");
|
|
|
67
79
|
|
|
68
80
|
exports.instanceOf = _instanceOf.instanceOf;
|
|
69
81
|
|
|
82
|
+
var _number = require("./core/number");
|
|
83
|
+
|
|
84
|
+
exports.integer = _number.integer;
|
|
85
|
+
exports.number = _number.number;
|
|
86
|
+
exports.positiveInteger = _number.positiveInteger;
|
|
87
|
+
exports.positiveNumber = _number.positiveNumber;
|
|
88
|
+
|
|
70
89
|
var _json = require("./core/json");
|
|
71
90
|
|
|
72
91
|
exports.json = _json.json;
|
|
@@ -77,45 +96,16 @@ var _lazy = require("./core/lazy");
|
|
|
77
96
|
|
|
78
97
|
exports.lazy = _lazy.lazy;
|
|
79
98
|
|
|
80
|
-
var _mapping = require("./core/mapping");
|
|
81
|
-
|
|
82
|
-
exports.mapping = _mapping.mapping;
|
|
83
|
-
exports.dict = _mapping.dict;
|
|
84
|
-
|
|
85
|
-
var _number = require("./core/number");
|
|
86
|
-
|
|
87
|
-
exports.integer = _number.integer;
|
|
88
|
-
exports.number = _number.number;
|
|
89
|
-
exports.positiveInteger = _number.positiveInteger;
|
|
90
|
-
exports.positiveNumber = _number.positiveNumber;
|
|
91
|
-
|
|
92
|
-
var _object = require("./core/object");
|
|
93
|
-
|
|
94
|
-
exports.exact = _object.exact;
|
|
95
|
-
exports.inexact = _object.inexact;
|
|
96
|
-
exports.object = _object.object;
|
|
97
|
-
exports.pojo = _object.pojo;
|
|
98
|
-
|
|
99
99
|
var _optional = require("./core/optional");
|
|
100
100
|
|
|
101
101
|
exports.maybe = _optional.maybe;
|
|
102
102
|
exports.nullable = _optional.nullable;
|
|
103
103
|
exports.optional = _optional.optional;
|
|
104
104
|
|
|
105
|
-
var
|
|
105
|
+
var _dispatch = require("./core/dispatch");
|
|
106
106
|
|
|
107
|
-
exports.
|
|
108
|
-
exports.httpsUrl = _string.httpsUrl;
|
|
109
|
-
exports.nonEmptyString = _string.nonEmptyString;
|
|
110
|
-
exports.regex = _string.regex;
|
|
111
|
-
exports.string = _string.string;
|
|
112
|
-
exports.url = _string.url;
|
|
107
|
+
exports.taggedUnion = _dispatch.taggedUnion;
|
|
113
108
|
|
|
114
109
|
var _tuple = require("./core/tuple");
|
|
115
110
|
|
|
116
|
-
exports.
|
|
117
|
-
exports.tuple2 = _tuple.tuple2;
|
|
118
|
-
exports.tuple3 = _tuple.tuple3;
|
|
119
|
-
exports.tuple4 = _tuple.tuple4;
|
|
120
|
-
exports.tuple5 = _tuple.tuple5;
|
|
121
|
-
exports.tuple6 = _tuple.tuple6;
|
|
111
|
+
exports.tuple = _tuple.tuple;
|
package/index.js.flow
CHANGED
|
@@ -32,32 +32,31 @@ export type { JSONValue, JSONObject, JSONArray } from './core/json';
|
|
|
32
32
|
|
|
33
33
|
export { guard } from './_guard';
|
|
34
34
|
|
|
35
|
-
export { compose,
|
|
35
|
+
export { compose, predicate, prep, transform } from './core/composition';
|
|
36
36
|
|
|
37
|
-
export { array, nonEmptyArray, poja } from './core/array';
|
|
37
|
+
export { array, nonEmptyArray, poja, set } from './core/array';
|
|
38
38
|
export { boolean, numericBoolean, truthy } from './core/boolean';
|
|
39
39
|
export { constant, hardcoded, mixed, null_, undefined_, unknown } from './core/constants';
|
|
40
40
|
export { date, iso8601 } from './core/date';
|
|
41
41
|
export { describe } from './core/describe';
|
|
42
|
-
export {
|
|
42
|
+
export { dict, exact, inexact, mapping, object, pojo } from './core/object';
|
|
43
|
+
export { either, oneOf } from './core/either';
|
|
43
44
|
export {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
} from './core/
|
|
45
|
+
email,
|
|
46
|
+
httpsUrl,
|
|
47
|
+
nonEmptyString,
|
|
48
|
+
regex,
|
|
49
|
+
string,
|
|
50
|
+
url,
|
|
51
|
+
uuid,
|
|
52
|
+
uuidv1,
|
|
53
|
+
uuidv4,
|
|
54
|
+
} from './core/string';
|
|
54
55
|
export { fail } from './core/fail';
|
|
55
56
|
export { instanceOf } from './core/instanceOf';
|
|
57
|
+
export { integer, number, positiveInteger, positiveNumber } from './core/number';
|
|
56
58
|
export { json, jsonObject, jsonArray } from './core/json';
|
|
57
59
|
export { lazy } from './core/lazy';
|
|
58
|
-
export { mapping, dict } from './core/mapping';
|
|
59
|
-
export { integer, number, positiveInteger, positiveNumber } from './core/number';
|
|
60
|
-
export { exact, inexact, object, pojo } from './core/object';
|
|
61
60
|
export { maybe, nullable, optional } from './core/optional';
|
|
62
|
-
export {
|
|
63
|
-
export {
|
|
61
|
+
export { taggedUnion } from './core/dispatch';
|
|
62
|
+
export { tuple } from './core/tuple';
|