typebox 1.1.31 → 1.1.33
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/build/guard/guard.d.mts +4 -0
- package/build/guard/guard.mjs +6 -0
- package/build/system/locale/_config.d.mts +1 -1
- package/build/system/locale/ar_001.d.mts +1 -1
- package/build/system/locale/bn_BD.d.mts +1 -1
- package/build/system/locale/cs_CZ.d.mts +1 -1
- package/build/system/locale/de_DE.d.mts +1 -1
- package/build/system/locale/el_GR.d.mts +1 -1
- package/build/system/locale/en_US.d.mts +1 -1
- package/build/system/locale/es_419.d.mts +1 -1
- package/build/system/locale/es_AR.d.mts +1 -1
- package/build/system/locale/es_ES.d.mts +1 -1
- package/build/system/locale/es_MX.d.mts +1 -1
- package/build/system/locale/fa_IR.d.mts +1 -1
- package/build/system/locale/fil_PH.d.mts +1 -1
- package/build/system/locale/fr_CA.d.mts +1 -1
- package/build/system/locale/fr_FR.d.mts +1 -1
- package/build/system/locale/ha_NG.d.mts +1 -1
- package/build/system/locale/hi_IN.d.mts +1 -1
- package/build/system/locale/hu_HU.d.mts +1 -1
- package/build/system/locale/id_ID.d.mts +1 -1
- package/build/system/locale/it_IT.d.mts +1 -1
- package/build/system/locale/ja_JP.d.mts +1 -1
- package/build/system/locale/ko_KR.d.mts +1 -1
- package/build/system/locale/ms_MY.d.mts +1 -1
- package/build/system/locale/nl_NL.d.mts +1 -1
- package/build/system/locale/pl_PL.d.mts +1 -1
- package/build/system/locale/pt_BR.d.mts +1 -1
- package/build/system/locale/pt_PT.d.mts +1 -1
- package/build/system/locale/ro_RO.d.mts +1 -1
- package/build/system/locale/ru_RU.d.mts +1 -1
- package/build/system/locale/sv_SE.d.mts +1 -1
- package/build/system/locale/sw_TZ.d.mts +1 -1
- package/build/system/locale/th_TH.d.mts +1 -1
- package/build/system/locale/tr_TR.d.mts +1 -1
- package/build/system/locale/uk_UA.d.mts +1 -1
- package/build/system/locale/ur_PK.d.mts +1 -1
- package/build/system/locale/vi_VN.d.mts +1 -1
- package/build/system/locale/yo_NG.d.mts +1 -1
- package/build/system/locale/zh_Hans.d.mts +1 -1
- package/build/system/locale/zh_Hant.d.mts +1 -1
- package/build/type/engine/call/distribute-arguments.mjs +1 -7
- package/build/type/engine/call/resolve-arguments.mjs +3 -9
- package/build/type/engine/cyclic/candidates.d.mts +1 -1
- package/build/type/engine/cyclic/check.mjs +4 -7
- package/build/type/engine/evaluate/distribute.mjs +7 -17
- package/build/type/engine/evaluate/flatten.d.mts +1 -1
- package/build/type/engine/evaluate/narrow.d.mts +3 -3
- package/build/type/engine/indexable/from-literal.d.mts +1 -1
- package/build/type/engine/indexable/from-type.d.mts +6 -6
- package/build/type/engine/instantiate.d.mts +2 -2
- package/build/type/engine/instantiate.mjs +5 -9
- package/build/type/engine/object/from-union.mjs +3 -10
- package/build/type/engine/ref/instantiate.d.mts +1 -1
- package/build/type/engine/template-literal/decode.d.mts +2 -2
- package/build/type/engine/template-literal/decode.mjs +4 -10
- package/build/type/engine/template-literal/encode.d.mts +1 -1
- package/build/type/engine/template-literal/encode.mjs +3 -9
- package/build/type/engine/template-literal/is-finite.mjs +3 -7
- package/build/type/engine/this/expand-this.mjs +6 -6
- package/build/type/extends/extends-right.mjs +3 -2
- package/build/type/extends/inference.mjs +1 -1
- package/build/type/extends/literal.d.mts +1 -1
- package/build/type/extends/literal.mjs +1 -1
- package/build/type/extends/parameters.mjs +3 -2
- package/build/type/extends/result.d.mts +1 -4
- package/build/type/extends/result.mjs +0 -3
- package/build/type/extends/tuple.mjs +3 -3
- package/build/type/extends/union.mjs +3 -2
- package/build/type/script/token/internal/guard.d.mts +1 -1
- package/build/type/script/token/internal/guard.mjs +1 -1
- package/build/type/script/token/internal/take.mjs +5 -9
- package/build/type/script/token/until.mjs +4 -7
- package/build/type/types/array.d.mts +2 -1
- package/build/type/types/array.mjs +2 -1
- package/build/type/types/function.mjs +1 -1
- package/build/type/types/object.mjs +1 -1
- package/build/value/clean/from-cyclic.d.mts +1 -1
- package/build/value/convert/from-literal.d.mts +1 -1
- package/build/value/convert/try/try-bigint.d.mts +1 -1
- package/build/value/convert/try/try-boolean.d.mts +1 -1
- package/build/value/convert/try/try-null.d.mts +1 -1
- package/build/value/convert/try/try-number.d.mts +1 -1
- package/build/value/convert/try/try-string.d.mts +1 -1
- package/build/value/convert/try/try-undefined.d.mts +1 -1
- package/build/value/default/from-intersect.d.mts +1 -1
- package/package.json +30 -30
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// deno-fmt-ignore-file
|
|
2
|
-
import {
|
|
2
|
+
import { Guard } from '../../../guard/index.mjs';
|
|
3
3
|
import { IsEnum } from '../../types/enum.mjs';
|
|
4
4
|
import { Literal, IsLiteral } from '../../types/literal.mjs';
|
|
5
5
|
import { Union, IsUnion } from '../../types/union.mjs';
|
|
@@ -50,10 +50,7 @@ function EncodeEnum(types, right, pattern) {
|
|
|
50
50
|
return EncodeUnion(variants, right, pattern);
|
|
51
51
|
}
|
|
52
52
|
function EncodeUnion(types, right, pattern, result = []) {
|
|
53
|
-
|
|
54
|
-
return (IsSchema(head)
|
|
55
|
-
? EncodeUnion(tail, right, pattern, [...result, EncodeType(head, [], '')])
|
|
56
|
-
: EncodeTypes(right, `${pattern}(${JoinString(result)})`));
|
|
53
|
+
return Guard.TakeLeft(types, (head, tail) => EncodeUnion(tail, right, pattern, [...result, EncodeType(head, [], '')]), () => EncodeTypes(right, `${pattern}(${JoinString(result)})`));
|
|
57
54
|
}
|
|
58
55
|
function EncodeType(type, right, pattern) {
|
|
59
56
|
return (IsEnum(type) ? EncodeEnum(type.enum, right, pattern) :
|
|
@@ -69,10 +66,7 @@ function EncodeType(type, right, pattern) {
|
|
|
69
66
|
NeverPattern);
|
|
70
67
|
}
|
|
71
68
|
function EncodeTypes(types, pattern) {
|
|
72
|
-
|
|
73
|
-
return (IsSchema(left)
|
|
74
|
-
? EncodeType(left, right, pattern)
|
|
75
|
-
: pattern);
|
|
69
|
+
return Guard.TakeLeft(types, (left, right) => EncodeType(left, right, pattern), () => pattern);
|
|
76
70
|
}
|
|
77
71
|
function EncodePattern(types) {
|
|
78
72
|
const encoded = EncodeTypes(types, '');
|
|
@@ -1,18 +1,14 @@
|
|
|
1
1
|
// deno-fmt-ignore-file
|
|
2
2
|
import { Guard } from '../../../guard/index.mjs';
|
|
3
|
-
import { IsSchema } from '../../types/schema.mjs';
|
|
4
3
|
import { IsLiteral } from '../../types/literal.mjs';
|
|
5
4
|
import { IsUnion } from '../../types/union.mjs';
|
|
6
5
|
function FromLiteral(_value) {
|
|
7
6
|
return true;
|
|
8
7
|
}
|
|
9
8
|
function FromTypesReduce(types) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
? FromTypesReduce(right)
|
|
14
|
-
: false
|
|
15
|
-
: true);
|
|
9
|
+
return Guard.TakeLeft(types, (left, right) => FromType(left)
|
|
10
|
+
? FromTypesReduce(right)
|
|
11
|
+
: false, () => true);
|
|
16
12
|
}
|
|
17
13
|
function FromTypes(types) {
|
|
18
14
|
const result = Guard.IsEqual(types.length, 0) ? false : FromTypesReduce(types);
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
// deno-fmt-ignore-file
|
|
2
|
-
import { IsArray,
|
|
2
|
+
import { IsArray, _Array_ } from '../../types/array.mjs';
|
|
3
3
|
import { IsAsyncIterator, AsyncIterator } from '../../types/async-iterator.mjs';
|
|
4
4
|
import { IsConstructor, Constructor } from '../../types/constructor.mjs';
|
|
5
|
-
import { IsFunction,
|
|
5
|
+
import { IsFunction, _Function_ } from '../../types/function.mjs';
|
|
6
6
|
import { IsIterator, Iterator } from '../../types/iterator.mjs';
|
|
7
7
|
import { IsIntersect, Intersect } from '../../types/intersect.mjs';
|
|
8
|
-
import {
|
|
8
|
+
import { _Object_ } from '../../types/object.mjs';
|
|
9
9
|
import { IsPromise, Promise } from '../../types/promise.mjs';
|
|
10
10
|
import { IsTuple, Tuple } from '../../types/tuple.mjs';
|
|
11
11
|
import { IsThis } from '../../types/this.mjs';
|
|
@@ -14,16 +14,16 @@ function FromTypes(properties, types) {
|
|
|
14
14
|
return types.map(type => FromType(properties, type));
|
|
15
15
|
}
|
|
16
16
|
export function FromType(properties, type) {
|
|
17
|
-
return (IsArray(type) ?
|
|
17
|
+
return (IsArray(type) ? _Array_(FromType(properties, type.items)) :
|
|
18
18
|
IsAsyncIterator(type) ? AsyncIterator(FromType(properties, type.iteratorItems)) :
|
|
19
19
|
IsConstructor(type) ? Constructor(FromTypes(properties, type.parameters), FromType(properties, type.instanceType)) :
|
|
20
|
-
IsFunction(type) ?
|
|
20
|
+
IsFunction(type) ? _Function_(FromTypes(properties, type.parameters), FromType(properties, type.returnType)) :
|
|
21
21
|
IsIterator(type) ? Iterator(FromType(properties, type.iteratorItems)) :
|
|
22
22
|
IsPromise(type) ? Promise(FromType(properties, type.item)) :
|
|
23
23
|
IsTuple(type) ? Tuple(FromTypes(properties, type.items)) :
|
|
24
24
|
IsUnion(type) ? Union(FromTypes(properties, type.anyOf)) :
|
|
25
25
|
IsIntersect(type) ? Intersect(FromTypes(properties, type.allOf)) :
|
|
26
|
-
IsThis(type) ?
|
|
26
|
+
IsThis(type) ? _Object_(properties) :
|
|
27
27
|
type);
|
|
28
28
|
}
|
|
29
29
|
export function ExpandThis(properties, type) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// deno-fmt-ignore-file
|
|
2
|
+
import { Guard } from '../../guard/index.mjs';
|
|
2
3
|
import { Memory } from '../../system/memory/index.mjs';
|
|
3
4
|
import { IsAny } from '../types/any.mjs';
|
|
4
5
|
import { IsEnum } from '../types/enum.mjs';
|
|
@@ -22,14 +23,14 @@ function ExtendsRightEnum(inferred, left, right) {
|
|
|
22
23
|
return ExtendsLeft(inferred, left, union);
|
|
23
24
|
}
|
|
24
25
|
function ExtendsRightIntersect(inferred, left, right) {
|
|
25
|
-
return
|
|
26
|
+
return Guard.TakeLeft(right, (head, tail) => Result.Match(ExtendsLeft(inferred, left, head), inferred => ExtendsRightIntersect(inferred, left, tail), () => Result.ExtendsFalse()), () => Result.ExtendsTrue(inferred));
|
|
26
27
|
}
|
|
27
28
|
function ExtendsRightTemplateLiteral(inferred, left, right) {
|
|
28
29
|
const decoded = TemplateLiteralDecode(right);
|
|
29
30
|
return ExtendsLeft(inferred, left, decoded);
|
|
30
31
|
}
|
|
31
32
|
function ExtendsRightUnion(inferred, left, right) {
|
|
32
|
-
return
|
|
33
|
+
return Guard.TakeLeft(right, (head, tail) => Result.Match(ExtendsLeft(inferred, left, head), inferred => Result.ExtendsTrue(inferred), () => ExtendsRightUnion(inferred, left, tail)), () => Result.ExtendsFalse());
|
|
33
34
|
}
|
|
34
35
|
export function ExtendsRight(inferred, left, right) {
|
|
35
36
|
return (IsAny(right) ? ExtendsRightAny(inferred, left) :
|
|
@@ -46,7 +46,7 @@ export function TryInferable(type) {
|
|
|
46
46
|
undefined);
|
|
47
47
|
}
|
|
48
48
|
function TryInferResults(rest, right, result = []) {
|
|
49
|
-
return
|
|
49
|
+
return Guard.TakeLeft(rest, (head, tail) => Result.Match(ExtendsLeft({}, head, right), () => TryInferResults(tail, right, [...result, head]), () => undefined), () => result);
|
|
50
50
|
}
|
|
51
51
|
export function InferTupleResult(inferred, name, left, right) {
|
|
52
52
|
const results = TryInferResults(left, right);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TUnreachable } from '../../system/unreachable/unreachable.mjs';
|
|
1
|
+
import { type TUnreachable } from '../../system/unreachable/unreachable.mjs';
|
|
2
2
|
import { type TSchema } from '../types/schema.mjs';
|
|
3
3
|
import { type TProperties } from '../types/properties.mjs';
|
|
4
4
|
import { type TLiteral, type TLiteralValue } from '../types/literal.mjs';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// deno-fmt-ignore-file
|
|
2
|
-
import { Unreachable } from '../../system/unreachable/unreachable.mjs';
|
|
3
2
|
import { Guard } from '../../guard/index.mjs';
|
|
3
|
+
import { Unreachable } from '../../system/unreachable/unreachable.mjs';
|
|
4
4
|
import { IsLiteral, Literal } from '../types/literal.mjs';
|
|
5
5
|
import { IsBigInt } from '../types/bigint.mjs';
|
|
6
6
|
import { IsBoolean } from '../types/boolean.mjs';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// deno-fmt-ignore-file
|
|
2
|
+
import { Guard } from '../../guard/index.mjs';
|
|
2
3
|
import { IsInfer } from '../types/infer.mjs';
|
|
3
4
|
import { IsOptional } from '../types/_optional.mjs';
|
|
4
5
|
import { ExtendsLeft } from './extends-left.mjs';
|
|
@@ -15,12 +16,12 @@ function ParameterCompare(inferred, left, leftRest, right, rightRest) {
|
|
|
15
16
|
);
|
|
16
17
|
}
|
|
17
18
|
function ParameterRight(inferred, left, leftRest, rightRest) {
|
|
18
|
-
return
|
|
19
|
+
return Guard.TakeLeft(rightRest, (head, tail) => ParameterCompare(inferred, left, leftRest, head, tail), () => IsOptional(left) // 'right-did-not-have-enough-elements'
|
|
19
20
|
? Result.ExtendsTrue(inferred) // 'ok: left was optional'
|
|
20
21
|
: Result.ExtendsFalse()); // 'fail: left was required'
|
|
21
22
|
}
|
|
22
23
|
function ParametersLeft(inferred, left, rightRest) {
|
|
23
|
-
return
|
|
24
|
+
return Guard.TakeLeft(left, (head, tail) => ParameterRight(inferred, head, tail, rightRest), () => Result.ExtendsTrue(inferred)); // 'ok: no-more-elements-in-left'
|
|
24
25
|
}
|
|
25
26
|
export function ExtendsParameters(inferred, left, right) {
|
|
26
27
|
return ParametersLeft(inferred, left, right);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TProperties } from '../types/properties.mjs';
|
|
1
|
+
import { type TProperties } from '../types/properties.mjs';
|
|
2
2
|
export type TResult = TExtendsUnion | TExtendsTrue | TExtendsFalse;
|
|
3
3
|
export interface TExtendsUnion<Inferred extends TProperties = TProperties> {
|
|
4
4
|
'~kind': 'ExtendsUnion';
|
|
@@ -22,6 +22,3 @@ export declare function IsExtendsTrueLike(value: unknown): value is TExtendsTrue
|
|
|
22
22
|
export type MatchTrueLike = (inferred: TProperties) => unknown;
|
|
23
23
|
export type MatchFalse = () => unknown;
|
|
24
24
|
export declare function Match(result: TResult, true_: MatchTrueLike, false_: MatchFalse): unknown;
|
|
25
|
-
export type TakeLeftTrue<T> = (left: T, right: T[]) => unknown;
|
|
26
|
-
export type TakeLeftFalse = () => unknown;
|
|
27
|
-
export declare function TakeLeft<T>(array: T[], true_: TakeLeftTrue<T>, false_: TakeLeftFalse): unknown;
|
|
@@ -34,6 +34,3 @@ export function IsExtendsTrueLike(value) {
|
|
|
34
34
|
export function Match(result, true_, false_) {
|
|
35
35
|
return IsExtendsTrueLike(result) ? true_(result.inferred) : false_();
|
|
36
36
|
}
|
|
37
|
-
export function TakeLeft(array, true_, false_) {
|
|
38
|
-
return Guard.IsEqual(array.length, 0) ? false_() : true_(array[0], array.slice(1));
|
|
39
|
-
}
|
|
@@ -31,10 +31,10 @@ function ElementsLeft(inferred, reversed, leftRest, right, rightRest) {
|
|
|
31
31
|
// Rest Inferrable Right Means we delegate to TInferTupleResult to Generate a Result
|
|
32
32
|
IsInferable(inferable)
|
|
33
33
|
? InferTupleResult(inferred, inferable['name'], ApplyReverse(leftRest, reversed), inferable['type'])
|
|
34
|
-
:
|
|
34
|
+
: Guard.TakeLeft(leftRest, (head, tail) => ElementsCompare(inferred, reversed, head, tail, right, rightRest), () => Result.ExtendsFalse()));
|
|
35
35
|
}
|
|
36
36
|
function ElementsRight(inferred, reversed, leftRest, rightRest) {
|
|
37
|
-
return
|
|
37
|
+
return Guard.TakeLeft(rightRest, (head, tail) => ElementsLeft(inferred, reversed, leftRest, head, tail), () => Guard.IsEqual(leftRest.length, 0)
|
|
38
38
|
? Result.ExtendsTrue(inferred) // 'Ok: right-empty-and-left-empty'
|
|
39
39
|
: Result.ExtendsFalse()); // 'Fail: right-empty-and-left-not-empty'
|
|
40
40
|
}
|
|
@@ -50,7 +50,7 @@ function ExtendsTupleToArray(inferred, left, right) {
|
|
|
50
50
|
const inferrable = TryInferable(right);
|
|
51
51
|
return (IsInferable(inferrable)
|
|
52
52
|
? InferUnionResult(inferred, inferrable['name'], left, inferrable['type'])
|
|
53
|
-
:
|
|
53
|
+
: Guard.TakeLeft(left, (head, tail) => Result.Match(ExtendsLeft(inferred, head, right), inferred => ExtendsTupleToArray(inferred, tail, right), () => Result.ExtendsFalse()), () => Result.ExtendsTrue(inferred)));
|
|
54
54
|
}
|
|
55
55
|
export function ExtendsTuple(inferred, left, right) {
|
|
56
56
|
const instantiatedLeft = InstantiateElements(inferred, { callstack: [] }, left);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// deno-fmt-ignore-file
|
|
2
|
+
import { Guard } from '../../guard/index.mjs';
|
|
2
3
|
import { IsUnion } from '../types/union.mjs';
|
|
3
4
|
import { ExtendsLeft } from './extends-left.mjs';
|
|
4
5
|
import * as Result from './result.mjs';
|
|
@@ -7,10 +8,10 @@ import * as Result from './result.mjs';
|
|
|
7
8
|
// ----------------------------------------------------------------------------
|
|
8
9
|
import { IsInferable, TryInferable, InferUnionResult } from './inference.mjs';
|
|
9
10
|
function ExtendsUnionSome(inferred, type, unionTypes) {
|
|
10
|
-
return
|
|
11
|
+
return Guard.TakeLeft(unionTypes, (head, tail) => Result.Match(ExtendsLeft(inferred, type, head), inferred => Result.ExtendsTrue(inferred), () => ExtendsUnionSome(inferred, type, tail)), () => Result.ExtendsFalse());
|
|
11
12
|
}
|
|
12
13
|
function ExtendsUnionLeft(inferred, left, right) {
|
|
13
|
-
return
|
|
14
|
+
return Guard.TakeLeft(left, (head, tail) => Result.Match(ExtendsUnionSome(inferred, head, right), inferred => ExtendsUnionLeft(inferred, tail, right), () => Result.ExtendsFalse()), () => Result.ExtendsTrue(inferred));
|
|
14
15
|
}
|
|
15
16
|
export function ExtendsUnion(inferred, left, right) {
|
|
16
17
|
const inferrable = TryInferable(right);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { IsArray, IsEqual, IsString } from '../../../../guard/guard.mjs';
|
|
1
|
+
export { IsArray, IsEqual, IsString, TakeLeft } from '../../../../guard/guard.mjs';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// deno-coverage-ignore-start - parsebox tested
|
|
2
|
-
export { IsArray, IsEqual, IsString } from '../../../../guard/guard.mjs';
|
|
2
|
+
export { IsArray, IsEqual, IsString, TakeLeft } from '../../../../guard/guard.mjs';
|
|
3
3
|
// ------------------------------------------------------------------
|
|
4
4
|
// Internal Guards to ensure Token is portable.
|
|
5
5
|
// ------------------------------------------------------------------
|
|
@@ -12,15 +12,11 @@ export function Take(variants, input) {
|
|
|
12
12
|
// ----------------------------------------------------------------
|
|
13
13
|
// Symmetric
|
|
14
14
|
// ----------------------------------------------------------------
|
|
15
|
-
//
|
|
16
|
-
//
|
|
17
|
-
//
|
|
18
|
-
//
|
|
19
|
-
//
|
|
20
|
-
// return IsEqual(result.length, 2) ? result : Take(right, input)
|
|
21
|
-
// })()
|
|
22
|
-
// : []
|
|
23
|
-
// ) as never
|
|
15
|
+
// return Guard.TakeLeft(variants, (valueLeft, valueRight) =>
|
|
16
|
+
// Match(TakeVariant(valueLeft, input), (take, rest) =>
|
|
17
|
+
// [take, rest],
|
|
18
|
+
// () => Take(valueRight, input)),
|
|
19
|
+
// () => []) as never
|
|
24
20
|
// ----------------------------------------------------------------
|
|
25
21
|
// Inline
|
|
26
22
|
// ----------------------------------------------------------------
|
|
@@ -1,18 +1,15 @@
|
|
|
1
1
|
// deno-coverage-ignore-start - parsebox tested
|
|
2
2
|
// deno-fmt-ignore-file
|
|
3
3
|
import { Match } from './internal/match.mjs';
|
|
4
|
-
import { IsEqual,
|
|
4
|
+
import { IsEqual, TakeLeft } from './internal/guard.mjs';
|
|
5
5
|
function TakeOne(input) {
|
|
6
6
|
const result = IsEqual(input, '') ? [] : [input.slice(0, 1), input.slice(1)];
|
|
7
7
|
return result;
|
|
8
8
|
}
|
|
9
9
|
function IsInputMatchSentinal(end, input) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
? true
|
|
14
|
-
: IsInputMatchSentinal(right, input)
|
|
15
|
-
: false);
|
|
10
|
+
return TakeLeft(end, (left, right) => input.startsWith(left)
|
|
11
|
+
? true
|
|
12
|
+
: IsInputMatchSentinal(right, input), () => false);
|
|
16
13
|
}
|
|
17
14
|
/** Match Input until but not including End. No match if End not found. */
|
|
18
15
|
export function Until(end, input, result = '') {
|
|
@@ -10,7 +10,8 @@ export interface TArray<Type extends TSchema = TSchema> extends TSchema {
|
|
|
10
10
|
items: Type;
|
|
11
11
|
}
|
|
12
12
|
/** Creates an Array type. */
|
|
13
|
-
export declare function
|
|
13
|
+
export declare function _Array_<Type extends TSchema>(items: Type, options?: TArrayOptions): TArray<Type>;
|
|
14
|
+
export { _Array_ as Array };
|
|
14
15
|
/** Returns true if the given value is a TArray. */
|
|
15
16
|
export declare function IsArray(value: unknown): value is TArray;
|
|
16
17
|
/** Extracts options from a TArray. */
|
|
@@ -5,9 +5,10 @@ import { IsKind } from './schema.mjs';
|
|
|
5
5
|
// Factory
|
|
6
6
|
// ------------------------------------------------------------------
|
|
7
7
|
/** Creates an Array type. */
|
|
8
|
-
export function
|
|
8
|
+
export function _Array_(items, options) {
|
|
9
9
|
return Memory.Create({ '~kind': 'Array' }, { type: 'array', items }, options);
|
|
10
10
|
}
|
|
11
|
+
export { _Array_ as Array }; // Prevent Collision With Global Scope
|
|
11
12
|
// ------------------------------------------------------------------
|
|
12
13
|
// Guard
|
|
13
14
|
// ------------------------------------------------------------------
|
|
@@ -8,7 +8,7 @@ import { IsKind } from './schema.mjs';
|
|
|
8
8
|
export function _Function_(parameters, returnType, options = {}) {
|
|
9
9
|
return Memory.Create({ ['~kind']: 'Function' }, { type: 'function', parameters, returnType }, options);
|
|
10
10
|
}
|
|
11
|
-
export { _Function_ as Function };
|
|
11
|
+
export { _Function_ as Function }; // Prevent Collision With Global Scope
|
|
12
12
|
// ------------------------------------------------------------------
|
|
13
13
|
// Guard
|
|
14
14
|
// ------------------------------------------------------------------
|
|
@@ -11,7 +11,7 @@ export function _Object_(properties, options = {}) {
|
|
|
11
11
|
const required = requiredKeys.length > 0 ? { required: requiredKeys } : {};
|
|
12
12
|
return Memory.Create({ '~kind': 'Object' }, { type: 'object', ...required, properties }, options);
|
|
13
13
|
}
|
|
14
|
-
export { _Object_ as Object }; //
|
|
14
|
+
export { _Object_ as Object }; // Prevent Collision With Global Scope
|
|
15
15
|
// ------------------------------------------------------------------
|
|
16
16
|
// Guard
|
|
17
17
|
// ------------------------------------------------------------------
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { type TProperties, TCyclic } from '../../type/index.mjs';
|
|
1
|
+
import { type TProperties, type TCyclic } from '../../type/index.mjs';
|
|
2
2
|
export declare function FromCyclic(context: TProperties, type: TCyclic, value: unknown): unknown;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { TLiteral, TProperties } from '../../type/index.mjs';
|
|
1
|
+
import { type TLiteral, type TProperties } from '../../type/index.mjs';
|
|
2
2
|
export declare function FromLiteral(context: TProperties, type: TLiteral, value: unknown): unknown;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { TResult } from './try-result.mjs';
|
|
1
|
+
import { type TResult } from './try-result.mjs';
|
|
2
2
|
export declare function TryBigInt(value: unknown): TResult<bigint>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { TResult } from './try-result.mjs';
|
|
1
|
+
import { type TResult } from './try-result.mjs';
|
|
2
2
|
export declare function TryBoolean(value: unknown): TResult<boolean>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { TResult } from './try-result.mjs';
|
|
1
|
+
import { type TResult } from './try-result.mjs';
|
|
2
2
|
export declare function TryNull(value: unknown): TResult<null>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { TResult } from './try-result.mjs';
|
|
1
|
+
import { type TResult } from './try-result.mjs';
|
|
2
2
|
export declare function TryNumber(value: unknown): TResult<number>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { TResult } from './try-result.mjs';
|
|
1
|
+
import { type TResult } from './try-result.mjs';
|
|
2
2
|
export declare function TryString(value: unknown): TResult;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { TResult } from './try-result.mjs';
|
|
1
|
+
import { type TResult } from './try-result.mjs';
|
|
2
2
|
export declare function TryUndefined(value: unknown): TResult<undefined>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { TProperties, TIntersect } from '../../type/index.mjs';
|
|
1
|
+
import { type TProperties, type TIntersect } from '../../type/index.mjs';
|
|
2
2
|
export declare function FromIntersect(context: TProperties, type: TIntersect, value: unknown): unknown;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "typebox",
|
|
3
3
|
"description": "Json Schema Type Builder with Static Type Resolution for TypeScript",
|
|
4
|
-
"version": "1.1.
|
|
4
|
+
"version": "1.1.33",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
7
7
|
"jsonschema"
|
|
@@ -16,37 +16,37 @@
|
|
|
16
16
|
"types": "./build/index.d.mts",
|
|
17
17
|
"module": "./build/index.mjs",
|
|
18
18
|
"exports": {
|
|
19
|
-
"./value": {
|
|
20
|
-
"import": "./build/value/index.mjs",
|
|
21
|
-
"default": "./build/value/index.mjs"
|
|
22
|
-
},
|
|
23
19
|
"./guard": {
|
|
24
20
|
"import": "./build/guard/index.mjs",
|
|
25
21
|
"default": "./build/guard/index.mjs"
|
|
26
22
|
},
|
|
27
|
-
"./
|
|
28
|
-
"import": "./build/
|
|
29
|
-
"default": "./build/
|
|
23
|
+
"./error": {
|
|
24
|
+
"import": "./build/error/index.mjs",
|
|
25
|
+
"default": "./build/error/index.mjs"
|
|
26
|
+
},
|
|
27
|
+
"./compile": {
|
|
28
|
+
"import": "./build/compile/index.mjs",
|
|
29
|
+
"default": "./build/compile/index.mjs"
|
|
30
30
|
},
|
|
31
31
|
"./system": {
|
|
32
32
|
"import": "./build/system/index.mjs",
|
|
33
33
|
"default": "./build/system/index.mjs"
|
|
34
34
|
},
|
|
35
|
+
"./format": {
|
|
36
|
+
"import": "./build/format/index.mjs",
|
|
37
|
+
"default": "./build/format/index.mjs"
|
|
38
|
+
},
|
|
35
39
|
"./type": {
|
|
36
40
|
"import": "./build/type/index.mjs",
|
|
37
41
|
"default": "./build/type/index.mjs"
|
|
38
42
|
},
|
|
39
|
-
"./
|
|
40
|
-
"import": "./build/
|
|
41
|
-
"default": "./build/
|
|
42
|
-
},
|
|
43
|
-
"./error": {
|
|
44
|
-
"import": "./build/error/index.mjs",
|
|
45
|
-
"default": "./build/error/index.mjs"
|
|
43
|
+
"./schema": {
|
|
44
|
+
"import": "./build/schema/index.mjs",
|
|
45
|
+
"default": "./build/schema/index.mjs"
|
|
46
46
|
},
|
|
47
|
-
"./
|
|
48
|
-
"import": "./build/
|
|
49
|
-
"default": "./build/
|
|
47
|
+
"./value": {
|
|
48
|
+
"import": "./build/value/index.mjs",
|
|
49
|
+
"default": "./build/value/index.mjs"
|
|
50
50
|
},
|
|
51
51
|
".": {
|
|
52
52
|
"import": "./build/index.mjs",
|
|
@@ -55,29 +55,29 @@
|
|
|
55
55
|
},
|
|
56
56
|
"typesVersions": {
|
|
57
57
|
"*": {
|
|
58
|
-
"value": [
|
|
59
|
-
"./build/value/index.d.mts"
|
|
60
|
-
],
|
|
61
58
|
"guard": [
|
|
62
59
|
"./build/guard/index.d.mts"
|
|
63
60
|
],
|
|
64
|
-
"
|
|
65
|
-
"./build/
|
|
61
|
+
"error": [
|
|
62
|
+
"./build/error/index.d.mts"
|
|
63
|
+
],
|
|
64
|
+
"compile": [
|
|
65
|
+
"./build/compile/index.d.mts"
|
|
66
66
|
],
|
|
67
67
|
"system": [
|
|
68
68
|
"./build/system/index.d.mts"
|
|
69
69
|
],
|
|
70
|
+
"format": [
|
|
71
|
+
"./build/format/index.d.mts"
|
|
72
|
+
],
|
|
70
73
|
"type": [
|
|
71
74
|
"./build/type/index.d.mts"
|
|
72
75
|
],
|
|
73
|
-
"
|
|
74
|
-
"./build/
|
|
75
|
-
],
|
|
76
|
-
"error": [
|
|
77
|
-
"./build/error/index.d.mts"
|
|
76
|
+
"schema": [
|
|
77
|
+
"./build/schema/index.d.mts"
|
|
78
78
|
],
|
|
79
|
-
"
|
|
80
|
-
"./build/
|
|
79
|
+
"value": [
|
|
80
|
+
"./build/value/index.d.mts"
|
|
81
81
|
],
|
|
82
82
|
".": [
|
|
83
83
|
"./build/index.d.mts"
|