decoders 1.26.0-beta2 → 2.0.0-beta3
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 +21 -5
- package/_esm/_guard.js +15 -0
- package/_esm/_guard.js.flow +20 -0
- package/_esm/_types.js +0 -0
- package/_esm/_types.js.flow +20 -0
- package/_esm/_utils.js +93 -0
- package/_esm/_utils.js.flow +97 -0
- package/_esm/annotate.js +144 -0
- package/_esm/annotate.js.flow +218 -0
- package/_esm/core/array.js +91 -0
- package/{cjs → _esm/core}/array.js.flow +22 -25
- package/_esm/core/boolean.js +28 -0
- package/{cjs → _esm/core}/boolean.js.flow +8 -7
- package/_esm/core/composition.js +42 -0
- package/{cjs/utils.js.flow → _esm/core/composition.js.flow} +7 -22
- package/_esm/core/constants.js +46 -0
- package/{cjs → _esm/core}/constants.js.flow +13 -12
- package/_esm/core/date.js +28 -0
- package/{cjs → _esm/core}/date.js.flow +9 -7
- package/{cjs → _esm/core}/describe.js +5 -11
- package/{cjs → _esm/core}/describe.js.flow +4 -4
- package/{cjs → _esm/core}/dispatch.js +8 -15
- package/{cjs → _esm/core}/dispatch.js.flow +6 -5
- package/_esm/core/either.js +90 -0
- package/{cjs → _esm/core}/either.js.flow +55 -35
- package/_esm/core/fail.js +11 -0
- package/_esm/core/fail.js.flow +12 -0
- package/_esm/core/instanceOf.js +8 -0
- package/{cjs → _esm/core}/instanceOf.js.flow +7 -8
- package/_esm/core/json.js +15 -0
- package/{cjs → _esm/core}/json.js.flow +4 -4
- package/_esm/core/lazy.js +11 -0
- package/{cjs → _esm/core}/lazy.js.flow +1 -1
- package/_esm/core/mapping.js +54 -0
- package/_esm/core/mapping.js.flow +54 -0
- package/_esm/core/number.js +25 -0
- package/{cjs → _esm/core}/number.js.flow +10 -11
- package/_esm/core/object.js +175 -0
- package/{cjs → _esm/core}/object.js.flow +44 -52
- package/_esm/core/optional.js +38 -0
- package/{cjs → _esm/core}/optional.js.flow +6 -7
- package/{cjs → _esm/core}/string.js +18 -35
- package/{cjs → _esm/core}/string.js.flow +13 -12
- package/_esm/core/tuple.js +155 -0
- package/{cjs → _esm/core}/tuple.js.flow +62 -63
- package/_esm/format/index.js +2 -0
- package/_esm/format/index.js.flow +4 -0
- package/_esm/format/inline.js +137 -0
- package/_esm/format/inline.js.flow +122 -0
- package/_esm/format/short.js +4 -0
- package/_esm/format/short.js.flow +8 -0
- package/_esm/index.js +37 -0
- package/{cjs → _esm}/index.js.flow +31 -24
- package/_esm/result.js +139 -0
- package/_esm/result.js.flow +166 -0
- package/_guard.js +26 -0
- package/_guard.js.flow +20 -0
- package/_types.js +1 -0
- package/_types.js.flow +20 -0
- package/_utils.js +108 -0
- package/_utils.js.flow +97 -0
- package/annotate.js +161 -0
- package/annotate.js.flow +218 -0
- package/core/array.js +108 -0
- package/core/array.js.flow +103 -0
- package/core/boolean.js +44 -0
- package/core/boolean.js.flow +29 -0
- package/core/composition.js +56 -0
- package/core/composition.js.flow +43 -0
- package/core/constants.js +69 -0
- package/core/constants.js.flow +46 -0
- package/core/date.js +46 -0
- package/core/date.js.flow +40 -0
- package/core/describe.js +26 -0
- package/core/describe.js.flow +17 -0
- package/core/dispatch.js +62 -0
- package/core/dispatch.js.flow +58 -0
- package/core/either.js +117 -0
- package/core/either.js.flow +151 -0
- package/core/fail.js +21 -0
- package/core/fail.js.flow +12 -0
- package/core/instanceOf.js +19 -0
- package/core/instanceOf.js.flow +20 -0
- package/{cjs → core}/json.js +3 -5
- package/core/json.js.flow +28 -0
- package/{cjs → core}/lazy.js +1 -3
- package/core/lazy.js.flow +15 -0
- package/core/mapping.js +67 -0
- package/core/mapping.js.flow +54 -0
- package/core/number.js +40 -0
- package/core/number.js.flow +34 -0
- package/core/object.js +194 -0
- package/core/object.js.flow +203 -0
- package/core/optional.js +54 -0
- package/core/optional.js.flow +41 -0
- package/core/string.js +98 -0
- package/core/string.js.flow +82 -0
- package/core/tuple.js +173 -0
- package/core/tuple.js.flow +220 -0
- package/format/index.js +12 -0
- package/format/index.js.flow +4 -0
- package/format/inline.js +146 -0
- package/format/inline.js.flow +122 -0
- package/format/short.js +10 -0
- package/format/short.js.flow +8 -0
- package/index.js +120 -0
- package/index.js.flow +63 -0
- package/package.json +3 -11
- package/result.js +172 -0
- package/result.js.flow +166 -0
- package/cjs/array.js +0 -133
- package/cjs/boolean.js +0 -42
- package/cjs/constants.js +0 -67
- package/cjs/date.js +0 -42
- package/cjs/either.js +0 -85
- package/cjs/fail.js +0 -19
- package/cjs/fail.js.flow +0 -13
- package/cjs/guard.js +0 -30
- package/cjs/guard.js.flow +0 -36
- package/cjs/index.js +0 -397
- package/cjs/instanceOf.js +0 -17
- package/cjs/mapping.js +0 -113
- package/cjs/mapping.js.flow +0 -71
- package/cjs/number.js +0 -38
- package/cjs/object.js +0 -254
- package/cjs/optional.js +0 -52
- package/cjs/tuple.js +0 -199
- package/cjs/types.js +0 -3
- package/cjs/types.js.flow +0 -26
- package/cjs/utils.js +0 -70
- package/es/index.js +0 -1039
- package/ts/array.d.ts +0 -5
- package/ts/boolean.d.ts +0 -5
- package/ts/constants.d.ts +0 -11
- package/ts/date.d.ts +0 -4
- package/ts/describe.d.ts +0 -3
- package/ts/dispatch.d.ts +0 -8
- package/ts/either.d.ts +0 -61
- package/ts/fail.d.ts +0 -3
- package/ts/guard.d.ts +0 -7
- package/ts/helpers.d.ts +0 -79
- package/ts/index.d.ts +0 -38
- package/ts/instanceOf.d.ts +0 -3
- package/ts/json.d.ts +0 -11
- package/ts/lazy.d.ts +0 -3
- package/ts/mapping.d.ts +0 -4
- package/ts/number.d.ts +0 -6
- package/ts/object.d.ts +0 -33
- package/ts/optional.d.ts +0 -5
- package/ts/string.d.ts +0 -7
- package/ts/tuple.d.ts +0 -30
- package/ts/types.d.ts +0 -18
- package/ts/utils.d.ts +0 -13
package/ts/array.d.ts
DELETED
package/ts/boolean.d.ts
DELETED
package/ts/constants.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Decoder, Scalar } from './types';
|
|
2
|
-
|
|
3
|
-
// Constants
|
|
4
|
-
|
|
5
|
-
export const null_: Decoder<null>;
|
|
6
|
-
export const undefined_: Decoder<undefined>;
|
|
7
|
-
export function constant<T extends Scalar>(value: T): Decoder<T>;
|
|
8
|
-
export function hardcoded<T extends Scalar>(value: T): Decoder<T>;
|
|
9
|
-
export function hardcoded<T>(value: T): Decoder<T>;
|
|
10
|
-
export const mixed: Decoder<unknown>;
|
|
11
|
-
export const unknown: Decoder<unknown>;
|
package/ts/date.d.ts
DELETED
package/ts/describe.d.ts
DELETED
package/ts/dispatch.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { Decoder, $DecoderType } from './types';
|
|
2
|
-
|
|
3
|
-
export type $Values<T extends object> = T[keyof T];
|
|
4
|
-
|
|
5
|
-
export function dispatch<O extends { [key: string]: Decoder<any> }>(
|
|
6
|
-
field: string,
|
|
7
|
-
mapping: O
|
|
8
|
-
): Decoder<$Values<{ [key in keyof O]: $DecoderType<O[key]> }>>;
|
package/ts/either.d.ts
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { Decoder, Scalar } from './types';
|
|
2
|
-
|
|
3
|
-
export function either<T1, T2>(d1: Decoder<T1>, d2: Decoder<T2>): Decoder<T1 | T2>;
|
|
4
|
-
export function either2<T1, T2>(d1: Decoder<T1>, d2: Decoder<T2>): Decoder<T1 | T2>;
|
|
5
|
-
export function either3<T1, T2, T3>(
|
|
6
|
-
d1: Decoder<T1>,
|
|
7
|
-
d2: Decoder<T2>,
|
|
8
|
-
d3: Decoder<T3>
|
|
9
|
-
): Decoder<T1 | T2 | T3>;
|
|
10
|
-
export function either4<T1, T2, T3, T4>(
|
|
11
|
-
d1: Decoder<T1>,
|
|
12
|
-
d2: Decoder<T2>,
|
|
13
|
-
d3: Decoder<T3>,
|
|
14
|
-
d4: Decoder<T4>
|
|
15
|
-
): Decoder<T1 | T2 | T3 | T4>;
|
|
16
|
-
export function either5<T1, T2, T3, T4, T5>(
|
|
17
|
-
d1: Decoder<T1>,
|
|
18
|
-
d2: Decoder<T2>,
|
|
19
|
-
d3: Decoder<T3>,
|
|
20
|
-
d4: Decoder<T4>,
|
|
21
|
-
d5: Decoder<T5>
|
|
22
|
-
): Decoder<T1 | T2 | T3 | T4 | T5>;
|
|
23
|
-
export function either6<T1, T2, T3, T4, T5, T6>(
|
|
24
|
-
d1: Decoder<T1>,
|
|
25
|
-
d2: Decoder<T2>,
|
|
26
|
-
d3: Decoder<T3>,
|
|
27
|
-
d4: Decoder<T4>,
|
|
28
|
-
d5: Decoder<T5>,
|
|
29
|
-
d6: Decoder<T6>
|
|
30
|
-
): Decoder<T1 | T2 | T3 | T4 | T5 | T6>;
|
|
31
|
-
export function either7<T1, T2, T3, T4, T5, T6, T7>(
|
|
32
|
-
d1: Decoder<T1>,
|
|
33
|
-
d2: Decoder<T2>,
|
|
34
|
-
d3: Decoder<T3>,
|
|
35
|
-
d4: Decoder<T4>,
|
|
36
|
-
d5: Decoder<T5>,
|
|
37
|
-
d6: Decoder<T6>,
|
|
38
|
-
d7: Decoder<T7>
|
|
39
|
-
): Decoder<T1 | T2 | T3 | T4 | T5 | T6 | T7>;
|
|
40
|
-
export function either8<T1, T2, T3, T4, T5, T6, T7, T8>(
|
|
41
|
-
d1: Decoder<T1>,
|
|
42
|
-
d2: Decoder<T2>,
|
|
43
|
-
d3: Decoder<T3>,
|
|
44
|
-
d4: Decoder<T4>,
|
|
45
|
-
d5: Decoder<T5>,
|
|
46
|
-
d6: Decoder<T6>,
|
|
47
|
-
d7: Decoder<T7>,
|
|
48
|
-
d8: Decoder<T8>
|
|
49
|
-
): Decoder<T1 | T2 | T3 | T4 | T5 | T6 | T7 | T8>;
|
|
50
|
-
export function either9<T1, T2, T3, T4, T5, T6, T7, T8, T9>(
|
|
51
|
-
d1: Decoder<T1>,
|
|
52
|
-
d2: Decoder<T2>,
|
|
53
|
-
d3: Decoder<T3>,
|
|
54
|
-
d4: Decoder<T4>,
|
|
55
|
-
d5: Decoder<T5>,
|
|
56
|
-
d6: Decoder<T6>,
|
|
57
|
-
d7: Decoder<T7>,
|
|
58
|
-
d8: Decoder<T8>,
|
|
59
|
-
d9: Decoder<T9>
|
|
60
|
-
): Decoder<T1 | T2 | T3 | T4 | T5 | T6 | T7 | T8 | T9>;
|
|
61
|
-
export function oneOf<T extends Scalar>(constants: readonly T[]): Decoder<T>;
|
package/ts/fail.d.ts
DELETED
package/ts/guard.d.ts
DELETED
package/ts/helpers.d.ts
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Given a type like:
|
|
3
|
-
*
|
|
4
|
-
* {
|
|
5
|
-
* a: string;
|
|
6
|
-
* b: number | undefined;
|
|
7
|
-
* c: null | undefined;
|
|
8
|
-
* d: null;
|
|
9
|
-
* e: undefined;
|
|
10
|
-
* }
|
|
11
|
-
*
|
|
12
|
-
* Will drop all the "undefined" types. In this case, only "e":
|
|
13
|
-
*
|
|
14
|
-
* {
|
|
15
|
-
* a: string;
|
|
16
|
-
* b: number | undefined;
|
|
17
|
-
* c: null | undefined;
|
|
18
|
-
* d: null;
|
|
19
|
-
* }
|
|
20
|
-
*
|
|
21
|
-
*/
|
|
22
|
-
type Compact<T> = { [K in IsDefined<T, keyof T>]: T[K] };
|
|
23
|
-
|
|
24
|
-
type IsDefined<T, K extends keyof T> = K extends any
|
|
25
|
-
? T[K] extends undefined
|
|
26
|
-
? never
|
|
27
|
-
: K
|
|
28
|
-
: never;
|
|
29
|
-
|
|
30
|
-
//
|
|
31
|
-
// HACK:
|
|
32
|
-
// These weird conditionals test whether TypeScript is configured with the
|
|
33
|
-
// `strictNullChecks` compiler option. We use these definitions to influence
|
|
34
|
-
// what's considered a "required" vs an "optional" key for the AllowImplicit
|
|
35
|
-
// type.
|
|
36
|
-
//
|
|
37
|
-
// If strictNullChecks is false, then we should not be emitting any `?` fields
|
|
38
|
-
// and consider all fields "required" because everything is optional by default
|
|
39
|
-
// in that mode anyway.
|
|
40
|
-
//
|
|
41
|
-
type NoStrictNullChecks = undefined extends string ? 1 : undefined;
|
|
42
|
-
// ^^^^^^^^^^^^^^^^^^^^^^^^
|
|
43
|
-
type StrictNullChecks = undefined extends string ? undefined : 1;
|
|
44
|
-
// ^^^^^^^^^^^^^^^^^^^^^^^^
|
|
45
|
-
|
|
46
|
-
export type RequiredKeys<T> = keyof Compact<{
|
|
47
|
-
[K in keyof T]: undefined extends T[K] ? NoStrictNullChecks : 1;
|
|
48
|
-
}>;
|
|
49
|
-
|
|
50
|
-
export type OptionalKeys<T> = keyof Compact<{
|
|
51
|
-
[K in keyof T]: undefined extends T[K] ? 1 : StrictNullChecks;
|
|
52
|
-
}>;
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Transforms an object type, by marking all fields that contain "undefined"
|
|
56
|
-
* with a question mark, i.e. allowing implicit-undefineds when
|
|
57
|
-
* explicit-undefined are also allowed.
|
|
58
|
-
*
|
|
59
|
-
* For example, if:
|
|
60
|
-
*
|
|
61
|
-
* type User = {
|
|
62
|
-
* name: string;
|
|
63
|
-
* age: number | null | undefined;
|
|
64
|
-
* }
|
|
65
|
-
*
|
|
66
|
-
* Then AllowImplicit<User> will become equivalent to:
|
|
67
|
-
*
|
|
68
|
-
* {
|
|
69
|
-
* name: string;
|
|
70
|
-
* age?: number | null;
|
|
71
|
-
* ^
|
|
72
|
-
* Note the question mark
|
|
73
|
-
* }
|
|
74
|
-
*/
|
|
75
|
-
type AllowImplicit<T> = { [K in RequiredKeys<T>]-?: T[K] } & {
|
|
76
|
-
[K in OptionalKeys<T>]+?: Exclude<T[K], undefined>;
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
export { AllowImplicit };
|
package/ts/index.d.ts
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { Decoder, DecoderType, Guard, GuardType } from './types';
|
|
2
|
-
|
|
3
|
-
export { guard } from './guard';
|
|
4
|
-
export { compose, map, predicate } from './utils';
|
|
5
|
-
|
|
6
|
-
export { array, nonEmptyArray, poja } from './array';
|
|
7
|
-
export { boolean, numericBoolean, truthy } from './boolean';
|
|
8
|
-
export { constant, hardcoded, mixed, null_, undefined_, unknown } from './constants';
|
|
9
|
-
export { date, iso8601 } from './date';
|
|
10
|
-
export { describe } from './describe';
|
|
11
|
-
export { dispatch } from './dispatch';
|
|
12
|
-
export {
|
|
13
|
-
either,
|
|
14
|
-
either3,
|
|
15
|
-
either4,
|
|
16
|
-
either5,
|
|
17
|
-
either6,
|
|
18
|
-
either7,
|
|
19
|
-
either8,
|
|
20
|
-
either9,
|
|
21
|
-
oneOf,
|
|
22
|
-
} from './either';
|
|
23
|
-
export { fail } from './fail';
|
|
24
|
-
export { instanceOf } from './instanceOf';
|
|
25
|
-
export { json, jsonArray, jsonObject } from './json';
|
|
26
|
-
export { lazy } from './lazy';
|
|
27
|
-
export { mapping, dict } from './mapping';
|
|
28
|
-
export { integer, number, positiveInteger, positiveNumber } from './number';
|
|
29
|
-
export { exact, inexact, object, pojo } from './object';
|
|
30
|
-
export { maybe, nullable, optional } from './optional';
|
|
31
|
-
export { email, nonEmptyString, regex, string, url } from './string';
|
|
32
|
-
export { tuple1, tuple2, tuple3, tuple4, tuple5, tuple6 } from './tuple';
|
|
33
|
-
|
|
34
|
-
export { Decoder, Guard };
|
|
35
|
-
export { DecoderType, GuardType };
|
|
36
|
-
export { JSONArray, JSONObject, JSONValue } from './json';
|
|
37
|
-
|
|
38
|
-
export type $DecoderType<T> = DecoderType<T>; // Alias for backward compatibility
|
package/ts/instanceOf.d.ts
DELETED
package/ts/json.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Decoder } from './types';
|
|
2
|
-
|
|
3
|
-
export type JSONValue = null | string | number | boolean | JSONObject | JSONArray;
|
|
4
|
-
export interface JSONObject {
|
|
5
|
-
[key: string]: JSONValue;
|
|
6
|
-
}
|
|
7
|
-
export type JSONArray = JSONValue[];
|
|
8
|
-
|
|
9
|
-
export const json: Decoder<JSONValue>;
|
|
10
|
-
export const jsonArray: Decoder<JSONArray>;
|
|
11
|
-
export const jsonObject: Decoder<JSONObject>;
|
package/ts/lazy.d.ts
DELETED
package/ts/mapping.d.ts
DELETED
package/ts/number.d.ts
DELETED
package/ts/object.d.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { $DecoderType, Decoder } from './types';
|
|
2
|
-
import { AllowImplicit } from './helpers';
|
|
3
|
-
|
|
4
|
-
export type ObjectDecoderType<T> = AllowImplicit<{
|
|
5
|
-
[key in keyof T]: $DecoderType<T[key]>;
|
|
6
|
-
}>;
|
|
7
|
-
|
|
8
|
-
export const pojo: Decoder<{ [key: string]: unknown }>;
|
|
9
|
-
|
|
10
|
-
export function object<O extends { [key: string]: Decoder<any> }>(
|
|
11
|
-
mapping: O
|
|
12
|
-
): Decoder<{ [K in keyof ObjectDecoderType<O>]: ObjectDecoderType<O>[K] }>;
|
|
13
|
-
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
14
|
-
// This is basically just equivalent to:
|
|
15
|
-
// ObjectDecoderType<O>
|
|
16
|
-
//
|
|
17
|
-
// But by "resolving" this with a mapped type, we remove the helper
|
|
18
|
-
// type names from the inferred type here, making this much easier to
|
|
19
|
-
// work with while developing.
|
|
20
|
-
|
|
21
|
-
export function exact<O extends { [key: string]: Decoder<any> }>(
|
|
22
|
-
mapping: O
|
|
23
|
-
): Decoder<{ [K in keyof ObjectDecoderType<O>]: ObjectDecoderType<O>[K] }>;
|
|
24
|
-
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
25
|
-
// Ditto (see above)
|
|
26
|
-
|
|
27
|
-
export function inexact<O extends { [key: string]: Decoder<any> }>(
|
|
28
|
-
mapping: O
|
|
29
|
-
): Decoder<
|
|
30
|
-
{ [K in keyof ObjectDecoderType<O>]: ObjectDecoderType<O>[K] } & {
|
|
31
|
-
[extra: string]: unknown;
|
|
32
|
-
}
|
|
33
|
-
>;
|
package/ts/optional.d.ts
DELETED
package/ts/string.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { Decoder } from './types';
|
|
2
|
-
|
|
3
|
-
export const string: Decoder<string>;
|
|
4
|
-
export const nonEmptyString: Decoder<string>;
|
|
5
|
-
export function regex(regex: RegExp, msg: string): Decoder<string>;
|
|
6
|
-
export const email: Decoder<string>;
|
|
7
|
-
export function url(schemes?: readonly string[]): Decoder<string>;
|
package/ts/tuple.d.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { Decoder } from './types';
|
|
2
|
-
|
|
3
|
-
export function tuple1<T1>(d1: Decoder<T1>): Decoder<[T1]>;
|
|
4
|
-
export function tuple2<T1, T2>(d1: Decoder<T1>, d2: Decoder<T2>): Decoder<[T1, T2]>;
|
|
5
|
-
export function tuple3<T1, T2, T3>(
|
|
6
|
-
d1: Decoder<T1>,
|
|
7
|
-
d2: Decoder<T2>,
|
|
8
|
-
d3: Decoder<T3>
|
|
9
|
-
): Decoder<[T1, T2, T3]>;
|
|
10
|
-
export function tuple4<T1, T2, T3, T4>(
|
|
11
|
-
d1: Decoder<T1>,
|
|
12
|
-
d2: Decoder<T2>,
|
|
13
|
-
d3: Decoder<T3>,
|
|
14
|
-
d4: Decoder<T4>
|
|
15
|
-
): Decoder<[T1, T2, T3, T4]>;
|
|
16
|
-
export function tuple5<T1, T2, T3, T4, T5>(
|
|
17
|
-
d1: Decoder<T1>,
|
|
18
|
-
d2: Decoder<T2>,
|
|
19
|
-
d3: Decoder<T3>,
|
|
20
|
-
d4: Decoder<T4>,
|
|
21
|
-
d5: Decoder<T5>
|
|
22
|
-
): Decoder<[T1, T2, T3, T4, T5]>;
|
|
23
|
-
export function tuple6<T1, T2, T3, T4, T5, T6>(
|
|
24
|
-
d1: Decoder<T1>,
|
|
25
|
-
d2: Decoder<T2>,
|
|
26
|
-
d3: Decoder<T3>,
|
|
27
|
-
d4: Decoder<T4>,
|
|
28
|
-
d5: Decoder<T5>,
|
|
29
|
-
d6: Decoder<T6>
|
|
30
|
-
): Decoder<[T1, T2, T3, T4, T5, T6]>;
|
package/ts/types.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { Annotation } from 'debrief';
|
|
2
|
-
import { Result } from 'lemons';
|
|
3
|
-
|
|
4
|
-
export type Scalar = string | number | boolean | symbol | undefined | null;
|
|
5
|
-
|
|
6
|
-
export interface Guard<T> {
|
|
7
|
-
(blob: unknown): T;
|
|
8
|
-
}
|
|
9
|
-
export type Predicate<T> = (value: T) => boolean;
|
|
10
|
-
export type DecodeResult<T> = Result<Annotation, T>;
|
|
11
|
-
export interface Decoder<T, F = unknown> {
|
|
12
|
-
(blob: F): DecodeResult<T>;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export type DecoderType<T> = T extends Decoder<infer V> ? V : never;
|
|
16
|
-
export type $DecoderType<T> = DecoderType<T>; // Alias for backward compatibility
|
|
17
|
-
|
|
18
|
-
export type GuardType<T> = T extends Guard<infer V> ? V : never;
|
package/ts/utils.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Decoder } from './types';
|
|
2
|
-
|
|
3
|
-
export function isDate(value: unknown): boolean;
|
|
4
|
-
export function map<T, V>(decoder: Decoder<T>, mapper: (value: T) => V): Decoder<V>;
|
|
5
|
-
export function compose<T, V>(decoder: Decoder<T>, next: Decoder<V, T>): Decoder<V>;
|
|
6
|
-
export function predicate<T extends F, F = unknown>(
|
|
7
|
-
predicate: (value: F) => value is T,
|
|
8
|
-
msg: string
|
|
9
|
-
): Decoder<T, F>;
|
|
10
|
-
export function predicate<T>(
|
|
11
|
-
predicate: (value: T) => boolean,
|
|
12
|
-
msg: string
|
|
13
|
-
): Decoder<T, T>;
|