decoders 1.25.4 → 2.0.0-beta1
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 +30 -3
- package/cjs/_guard.js +26 -0
- package/cjs/_guard.js.flow +20 -0
- package/cjs/_types.js +1 -0
- package/cjs/_types.js.flow +20 -0
- package/cjs/_utils.js +108 -0
- package/cjs/_utils.js.flow +97 -0
- package/cjs/annotate.js +161 -0
- package/cjs/annotate.js.flow +218 -0
- package/cjs/format/index.js +12 -0
- package/cjs/format/index.js.flow +4 -0
- package/cjs/format/inline.js +146 -0
- package/cjs/format/inline.js.flow +122 -0
- package/cjs/format/short.js +10 -0
- package/cjs/format/short.js.flow +8 -0
- package/cjs/index.js +120 -0
- package/{index.js.flow → cjs/index.js.flow} +31 -24
- package/cjs/result.js +172 -0
- package/cjs/result.js.flow +166 -0
- package/cjs/stdlib/array.js +108 -0
- package/{array.js.flow → cjs/stdlib/array.js.flow} +22 -25
- package/cjs/stdlib/boolean.js +44 -0
- package/{boolean.js.flow → cjs/stdlib/boolean.js.flow} +8 -7
- package/cjs/stdlib/composition.js +56 -0
- package/{utils.js.flow → cjs/stdlib/composition.js.flow} +7 -22
- package/cjs/stdlib/constants.js +69 -0
- package/{constants.js.flow → cjs/stdlib/constants.js.flow} +13 -12
- package/cjs/stdlib/date.js +46 -0
- package/{date.js.flow → cjs/stdlib/date.js.flow} +9 -7
- package/cjs/stdlib/describe.js +26 -0
- package/{describe.js.flow → cjs/stdlib/describe.js.flow} +4 -4
- package/cjs/stdlib/dispatch.js +62 -0
- package/{dispatch.js.flow → cjs/stdlib/dispatch.js.flow} +6 -5
- package/cjs/stdlib/either.js +117 -0
- package/{either.js.flow → cjs/stdlib/either.js.flow} +55 -35
- package/cjs/stdlib/fail.js +21 -0
- package/cjs/stdlib/fail.js.flow +12 -0
- package/cjs/stdlib/instanceOf.js +19 -0
- package/{instanceOf.js.flow → cjs/stdlib/instanceOf.js.flow} +7 -8
- package/{json.js → cjs/stdlib/json.js} +3 -5
- package/{json.js.flow → cjs/stdlib/json.js.flow} +4 -4
- package/{lazy.js → cjs/stdlib/lazy.js} +1 -3
- package/{lazy.js.flow → cjs/stdlib/lazy.js.flow} +1 -1
- package/cjs/stdlib/mapping.js +67 -0
- package/cjs/stdlib/mapping.js.flow +54 -0
- package/cjs/stdlib/number.js +40 -0
- package/{number.js.flow → cjs/stdlib/number.js.flow} +10 -11
- package/cjs/stdlib/object.js +194 -0
- package/{object.js.flow → cjs/stdlib/object.js.flow} +44 -52
- package/cjs/stdlib/optional.js +54 -0
- package/{optional.js.flow → cjs/stdlib/optional.js.flow} +6 -7
- package/cjs/stdlib/string.js +98 -0
- package/{string.js.flow → cjs/stdlib/string.js.flow} +13 -12
- package/cjs/stdlib/tuple.js +173 -0
- package/{tuple.js.flow → cjs/stdlib/tuple.js.flow} +62 -63
- package/es/_guard.js +15 -0
- package/es/_types.js +0 -0
- package/es/_utils.js +93 -0
- package/es/annotate.js +144 -0
- package/es/format/index.js +2 -0
- package/es/format/inline.js +137 -0
- package/es/format/short.js +4 -0
- package/es/index.js +37 -0
- package/es/result.js +139 -0
- package/es/stdlib/array.js +91 -0
- package/es/stdlib/boolean.js +28 -0
- package/es/stdlib/composition.js +42 -0
- package/es/stdlib/constants.js +46 -0
- package/es/stdlib/date.js +28 -0
- package/{describe.js → es/stdlib/describe.js} +5 -11
- package/{dispatch.js → es/stdlib/dispatch.js} +8 -15
- package/es/stdlib/either.js +90 -0
- package/es/stdlib/fail.js +11 -0
- package/es/stdlib/instanceOf.js +8 -0
- package/es/stdlib/json.js +15 -0
- package/es/stdlib/lazy.js +11 -0
- package/es/stdlib/mapping.js +54 -0
- package/es/stdlib/number.js +25 -0
- package/es/stdlib/object.js +175 -0
- package/es/stdlib/optional.js +38 -0
- package/{string.js → es/stdlib/string.js} +18 -35
- package/es/stdlib/tuple.js +155 -0
- package/package.json +12 -7
- package/ts/_guard.d.ts +7 -0
- package/ts/_helpers.d.ts +79 -0
- package/{types.d.ts → ts/_types.d.ts} +3 -5
- package/{utils.d.ts → ts/_utils.d.ts} +3 -3
- package/ts/annotate.d.ts +58 -0
- package/{array.d.ts → ts/array.d.ts} +1 -1
- package/{boolean.d.ts → ts/boolean.d.ts} +1 -1
- package/{constants.d.ts → ts/constants.d.ts} +1 -1
- package/{date.d.ts → ts/date.d.ts} +1 -1
- package/{describe.d.ts → ts/describe.d.ts} +1 -1
- package/{dispatch.d.ts → ts/dispatch.d.ts} +3 -3
- package/{either.d.ts → ts/either.d.ts} +8 -8
- package/{fail.d.ts → ts/fail.d.ts} +1 -1
- package/ts/index.d.ts +42 -0
- package/ts/inline.d.ts +3 -0
- package/{instanceOf.d.ts → ts/instanceOf.d.ts} +1 -1
- package/{json.d.ts → ts/json.d.ts} +1 -1
- package/{lazy.d.ts → ts/lazy.d.ts} +1 -1
- package/{mapping.d.ts → ts/mapping.d.ts} +1 -1
- package/{number.d.ts → ts/number.d.ts} +1 -1
- package/{object.d.ts → ts/object.d.ts} +8 -8
- package/{optional.d.ts → ts/optional.d.ts} +1 -1
- package/ts/result.d.ts +39 -0
- package/ts/short.d.ts +3 -0
- package/{string.d.ts → ts/string.d.ts} +1 -1
- package/{tuple.d.ts → ts/tuple.d.ts} +5 -5
- package/array.js +0 -133
- package/boolean.js +0 -42
- package/constants.js +0 -67
- package/date.js +0 -42
- package/either.js +0 -85
- package/fail.js +0 -19
- package/fail.js.flow +0 -13
- package/guard.d.ts +0 -7
- package/guard.js +0 -30
- package/guard.js.flow +0 -36
- package/helpers.d.ts +0 -62
- package/index.d.ts +0 -38
- package/index.js +0 -397
- package/instanceOf.js +0 -17
- package/mapping.js +0 -113
- package/mapping.js.flow +0 -71
- package/number.js +0 -38
- package/object.js +0 -254
- package/optional.js +0 -52
- package/tuple.js +0 -199
- package/types.js +0 -5
- package/types.js.flow +0 -26
- package/utils.js +0 -70
package/either.js
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.either = either;
|
|
7
|
-
exports.either3 = either3;
|
|
8
|
-
exports.either4 = either4;
|
|
9
|
-
exports.either5 = either5;
|
|
10
|
-
exports.either6 = either6;
|
|
11
|
-
exports.either7 = either7;
|
|
12
|
-
exports.either8 = either8;
|
|
13
|
-
exports.either9 = either9;
|
|
14
|
-
exports.oneOf = oneOf;
|
|
15
|
-
|
|
16
|
-
var _debrief = require("debrief");
|
|
17
|
-
|
|
18
|
-
var _Result = require("lemons/Result");
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Indents and adds a dash in front of this (potentially multiline) string.
|
|
22
|
-
*/
|
|
23
|
-
// istanbul ignore next
|
|
24
|
-
function itemize() {
|
|
25
|
-
var s = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
26
|
-
return '-' + (0, _debrief.indent)(s).substring(1);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function either(d1, d2) {
|
|
30
|
-
return function (blob) {
|
|
31
|
-
return d1(blob).dispatch(function (value1) {
|
|
32
|
-
return (0, _Result.Ok)(value1);
|
|
33
|
-
}, function (err1) {
|
|
34
|
-
return d2(blob).dispatch(function (value2) {
|
|
35
|
-
return (0, _Result.Ok)(value2);
|
|
36
|
-
}, function (err2) {
|
|
37
|
-
return (0, _Result.Err)((0, _debrief.annotate)(blob, ['Either:', itemize((0, _debrief.summarize)(err1).join('\n')), itemize((0, _debrief.summarize)(err2).join('\n'))].join('\n')));
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
function either3(d1, d2, d3) {
|
|
44
|
-
return either(d1, either(d2, d3));
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
function either4(d1, d2, d3, d4) {
|
|
48
|
-
return either(d1, either3(d2, d3, d4));
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
function either5(d1, d2, d3, d4, d5) {
|
|
52
|
-
return either(d1, either4(d2, d3, d4, d5));
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
function either6(d1, d2, d3, d4, d5, d6) {
|
|
56
|
-
return either(d1, either5(d2, d3, d4, d5, d6));
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
function either7(d1, d2, d3, d4, d5, d6, d7) {
|
|
60
|
-
return either(d1, either6(d2, d3, d4, d5, d6, d7));
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
function either8(d1, d2, d3, d4, d5, d6, d7, d8) {
|
|
64
|
-
return either(d1, either7(d2, d3, d4, d5, d6, d7, d8));
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
function either9(d1, d2, d3, d4, d5, d6, d7, d8, d9) {
|
|
68
|
-
return either(d1, either8(d2, d3, d4, d5, d6, d7, d8, d9));
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
function oneOf(constants) {
|
|
72
|
-
return function (blob) {
|
|
73
|
-
var winner = constants.find(function (c) {
|
|
74
|
-
return c === blob;
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
if (winner !== undefined) {
|
|
78
|
-
return (0, _Result.Ok)(winner);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
return (0, _Result.Err)((0, _debrief.annotate)(blob, "Must be one of ".concat(constants.map(function (value) {
|
|
82
|
-
return JSON.stringify(value);
|
|
83
|
-
}).join(', '))));
|
|
84
|
-
};
|
|
85
|
-
}
|
package/fail.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.fail = fail;
|
|
7
|
-
|
|
8
|
-
var _debrief = require("debrief");
|
|
9
|
-
|
|
10
|
-
var _Result = require("lemons/Result");
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Decoder that always fails with the given error message, no matter what the input.
|
|
14
|
-
*/
|
|
15
|
-
function fail(msg) {
|
|
16
|
-
return function (blob) {
|
|
17
|
-
return (0, _Result.Err)((0, _debrief.annotate)(blob, msg));
|
|
18
|
-
};
|
|
19
|
-
}
|
package/fail.js.flow
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
// @flow strict
|
|
2
|
-
|
|
3
|
-
import { annotate } from 'debrief';
|
|
4
|
-
import { Err } from 'lemons/Result';
|
|
5
|
-
|
|
6
|
-
import type { Decoder } from './types';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Decoder that always fails with the given error message, no matter what the input.
|
|
10
|
-
*/
|
|
11
|
-
export function fail(msg: string): Decoder<empty> {
|
|
12
|
-
return (blob: mixed) => Err(annotate(blob, msg));
|
|
13
|
-
}
|
package/guard.d.ts
DELETED
package/guard.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.guard = guard;
|
|
7
|
-
|
|
8
|
-
var _debrief = require("debrief");
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Alternative for serialize() that does not echo back the input value.
|
|
12
|
-
*/
|
|
13
|
-
function serializeSimple(annotation) {
|
|
14
|
-
return (0, _debrief.summarize)(annotation).join('\n');
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function guard(decoder, options) {
|
|
18
|
-
var o = options || {};
|
|
19
|
-
var style = o.style || 'inline';
|
|
20
|
-
var serializer = style === 'inline' ? _debrief.serialize // Normal serializer, which echoes back inputted value and inlines errors
|
|
21
|
-
: serializeSimple; // Only returns error messages, without echoing back input
|
|
22
|
-
|
|
23
|
-
return function (blob) {
|
|
24
|
-
return decoder(blob).mapError(function (annotation) {
|
|
25
|
-
var err = new Error('\n' + serializer(annotation));
|
|
26
|
-
err.name = 'Decoding error';
|
|
27
|
-
return err;
|
|
28
|
-
}).unwrap();
|
|
29
|
-
};
|
|
30
|
-
}
|
package/guard.js.flow
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
// @flow strict
|
|
2
|
-
|
|
3
|
-
import { serialize as serializeInline, summarize } from 'debrief';
|
|
4
|
-
import type { Annotation } from 'debrief';
|
|
5
|
-
|
|
6
|
-
import type { Decoder, Guard } from './types';
|
|
7
|
-
|
|
8
|
-
type Options = {|
|
|
9
|
-
style?: 'inline' | 'simple', // `inline` by default
|
|
10
|
-
|};
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Alternative for serialize() that does not echo back the input value.
|
|
14
|
-
*/
|
|
15
|
-
function serializeSimple(annotation: Annotation) {
|
|
16
|
-
return summarize(annotation).join('\n');
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export function guard<T>(decoder: Decoder<T>, options?: Options): Guard<T> {
|
|
20
|
-
const o = options || {};
|
|
21
|
-
const style = o.style || 'inline';
|
|
22
|
-
|
|
23
|
-
const serializer =
|
|
24
|
-
style === 'inline'
|
|
25
|
-
? serializeInline // Normal serializer, which echoes back inputted value and inlines errors
|
|
26
|
-
: serializeSimple; // Only returns error messages, without echoing back input
|
|
27
|
-
|
|
28
|
-
return (blob: mixed) =>
|
|
29
|
-
decoder(blob)
|
|
30
|
-
.mapError((annotation) => {
|
|
31
|
-
const err = new Error('\n' + serializer(annotation));
|
|
32
|
-
err.name = 'Decoding error';
|
|
33
|
-
return err;
|
|
34
|
-
})
|
|
35
|
-
.unwrap();
|
|
36
|
-
}
|
package/helpers.d.ts
DELETED
|
@@ -1,62 +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
|
-
export type RequiredKeys<T> = keyof Compact<
|
|
31
|
-
{ [K in keyof T]: undefined extends T[K] ? undefined : 1 }
|
|
32
|
-
>;
|
|
33
|
-
|
|
34
|
-
export type OptionalKeys<T> = keyof Compact<
|
|
35
|
-
{ [K in keyof T]: undefined extends T[K] ? 1 : undefined }
|
|
36
|
-
>;
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Transforms an object type, by marking all fields that contain "undefined"
|
|
40
|
-
* with a question mark, i.e. allowing implicit-undefineds when
|
|
41
|
-
* explicit-undefined are also allowed.
|
|
42
|
-
*
|
|
43
|
-
* For example, if:
|
|
44
|
-
*
|
|
45
|
-
* type User = {
|
|
46
|
-
* name: string;
|
|
47
|
-
* age: number | null | undefined;
|
|
48
|
-
* }
|
|
49
|
-
*
|
|
50
|
-
* Then AllowImplicit<User> will become equivalent to:
|
|
51
|
-
*
|
|
52
|
-
* {
|
|
53
|
-
* name: string;
|
|
54
|
-
* age?: number | null;
|
|
55
|
-
* ^
|
|
56
|
-
* Note the question mark
|
|
57
|
-
* }
|
|
58
|
-
*/
|
|
59
|
-
type AllowImplicit<T> = { [K in RequiredKeys<T>]-?: T[K] } &
|
|
60
|
-
{ [K in OptionalKeys<T>]+?: Exclude<T[K], undefined> };
|
|
61
|
-
|
|
62
|
-
export { AllowImplicit };
|
package/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/index.js
DELETED
|
@@ -1,397 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
Object.defineProperty(exports, "array", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function get() {
|
|
9
|
-
return _array.array;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
Object.defineProperty(exports, "boolean", {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function get() {
|
|
15
|
-
return _boolean["boolean"];
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
Object.defineProperty(exports, "compose", {
|
|
19
|
-
enumerable: true,
|
|
20
|
-
get: function get() {
|
|
21
|
-
return _utils.compose;
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
Object.defineProperty(exports, "constant", {
|
|
25
|
-
enumerable: true,
|
|
26
|
-
get: function get() {
|
|
27
|
-
return _constants.constant;
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
Object.defineProperty(exports, "date", {
|
|
31
|
-
enumerable: true,
|
|
32
|
-
get: function get() {
|
|
33
|
-
return _date.date;
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
Object.defineProperty(exports, "describe", {
|
|
37
|
-
enumerable: true,
|
|
38
|
-
get: function get() {
|
|
39
|
-
return _describe.describe;
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
Object.defineProperty(exports, "dict", {
|
|
43
|
-
enumerable: true,
|
|
44
|
-
get: function get() {
|
|
45
|
-
return _mapping.dict;
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
Object.defineProperty(exports, "dispatch", {
|
|
49
|
-
enumerable: true,
|
|
50
|
-
get: function get() {
|
|
51
|
-
return _dispatch.dispatch;
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
Object.defineProperty(exports, "either", {
|
|
55
|
-
enumerable: true,
|
|
56
|
-
get: function get() {
|
|
57
|
-
return _either.either;
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
Object.defineProperty(exports, "either3", {
|
|
61
|
-
enumerable: true,
|
|
62
|
-
get: function get() {
|
|
63
|
-
return _either.either3;
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
Object.defineProperty(exports, "either4", {
|
|
67
|
-
enumerable: true,
|
|
68
|
-
get: function get() {
|
|
69
|
-
return _either.either4;
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
Object.defineProperty(exports, "either5", {
|
|
73
|
-
enumerable: true,
|
|
74
|
-
get: function get() {
|
|
75
|
-
return _either.either5;
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
Object.defineProperty(exports, "either6", {
|
|
79
|
-
enumerable: true,
|
|
80
|
-
get: function get() {
|
|
81
|
-
return _either.either6;
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
Object.defineProperty(exports, "either7", {
|
|
85
|
-
enumerable: true,
|
|
86
|
-
get: function get() {
|
|
87
|
-
return _either.either7;
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
Object.defineProperty(exports, "either8", {
|
|
91
|
-
enumerable: true,
|
|
92
|
-
get: function get() {
|
|
93
|
-
return _either.either8;
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
Object.defineProperty(exports, "either9", {
|
|
97
|
-
enumerable: true,
|
|
98
|
-
get: function get() {
|
|
99
|
-
return _either.either9;
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
Object.defineProperty(exports, "email", {
|
|
103
|
-
enumerable: true,
|
|
104
|
-
get: function get() {
|
|
105
|
-
return _string.email;
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
Object.defineProperty(exports, "exact", {
|
|
109
|
-
enumerable: true,
|
|
110
|
-
get: function get() {
|
|
111
|
-
return _object.exact;
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
Object.defineProperty(exports, "fail", {
|
|
115
|
-
enumerable: true,
|
|
116
|
-
get: function get() {
|
|
117
|
-
return _fail.fail;
|
|
118
|
-
}
|
|
119
|
-
});
|
|
120
|
-
Object.defineProperty(exports, "guard", {
|
|
121
|
-
enumerable: true,
|
|
122
|
-
get: function get() {
|
|
123
|
-
return _guard.guard;
|
|
124
|
-
}
|
|
125
|
-
});
|
|
126
|
-
Object.defineProperty(exports, "hardcoded", {
|
|
127
|
-
enumerable: true,
|
|
128
|
-
get: function get() {
|
|
129
|
-
return _constants.hardcoded;
|
|
130
|
-
}
|
|
131
|
-
});
|
|
132
|
-
Object.defineProperty(exports, "inexact", {
|
|
133
|
-
enumerable: true,
|
|
134
|
-
get: function get() {
|
|
135
|
-
return _object.inexact;
|
|
136
|
-
}
|
|
137
|
-
});
|
|
138
|
-
Object.defineProperty(exports, "instanceOf", {
|
|
139
|
-
enumerable: true,
|
|
140
|
-
get: function get() {
|
|
141
|
-
return _instanceOf.instanceOf;
|
|
142
|
-
}
|
|
143
|
-
});
|
|
144
|
-
Object.defineProperty(exports, "integer", {
|
|
145
|
-
enumerable: true,
|
|
146
|
-
get: function get() {
|
|
147
|
-
return _number.integer;
|
|
148
|
-
}
|
|
149
|
-
});
|
|
150
|
-
Object.defineProperty(exports, "iso8601", {
|
|
151
|
-
enumerable: true,
|
|
152
|
-
get: function get() {
|
|
153
|
-
return _date.iso8601;
|
|
154
|
-
}
|
|
155
|
-
});
|
|
156
|
-
Object.defineProperty(exports, "json", {
|
|
157
|
-
enumerable: true,
|
|
158
|
-
get: function get() {
|
|
159
|
-
return _json.json;
|
|
160
|
-
}
|
|
161
|
-
});
|
|
162
|
-
Object.defineProperty(exports, "jsonArray", {
|
|
163
|
-
enumerable: true,
|
|
164
|
-
get: function get() {
|
|
165
|
-
return _json.jsonArray;
|
|
166
|
-
}
|
|
167
|
-
});
|
|
168
|
-
Object.defineProperty(exports, "jsonObject", {
|
|
169
|
-
enumerable: true,
|
|
170
|
-
get: function get() {
|
|
171
|
-
return _json.jsonObject;
|
|
172
|
-
}
|
|
173
|
-
});
|
|
174
|
-
Object.defineProperty(exports, "lazy", {
|
|
175
|
-
enumerable: true,
|
|
176
|
-
get: function get() {
|
|
177
|
-
return _lazy.lazy;
|
|
178
|
-
}
|
|
179
|
-
});
|
|
180
|
-
Object.defineProperty(exports, "map", {
|
|
181
|
-
enumerable: true,
|
|
182
|
-
get: function get() {
|
|
183
|
-
return _utils.map;
|
|
184
|
-
}
|
|
185
|
-
});
|
|
186
|
-
Object.defineProperty(exports, "mapping", {
|
|
187
|
-
enumerable: true,
|
|
188
|
-
get: function get() {
|
|
189
|
-
return _mapping.mapping;
|
|
190
|
-
}
|
|
191
|
-
});
|
|
192
|
-
Object.defineProperty(exports, "maybe", {
|
|
193
|
-
enumerable: true,
|
|
194
|
-
get: function get() {
|
|
195
|
-
return _optional.maybe;
|
|
196
|
-
}
|
|
197
|
-
});
|
|
198
|
-
Object.defineProperty(exports, "mixed", {
|
|
199
|
-
enumerable: true,
|
|
200
|
-
get: function get() {
|
|
201
|
-
return _constants.mixed;
|
|
202
|
-
}
|
|
203
|
-
});
|
|
204
|
-
Object.defineProperty(exports, "nonEmptyArray", {
|
|
205
|
-
enumerable: true,
|
|
206
|
-
get: function get() {
|
|
207
|
-
return _array.nonEmptyArray;
|
|
208
|
-
}
|
|
209
|
-
});
|
|
210
|
-
Object.defineProperty(exports, "nonEmptyString", {
|
|
211
|
-
enumerable: true,
|
|
212
|
-
get: function get() {
|
|
213
|
-
return _string.nonEmptyString;
|
|
214
|
-
}
|
|
215
|
-
});
|
|
216
|
-
Object.defineProperty(exports, "null_", {
|
|
217
|
-
enumerable: true,
|
|
218
|
-
get: function get() {
|
|
219
|
-
return _constants.null_;
|
|
220
|
-
}
|
|
221
|
-
});
|
|
222
|
-
Object.defineProperty(exports, "nullable", {
|
|
223
|
-
enumerable: true,
|
|
224
|
-
get: function get() {
|
|
225
|
-
return _optional.nullable;
|
|
226
|
-
}
|
|
227
|
-
});
|
|
228
|
-
Object.defineProperty(exports, "number", {
|
|
229
|
-
enumerable: true,
|
|
230
|
-
get: function get() {
|
|
231
|
-
return _number.number;
|
|
232
|
-
}
|
|
233
|
-
});
|
|
234
|
-
Object.defineProperty(exports, "numericBoolean", {
|
|
235
|
-
enumerable: true,
|
|
236
|
-
get: function get() {
|
|
237
|
-
return _boolean.numericBoolean;
|
|
238
|
-
}
|
|
239
|
-
});
|
|
240
|
-
Object.defineProperty(exports, "object", {
|
|
241
|
-
enumerable: true,
|
|
242
|
-
get: function get() {
|
|
243
|
-
return _object.object;
|
|
244
|
-
}
|
|
245
|
-
});
|
|
246
|
-
Object.defineProperty(exports, "oneOf", {
|
|
247
|
-
enumerable: true,
|
|
248
|
-
get: function get() {
|
|
249
|
-
return _either.oneOf;
|
|
250
|
-
}
|
|
251
|
-
});
|
|
252
|
-
Object.defineProperty(exports, "optional", {
|
|
253
|
-
enumerable: true,
|
|
254
|
-
get: function get() {
|
|
255
|
-
return _optional.optional;
|
|
256
|
-
}
|
|
257
|
-
});
|
|
258
|
-
Object.defineProperty(exports, "poja", {
|
|
259
|
-
enumerable: true,
|
|
260
|
-
get: function get() {
|
|
261
|
-
return _array.poja;
|
|
262
|
-
}
|
|
263
|
-
});
|
|
264
|
-
Object.defineProperty(exports, "pojo", {
|
|
265
|
-
enumerable: true,
|
|
266
|
-
get: function get() {
|
|
267
|
-
return _object.pojo;
|
|
268
|
-
}
|
|
269
|
-
});
|
|
270
|
-
Object.defineProperty(exports, "positiveInteger", {
|
|
271
|
-
enumerable: true,
|
|
272
|
-
get: function get() {
|
|
273
|
-
return _number.positiveInteger;
|
|
274
|
-
}
|
|
275
|
-
});
|
|
276
|
-
Object.defineProperty(exports, "positiveNumber", {
|
|
277
|
-
enumerable: true,
|
|
278
|
-
get: function get() {
|
|
279
|
-
return _number.positiveNumber;
|
|
280
|
-
}
|
|
281
|
-
});
|
|
282
|
-
Object.defineProperty(exports, "predicate", {
|
|
283
|
-
enumerable: true,
|
|
284
|
-
get: function get() {
|
|
285
|
-
return _utils.predicate;
|
|
286
|
-
}
|
|
287
|
-
});
|
|
288
|
-
Object.defineProperty(exports, "regex", {
|
|
289
|
-
enumerable: true,
|
|
290
|
-
get: function get() {
|
|
291
|
-
return _string.regex;
|
|
292
|
-
}
|
|
293
|
-
});
|
|
294
|
-
Object.defineProperty(exports, "string", {
|
|
295
|
-
enumerable: true,
|
|
296
|
-
get: function get() {
|
|
297
|
-
return _string.string;
|
|
298
|
-
}
|
|
299
|
-
});
|
|
300
|
-
Object.defineProperty(exports, "truthy", {
|
|
301
|
-
enumerable: true,
|
|
302
|
-
get: function get() {
|
|
303
|
-
return _boolean.truthy;
|
|
304
|
-
}
|
|
305
|
-
});
|
|
306
|
-
Object.defineProperty(exports, "tuple1", {
|
|
307
|
-
enumerable: true,
|
|
308
|
-
get: function get() {
|
|
309
|
-
return _tuple.tuple1;
|
|
310
|
-
}
|
|
311
|
-
});
|
|
312
|
-
Object.defineProperty(exports, "tuple2", {
|
|
313
|
-
enumerable: true,
|
|
314
|
-
get: function get() {
|
|
315
|
-
return _tuple.tuple2;
|
|
316
|
-
}
|
|
317
|
-
});
|
|
318
|
-
Object.defineProperty(exports, "tuple3", {
|
|
319
|
-
enumerable: true,
|
|
320
|
-
get: function get() {
|
|
321
|
-
return _tuple.tuple3;
|
|
322
|
-
}
|
|
323
|
-
});
|
|
324
|
-
Object.defineProperty(exports, "tuple4", {
|
|
325
|
-
enumerable: true,
|
|
326
|
-
get: function get() {
|
|
327
|
-
return _tuple.tuple4;
|
|
328
|
-
}
|
|
329
|
-
});
|
|
330
|
-
Object.defineProperty(exports, "tuple5", {
|
|
331
|
-
enumerable: true,
|
|
332
|
-
get: function get() {
|
|
333
|
-
return _tuple.tuple5;
|
|
334
|
-
}
|
|
335
|
-
});
|
|
336
|
-
Object.defineProperty(exports, "tuple6", {
|
|
337
|
-
enumerable: true,
|
|
338
|
-
get: function get() {
|
|
339
|
-
return _tuple.tuple6;
|
|
340
|
-
}
|
|
341
|
-
});
|
|
342
|
-
Object.defineProperty(exports, "undefined_", {
|
|
343
|
-
enumerable: true,
|
|
344
|
-
get: function get() {
|
|
345
|
-
return _constants.undefined_;
|
|
346
|
-
}
|
|
347
|
-
});
|
|
348
|
-
Object.defineProperty(exports, "unknown", {
|
|
349
|
-
enumerable: true,
|
|
350
|
-
get: function get() {
|
|
351
|
-
return _constants.unknown;
|
|
352
|
-
}
|
|
353
|
-
});
|
|
354
|
-
Object.defineProperty(exports, "url", {
|
|
355
|
-
enumerable: true,
|
|
356
|
-
get: function get() {
|
|
357
|
-
return _string.url;
|
|
358
|
-
}
|
|
359
|
-
});
|
|
360
|
-
|
|
361
|
-
var _guard = require("./guard");
|
|
362
|
-
|
|
363
|
-
var _utils = require("./utils");
|
|
364
|
-
|
|
365
|
-
var _array = require("./array");
|
|
366
|
-
|
|
367
|
-
var _boolean = require("./boolean");
|
|
368
|
-
|
|
369
|
-
var _constants = require("./constants");
|
|
370
|
-
|
|
371
|
-
var _date = require("./date");
|
|
372
|
-
|
|
373
|
-
var _describe = require("./describe");
|
|
374
|
-
|
|
375
|
-
var _dispatch = require("./dispatch");
|
|
376
|
-
|
|
377
|
-
var _either = require("./either");
|
|
378
|
-
|
|
379
|
-
var _fail = require("./fail");
|
|
380
|
-
|
|
381
|
-
var _instanceOf = require("./instanceOf");
|
|
382
|
-
|
|
383
|
-
var _json = require("./json");
|
|
384
|
-
|
|
385
|
-
var _lazy = require("./lazy");
|
|
386
|
-
|
|
387
|
-
var _mapping = require("./mapping");
|
|
388
|
-
|
|
389
|
-
var _number = require("./number");
|
|
390
|
-
|
|
391
|
-
var _object = require("./object");
|
|
392
|
-
|
|
393
|
-
var _optional = require("./optional");
|
|
394
|
-
|
|
395
|
-
var _string = require("./string");
|
|
396
|
-
|
|
397
|
-
var _tuple = require("./tuple");
|
package/instanceOf.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.instanceOf = instanceOf;
|
|
7
|
-
|
|
8
|
-
var _debrief = require("debrief");
|
|
9
|
-
|
|
10
|
-
var _Result = require("lemons/Result");
|
|
11
|
-
|
|
12
|
-
function instanceOf(klass) {
|
|
13
|
-
return function (blob) {
|
|
14
|
-
return blob instanceof klass ? (0, _Result.Ok)(blob) : (0, _Result.Err)((0, _debrief.annotate)(blob, "Must be ".concat( // $FlowFixMe[incompatible-use] - klass.name is fine?
|
|
15
|
-
klass.name, " instance")));
|
|
16
|
-
};
|
|
17
|
-
}
|