typebox 1.1.31 → 1.1.32

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.
@@ -43,8 +43,12 @@ export declare function GraphemeCount(value: string): number;
43
43
  export declare function IsMaxLength(value: string, length: number): boolean;
44
44
  /** Returns true if the string has at least the given number of graphemes */
45
45
  export declare function IsMinLength(value: string, length: number): boolean;
46
+ /** Returns true if all elements from offset satisfy the callback, short-circuiting on the first failure */
46
47
  export declare function Every<T>(value: T[], offset: number, callback: (value: T, index: number) => boolean): boolean;
48
+ /** Returns true if all elements from offset satisfy the callback, visiting every element regardless of failure */
47
49
  export declare function EveryAll<T>(value: T[], offset: number, callback: (value: T, index: number) => boolean): boolean;
50
+ /** Takes the left-most element from an array and dispatches to the true arm, or the false arm if empty */
51
+ export declare function TakeLeft<T, True extends (left: T, right: T[]) => unknown, False extends () => unknown>(array: T[], true_: True, false_: False): ReturnType<True> | ReturnType<False>;
48
52
  /** Returns true if this value has this property key */
49
53
  export declare function HasPropertyKey<Key extends PropertyKey>(value: object, key: Key): value is {
50
54
  [_ in Key]: unknown;
@@ -145,6 +145,7 @@ export function IsMinLength(value, length) {
145
145
  // --------------------------------------------------------------------------
146
146
  // Array
147
147
  // --------------------------------------------------------------------------
148
+ /** Returns true if all elements from offset satisfy the callback, short-circuiting on the first failure */
148
149
  export function Every(value, offset, callback) {
149
150
  for (let index = offset; index < value.length; index++) {
150
151
  if (!callback(value[index], index))
@@ -152,6 +153,7 @@ export function Every(value, offset, callback) {
152
153
  }
153
154
  return true;
154
155
  }
156
+ /** Returns true if all elements from offset satisfy the callback, visiting every element regardless of failure */
155
157
  export function EveryAll(value, offset, callback) {
156
158
  let result = true;
157
159
  for (let index = offset; index < value.length; index++) {
@@ -160,6 +162,10 @@ export function EveryAll(value, offset, callback) {
160
162
  }
161
163
  return result;
162
164
  }
165
+ /** Takes the left-most element from an array and dispatches to the true arm, or the false arm if empty */
166
+ export function TakeLeft(array, true_, false_) {
167
+ return (IsEqual(array.length, 0) ? false_() : true_(array[0], array.slice(1)));
168
+ }
163
169
  // --------------------------------------------------------------------------
164
170
  // Object
165
171
  // --------------------------------------------------------------------------
@@ -1,6 +1,6 @@
1
1
  // deno-fmt-ignore-file
2
+ import { Guard } from '../../../guard/index.mjs';
2
3
  import { Memory } from '../../../system/memory/index.mjs';
3
- import { IsSchema } from '../../types/schema.mjs';
4
4
  import { InstantiateType } from '../instantiate.mjs';
5
5
  import { Extends, ExtendsResult } from '../../extends/index.mjs';
6
6
  import { IsInfer } from '../../types/infer.mjs';
@@ -23,16 +23,10 @@ function BindArgument(context, state, name, extends_, type) {
23
23
  function BindArguments(context, state, parameterLeft, parameterRight, arguments_) {
24
24
  const instantiatedExtends = InstantiateType(context, state, parameterLeft.extends);
25
25
  const instantiatedEquals = InstantiateType(context, state, parameterLeft.equals);
26
- const [left, ...right] = arguments_;
27
- return (IsSchema(left)
28
- ? BindParameters(BindArgument(context, state, parameterLeft['name'], instantiatedExtends, left), state, parameterRight, right)
29
- : BindParameters(BindArgument(context, state, parameterLeft['name'], instantiatedExtends, instantiatedEquals), state, parameterRight, []));
26
+ return Guard.TakeLeft(arguments_, (left, right) => BindParameters(BindArgument(context, state, parameterLeft['name'], instantiatedExtends, left), state, parameterRight, right), () => BindParameters(BindArgument(context, state, parameterLeft['name'], instantiatedExtends, instantiatedEquals), state, parameterRight, []));
30
27
  }
31
28
  function BindParameters(context, state, parameters, arguments_) {
32
- const [left, ...right] = parameters;
33
- return (IsSchema(left)
34
- ? BindArguments(context, state, left, right, arguments_)
35
- : context);
29
+ return Guard.TakeLeft(parameters, (left, right) => BindArguments(context, state, left, right, arguments_), () => context);
36
30
  }
37
31
  export function ResolveArgumentsContext(context, state, parameters, arguments_) {
38
32
  return BindParameters(context, state, parameters, arguments_);
@@ -1,5 +1,5 @@
1
1
  // deno-fmt-ignore-file
2
- import { IsSchema } from '../../types/schema.mjs';
2
+ import { Guard } from '../../../guard/index.mjs';
3
3
  import { IsArray } from '../../types/array.mjs';
4
4
  import { IsAsyncIterator } from '../../types/async-iterator.mjs';
5
5
  import { IsConstructor } from '../../types/constructor.mjs';
@@ -24,12 +24,9 @@ function FromProperties(stack, context, properties) {
24
24
  return FromTypes(stack, context, types);
25
25
  }
26
26
  function FromTypes(stack, context, types) {
27
- const [left, ...right] = types;
28
- return (IsSchema(left)
29
- ? FromType(stack, context, left)
30
- ? true
31
- : FromTypes(stack, context, right)
32
- : false);
27
+ return Guard.TakeLeft(types, (left, right) => FromType(stack, context, left)
28
+ ? true
29
+ : FromTypes(stack, context, right), () => false);
33
30
  }
34
31
  function FromType(stack, context, type) {
35
32
  return (IsRef(type) ? FromRef(stack, context, type.$ref) :
@@ -1,7 +1,6 @@
1
1
  // deno-fmt-ignore-file
2
2
  // deno-fmt-ignore-file
3
3
  import { Guard } from '../../../guard/index.mjs';
4
- import { IsSchema } from '../../types/schema.mjs';
5
4
  import { IsUnion } from '../../types/union.mjs';
6
5
  import { IsObject } from '../../types/object.mjs';
7
6
  import { IsTuple } from '../../types/tuple.mjs';
@@ -32,24 +31,15 @@ function DistributeOperation(left, right) {
32
31
  return result;
33
32
  }
34
33
  function DistributeType(type, types, result = []) {
35
- const [left, ...right] = types;
36
- return (!Guard.IsUndefined(left) // TSchema[]
37
- ? DistributeType(type, right, [...result, DistributeOperation(type, left)])
38
- : result.length === 0
39
- ? [type]
40
- : result);
34
+ return Guard.TakeLeft(types, (left, right) => DistributeType(type, right, [...result, DistributeOperation(type, left)]), () => Guard.IsEqual(result.length, 0)
35
+ ? [type]
36
+ : result);
41
37
  }
42
38
  function DistributeUnion(types, distribution, result = []) {
43
- const [left, ...right] = types;
44
- return (IsSchema(left)
45
- ? DistributeUnion(right, distribution, [...result, ...Distribute([left], distribution)])
46
- : result);
39
+ return Guard.TakeLeft(types, (left, right) => DistributeUnion(right, distribution, [...result, ...Distribute([left], distribution)]), () => result);
47
40
  }
48
41
  export function Distribute(types, result = []) {
49
- const [left, ...right] = types;
50
- return (IsSchema(left)
51
- ? IsUnion(left)
52
- ? Distribute(right, DistributeUnion(left.anyOf, result))
53
- : Distribute(right, DistributeType(left, result))
54
- : result);
42
+ return Guard.TakeLeft(types, (left, right) => IsUnion(left)
43
+ ? Distribute(right, DistributeUnion(left.anyOf, result))
44
+ : Distribute(right, DistributeType(left, result)), () => result);
55
45
  }
@@ -11,7 +11,6 @@ import { IsReadonly, ReadonlyAdd, ReadonlyRemove } from '../types/_readonly.mjs'
11
11
  // Types
12
12
  // ------------------------------------------------------------------
13
13
  import { IsBase } from '../types/base.mjs';
14
- import { IsSchema } from '../types/schema.mjs';
15
14
  import { Array, IsArray, ArrayOptions } from '../types/array.mjs';
16
15
  import { AsyncIterator, IsAsyncIterator, AsyncIteratorOptions } from '../types/async-iterator.mjs';
17
16
  import { Constructor, IsConstructor, ConstructorOptions } from '../types/constructor.mjs';
@@ -66,12 +65,9 @@ import { UncapitalizeInstantiate } from './intrinsics/instantiate.mjs';
66
65
  import { UppercaseInstantiate } from './intrinsics/instantiate.mjs';
67
66
  import { RestSpread } from './rest/index.mjs';
68
67
  export function CanInstantiate(types) {
69
- const [left, ...right] = types;
70
- return (IsSchema(left)
71
- ? IsRef(left)
72
- ? false
73
- : CanInstantiate(right)
74
- : true);
68
+ return Guard.TakeLeft(types, (left, right) => IsRef(left)
69
+ ? false
70
+ : CanInstantiate(right), () => true);
75
71
  }
76
72
  function ModifierActions(type, readonly, optional) {
77
73
  return (IsReadonlyRemoveAction(type) ? ModifierActions(type.type, 'remove', optional) :
@@ -1,7 +1,6 @@
1
1
  // deno-fmt-ignore-file
2
- import { Unreachable } from '../../../system/unreachable/index.mjs';
3
2
  import { Guard } from '../../../guard/index.mjs';
4
- import { IsSchema } from '../../types/schema.mjs';
3
+ import { Unreachable } from '../../../system/unreachable/index.mjs';
5
4
  import { EvaluateUnion } from '../evaluate/evaluate.mjs';
6
5
  import { FromType } from './from-type.mjs';
7
6
  function CollapseUnionProperties(left, right) {
@@ -12,15 +11,9 @@ function CollapseUnionProperties(left, right) {
12
11
  return result;
13
12
  }
14
13
  function ReduceVariants(types, result) {
15
- const [left, ...right] = types;
16
- return (IsSchema(left)
17
- ? ReduceVariants(right, CollapseUnionProperties(result, FromType(left)))
18
- : result);
14
+ return Guard.TakeLeft(types, (left, right) => ReduceVariants(right, CollapseUnionProperties(result, FromType(left))), () => result);
19
15
  }
20
16
  export function FromUnion(types) {
21
- const [left, ...right] = types;
22
- return (IsSchema(left)
23
- ? ReduceVariants(right, FromType(left))
24
- : Unreachable());
17
+ return Guard.TakeLeft(types, (left, right) => ReduceVariants(right, FromType(left)), () => Unreachable());
25
18
  }
26
19
  // deno-coverage-ignore-stop
@@ -1,6 +1,6 @@
1
1
  import { TUnreachable } from '../../../system/unreachable/index.mjs';
2
- import { type TLiteral, type TLiteralValue } from '../../types/literal.mjs';
3
2
  import { type TSchema } from '../../types/schema.mjs';
3
+ import { type TLiteral, type TLiteralValue } from '../../types/literal.mjs';
4
4
  import { type TString } from '../../types/string.mjs';
5
5
  import { type TTemplateLiteral } from '../../types/template-literal.mjs';
6
6
  import { type TUnion } from '../../types/union.mjs';
@@ -1,8 +1,7 @@
1
1
  // deno-fmt-ignore-file
2
- import { Unreachable } from '../../../system/unreachable/index.mjs';
3
2
  import { Guard } from '../../../guard/index.mjs';
3
+ import { Unreachable } from '../../../system/unreachable/index.mjs';
4
4
  import { Literal, IsLiteral } from '../../types/literal.mjs';
5
- import { IsSchema } from '../../types/schema.mjs';
6
5
  import { String } from '../../types/string.mjs';
7
6
  import { IsTemplateLiteral } from '../../types/template-literal.mjs';
8
7
  import { Union, IsUnion } from '../../types/union.mjs';
@@ -10,17 +9,13 @@ import { ParsePatternIntoTypes } from '../patterns/pattern.mjs';
10
9
  import { IsTemplateLiteralFinite } from './is-finite.mjs';
11
10
  import { TemplateLiteralCreate } from './create.mjs';
12
11
  function FromLiteralPush(variants, value, result = []) {
13
- const [left, ...right] = variants;
14
- return (Guard.IsString(left) ? FromLiteralPush(right, value, [...result, `${left}${value}`]) : result);
12
+ return Guard.TakeLeft(variants, (left, right) => FromLiteralPush(right, value, [...result, `${left}${value}`]), () => result);
15
13
  }
16
14
  function FromLiteral(variants, value) {
17
15
  return (Guard.IsEqual(variants.length, 0) ? [`${value}`] : FromLiteralPush(variants, value));
18
16
  }
19
17
  function FromUnion(variants, types, result = []) {
20
- const [left, ...right] = types;
21
- return (IsSchema(left)
22
- ? FromUnion(variants, right, [...result, ...FromType(variants, left)])
23
- : result);
18
+ return Guard.TakeLeft(types, (left, right) => FromUnion(variants, right, [...result, ...FromType(variants, left)]), () => result);
24
19
  }
25
20
  // ------------------------------------------------------------------
26
21
  // deno-coverage-ignore-start - symmetric unreachable | internal
@@ -38,8 +33,7 @@ function FromType(variants, type) {
38
33
  return result;
39
34
  }
40
35
  function DecodeFromSpan(variants, types) {
41
- const [left, ...right] = types;
42
- return (IsSchema(left) ? DecodeFromSpan(FromType(variants, left), right) : variants);
36
+ return Guard.TakeLeft(types, (left, right) => DecodeFromSpan(FromType(variants, left), right), () => variants);
43
37
  }
44
38
  function VariantsToLiterals(variants) {
45
39
  return variants.map(variant => Literal(variant));
@@ -1,5 +1,5 @@
1
1
  // deno-fmt-ignore-file
2
- import { IsSchema } from '../../types/schema.mjs';
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
- const [head, ...tail] = types;
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
- const [left, ...right] = types;
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
- const [left, ...right] = types;
11
- return (IsSchema(left)
12
- ? FromType(left)
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,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 Result.TakeLeft(right, (head, tail) => Result.Match(ExtendsLeft(inferred, left, head), inferred => ExtendsRightIntersect(inferred, left, tail), () => Result.ExtendsFalse()), () => Result.ExtendsTrue(inferred));
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 Result.TakeLeft(right, (head, tail) => Result.Match(ExtendsLeft(inferred, left, head), inferred => Result.ExtendsTrue(inferred), () => ExtendsRightUnion(inferred, left, tail)), () => Result.ExtendsFalse());
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 Result.TakeLeft(rest, (head, tail) => Result.Match(ExtendsLeft({}, head, right), () => TryInferResults(tail, right, [...result, head]), () => undefined), () => result);
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,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 Result.TakeLeft(rightRest, (head, tail) => ParameterCompare(inferred, left, leftRest, head, tail), () => IsOptional(left) // 'right-did-not-have-enough-elements'
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 Result.TakeLeft(left, (head, tail) => ParameterRight(inferred, head, tail, rightRest), () => Result.ExtendsTrue(inferred)); // 'ok: no-more-elements-in-left'
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);
@@ -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
- : Result.TakeLeft(leftRest, (head, tail) => ElementsCompare(inferred, reversed, head, tail, right, rightRest), () => Result.ExtendsFalse()));
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 Result.TakeLeft(rightRest, (head, tail) => ElementsLeft(inferred, reversed, leftRest, head, tail), () => Guard.IsEqual(leftRest.length, 0)
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
- : Result.TakeLeft(left, (head, tail) => Result.Match(ExtendsLeft(inferred, head, right), inferred => ExtendsTupleToArray(inferred, tail, right), () => Result.ExtendsFalse()), () => Result.ExtendsTrue(inferred)));
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 Result.TakeLeft(unionTypes, (head, tail) => Result.Match(ExtendsLeft(inferred, type, head), inferred => Result.ExtendsTrue(inferred), () => ExtendsUnionSome(inferred, type, tail)), () => Result.ExtendsFalse());
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 Result.TakeLeft(left, (head, tail) => Result.Match(ExtendsUnionSome(inferred, head, right), inferred => ExtendsUnionLeft(inferred, tail, right), () => Result.ExtendsFalse()), () => Result.ExtendsTrue(inferred));
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);
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.31",
4
+ "version": "1.1.32",
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
- "./schema": {
28
- "import": "./build/schema/index.mjs",
29
- "default": "./build/schema/index.mjs"
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
- "./compile": {
40
- "import": "./build/compile/index.mjs",
41
- "default": "./build/compile/index.mjs"
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
- "./format": {
48
- "import": "./build/format/index.mjs",
49
- "default": "./build/format/index.mjs"
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
- "schema": [
65
- "./build/schema/index.d.mts"
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
- "compile": [
74
- "./build/compile/index.d.mts"
75
- ],
76
- "error": [
77
- "./build/error/index.d.mts"
76
+ "schema": [
77
+ "./build/schema/index.d.mts"
78
78
  ],
79
- "format": [
80
- "./build/format/index.d.mts"
79
+ "value": [
80
+ "./build/value/index.d.mts"
81
81
  ],
82
82
  ".": [
83
83
  "./build/index.d.mts"