@sinclair/typebox 0.32.24 → 0.32.25

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.
Files changed (114) hide show
  1. package/build/import/type/awaited/awaited.mjs +1 -1
  2. package/build/import/type/clone/value.mjs +8 -3
  3. package/build/import/type/composite/composite.mjs +14 -10
  4. package/build/import/type/const/const.mjs +4 -3
  5. package/build/import/type/deref/deref.d.mts +1 -1
  6. package/build/import/type/deref/deref.mjs +6 -4
  7. package/build/import/type/exclude/exclude-from-mapped-result.mjs +4 -3
  8. package/build/import/type/exclude/exclude.mjs +1 -1
  9. package/build/import/type/extends/extends-from-mapped-result.mjs +4 -3
  10. package/build/import/type/extends/extends.mjs +1 -1
  11. package/build/import/type/extract/extract-from-mapped-result.mjs +4 -3
  12. package/build/import/type/extract/extract.mjs +1 -1
  13. package/build/import/type/guard/index.d.mts +1 -0
  14. package/build/import/type/guard/index.mjs +1 -0
  15. package/build/import/type/guard/kind.d.mts +136 -0
  16. package/build/import/type/guard/kind.mjs +217 -0
  17. package/build/import/type/guard/type.d.mts +2 -2
  18. package/build/import/type/indexed/indexed-from-mapped-result.mjs +5 -3
  19. package/build/import/type/indexed/indexed-property-keys.mjs +5 -4
  20. package/build/import/type/indexed/indexed.mjs +1 -1
  21. package/build/import/type/intersect/intersect-create.mjs +1 -1
  22. package/build/import/type/intersect/intersect-evaluated.mjs +1 -2
  23. package/build/import/type/intersect/intersect.mjs +1 -1
  24. package/build/import/type/intrinsic/intrinsic.mjs +1 -1
  25. package/build/import/type/keyof/keyof-from-mapped-result.mjs +4 -3
  26. package/build/import/type/keyof/keyof-property-keys.mjs +5 -4
  27. package/build/import/type/keyof/keyof.mjs +1 -1
  28. package/build/import/type/mapped/mapped.d.mts +1 -1
  29. package/build/import/type/mapped/mapped.mjs +14 -12
  30. package/build/import/type/object/object.mjs +4 -2
  31. package/build/import/type/omit/omit-from-mapped-result.mjs +4 -3
  32. package/build/import/type/omit/omit.mjs +2 -4
  33. package/build/import/type/optional/optional-from-mapped-result.mjs +4 -3
  34. package/build/import/type/optional/optional.mjs +1 -1
  35. package/build/import/type/partial/partial-from-mapped-result.mjs +4 -3
  36. package/build/import/type/partial/partial.mjs +5 -4
  37. package/build/import/type/pick/pick-from-mapped-result.mjs +4 -3
  38. package/build/import/type/pick/pick.d.mts +1 -1
  39. package/build/import/type/pick/pick.mjs +6 -4
  40. package/build/import/type/readonly/readonly-from-mapped-result.mjs +4 -3
  41. package/build/import/type/readonly/readonly.mjs +1 -1
  42. package/build/import/type/record/record.mjs +5 -3
  43. package/build/import/type/required/required-from-mapped-result.mjs +4 -3
  44. package/build/import/type/required/required.mjs +5 -4
  45. package/build/import/type/rest/rest.mjs +4 -4
  46. package/build/import/type/sets/set.mjs +4 -1
  47. package/build/import/type/template-literal/pattern.mjs +1 -2
  48. package/build/import/type/transform/transform.mjs +1 -1
  49. package/build/import/type/union/union-evaluated.mjs +1 -1
  50. package/build/import/value/clean/clean.mjs +1 -1
  51. package/build/import/value/clone/clone.mjs +8 -2
  52. package/build/import/value/create/create.mjs +11 -7
  53. package/build/import/value/hash/hash.mjs +1 -1
  54. package/build/import/value/mutate/mutate.mjs +2 -2
  55. package/build/import/value/transform/decode.mjs +30 -30
  56. package/build/import/value/transform/encode.mjs +33 -30
  57. package/build/require/type/awaited/awaited.js +4 -4
  58. package/build/require/type/clone/value.js +8 -3
  59. package/build/require/type/composite/composite.js +15 -11
  60. package/build/require/type/const/const.js +4 -3
  61. package/build/require/type/deref/deref.d.ts +1 -1
  62. package/build/require/type/deref/deref.js +17 -15
  63. package/build/require/type/exclude/exclude-from-mapped-result.js +4 -3
  64. package/build/require/type/exclude/exclude.js +4 -4
  65. package/build/require/type/extends/extends-from-mapped-result.js +4 -3
  66. package/build/require/type/extends/extends.js +3 -3
  67. package/build/require/type/extract/extract-from-mapped-result.js +4 -3
  68. package/build/require/type/extract/extract.js +4 -4
  69. package/build/require/type/guard/index.d.ts +1 -0
  70. package/build/require/type/guard/index.js +2 -1
  71. package/build/require/type/guard/kind.d.ts +136 -0
  72. package/build/require/type/guard/kind.js +266 -0
  73. package/build/require/type/guard/type.d.ts +2 -2
  74. package/build/require/type/indexed/indexed-from-mapped-result.js +5 -3
  75. package/build/require/type/indexed/indexed-property-keys.js +10 -9
  76. package/build/require/type/indexed/indexed.js +11 -11
  77. package/build/require/type/intersect/intersect-create.js +4 -4
  78. package/build/require/type/intersect/intersect-evaluated.js +4 -5
  79. package/build/require/type/intersect/intersect.js +2 -2
  80. package/build/require/type/intrinsic/intrinsic.js +5 -5
  81. package/build/require/type/keyof/keyof-from-mapped-result.js +4 -3
  82. package/build/require/type/keyof/keyof-property-keys.js +11 -10
  83. package/build/require/type/keyof/keyof.js +2 -2
  84. package/build/require/type/mapped/mapped.d.ts +1 -1
  85. package/build/require/type/mapped/mapped.js +29 -27
  86. package/build/require/type/object/object.js +6 -4
  87. package/build/require/type/omit/omit-from-mapped-result.js +4 -3
  88. package/build/require/type/omit/omit.js +8 -10
  89. package/build/require/type/optional/optional-from-mapped-result.js +4 -3
  90. package/build/require/type/optional/optional.js +2 -2
  91. package/build/require/type/partial/partial-from-mapped-result.js +4 -3
  92. package/build/require/type/partial/partial.js +9 -8
  93. package/build/require/type/pick/pick-from-mapped-result.js +4 -3
  94. package/build/require/type/pick/pick.d.ts +1 -1
  95. package/build/require/type/pick/pick.js +12 -10
  96. package/build/require/type/readonly/readonly-from-mapped-result.js +4 -3
  97. package/build/require/type/readonly/readonly.js +2 -2
  98. package/build/require/type/record/record.js +12 -10
  99. package/build/require/type/required/required-from-mapped-result.js +4 -3
  100. package/build/require/type/required/required.js +9 -8
  101. package/build/require/type/rest/rest.js +4 -4
  102. package/build/require/type/sets/set.js +4 -1
  103. package/build/require/type/template-literal/pattern.js +9 -10
  104. package/build/require/type/transform/transform.js +2 -2
  105. package/build/require/type/union/union-evaluated.js +3 -3
  106. package/build/require/value/clean/clean.js +1 -1
  107. package/build/require/value/clone/clone.js +8 -2
  108. package/build/require/value/create/create.js +11 -7
  109. package/build/require/value/hash/hash.js +1 -1
  110. package/build/require/value/mutate/mutate.js +2 -2
  111. package/build/require/value/transform/decode.js +30 -30
  112. package/build/require/value/transform/encode.js +33 -30
  113. package/package.json +1 -1
  114. package/readme.md +4 -4
@@ -4,7 +4,7 @@ import { CloneType } from '../clone/type.mjs';
4
4
  // ------------------------------------------------------------------
5
5
  // TypeGuard
6
6
  // ------------------------------------------------------------------
7
- import { IsIntersect, IsUnion, IsPromise } from '../guard/type.mjs';
7
+ import { IsIntersect, IsUnion, IsPromise } from '../guard/kind.mjs';
8
8
  // prettier-ignore
9
9
  function FromRest(T) {
10
10
  return T.map(L => AwaitedResolve(L));
@@ -12,9 +12,14 @@ function RegExpType(value) {
12
12
  return new RegExp(value.source, value.flags);
13
13
  }
14
14
  function ObjectType(value) {
15
- const clonedProperties = Object.getOwnPropertyNames(value).reduce((acc, key) => ({ ...acc, [key]: Visit(value[key]) }), {});
16
- const clonedSymbols = Object.getOwnPropertySymbols(value).reduce((acc, key) => ({ ...acc, [key]: Visit(value[key]) }), {});
17
- return { ...clonedProperties, ...clonedSymbols };
15
+ const result = {};
16
+ for (const key of Object.getOwnPropertyNames(value)) {
17
+ result[key] = Visit(value[key]);
18
+ }
19
+ for (const key of Object.getOwnPropertySymbols(value)) {
20
+ result[key] = Visit(value[key]);
21
+ }
22
+ return result;
18
23
  }
19
24
  // prettier-ignore
20
25
  function Visit(value) {
@@ -6,12 +6,13 @@ import { SetDistinct } from '../sets/index.mjs';
6
6
  // ------------------------------------------------------------------
7
7
  // TypeGuard
8
8
  // ------------------------------------------------------------------
9
- import { IsNever } from '../guard/type.mjs';
9
+ import { IsNever } from '../guard/kind.mjs';
10
10
  // prettier-ignore
11
11
  function CompositeKeys(T) {
12
- return SetDistinct(T.reduce((Acc, L) => {
13
- return ([...Acc, ...KeyOfPropertyKeys(L)]);
14
- }, []));
12
+ const Acc = [];
13
+ for (const L of T)
14
+ Acc.push(...KeyOfPropertyKeys(L));
15
+ return SetDistinct(Acc);
15
16
  }
16
17
  // prettier-ignore
17
18
  function FilterNever(T) {
@@ -19,15 +20,18 @@ function FilterNever(T) {
19
20
  }
20
21
  // prettier-ignore
21
22
  function CompositeProperty(T, K) {
22
- return FilterNever(T.reduce((Acc, L) => {
23
- return [...Acc, ...IndexFromPropertyKeys(L, [K])];
24
- }, []));
23
+ const Acc = [];
24
+ for (const L of T)
25
+ Acc.push(...IndexFromPropertyKeys(L, [K]));
26
+ return FilterNever(Acc);
25
27
  }
26
28
  // prettier-ignore
27
29
  function CompositeProperties(T, K) {
28
- return K.reduce((Acc, L) => {
29
- return { ...Acc, [L]: IntersectEvaluated(CompositeProperty(T, L)) };
30
- }, {});
30
+ const Acc = {};
31
+ for (const L of K) {
32
+ Acc[L] = IntersectEvaluated(CompositeProperty(T, L));
33
+ }
34
+ return Acc;
31
35
  }
32
36
  // prettier-ignore
33
37
  export function Composite(T, options = {}) {
@@ -22,9 +22,10 @@ function FromArray(T) {
22
22
  }
23
23
  // prettier-ignore
24
24
  function FromProperties(value) {
25
- return globalThis.Object.getOwnPropertyNames(value).reduce((acc, key) => {
26
- return { ...acc, [key]: Readonly(FromValue(value[key], false)) };
27
- }, {});
25
+ const Acc = {};
26
+ for (const K of globalThis.Object.getOwnPropertyNames(value))
27
+ Acc[K] = Readonly(FromValue(value[K], false));
28
+ return Acc;
28
29
  }
29
30
  function ConditionalReadonly(T, root) {
30
31
  return (root === true ? T : Readonly(T));
@@ -15,7 +15,7 @@ export type TFromRest<T extends TSchema[], Acc extends TSchema[] = []> = (T exte
15
15
  type FromProperties<T extends TProperties> = Evaluate<{
16
16
  [K in keyof T]: TDeref<T[K]>;
17
17
  }>;
18
- declare function FromProperties(properties: TProperties, references: TSchema[]): TProperties;
18
+ declare function FromProperties(properties: TProperties, references: TSchema[]): never;
19
19
  export type TDeref<T extends TSchema> = T extends TConstructor<infer S extends TSchema[], infer R extends TSchema> ? TConstructor<TFromRest<S>, TDeref<R>> : T extends TFunction<infer S extends TSchema[], infer R extends TSchema> ? TFunction<TFromRest<S>, TDeref<R>> : T extends TIntersect<infer S extends TSchema[]> ? TIntersect<TFromRest<S>> : T extends TUnion<infer S extends TSchema[]> ? TUnion<TFromRest<S>> : T extends TTuple<infer S extends TSchema[]> ? TTuple<TFromRest<S>> : T extends TObject<infer S extends TProperties> ? TObject<FromProperties<S>> : T extends TArray<infer S extends TSchema> ? TArray<TDeref<S>> : T extends TPromise<infer S extends TSchema> ? TPromise<TDeref<S>> : T extends TAsyncIterator<infer S extends TSchema> ? TAsyncIterator<TDeref<S>> : T extends TIterator<infer S extends TSchema> ? TIterator<TDeref<S>> : T extends TRef<infer S extends TSchema> ? TDeref<S> : T;
20
20
  /** `[Json]` Creates a dereferenced type */
21
21
  export declare function Deref<T extends TSchema>(schema: T, references: TSchema[]): TDeref<T>;
@@ -4,15 +4,17 @@ import { IsUndefined } from '../guard/value.mjs';
4
4
  // ------------------------------------------------------------------
5
5
  // TypeGuard
6
6
  // ------------------------------------------------------------------
7
- import { IsConstructor, IsFunction, IsIntersect, IsUnion, IsTuple, IsArray, IsObject, IsPromise, IsAsyncIterator, IsIterator, IsRef } from '../guard/type.mjs';
7
+ import { IsConstructor, IsFunction, IsIntersect, IsUnion, IsTuple, IsArray, IsObject, IsPromise, IsAsyncIterator, IsIterator, IsRef } from '../guard/kind.mjs';
8
8
  function FromRest(schema, references) {
9
9
  return schema.map((schema) => Deref(schema, references));
10
10
  }
11
11
  // prettier-ignore
12
12
  function FromProperties(properties, references) {
13
- return globalThis.Object.getOwnPropertyNames(properties).reduce((acc, key) => {
14
- return { ...acc, [key]: Deref(properties[key], references) };
15
- }, {});
13
+ const Acc = {};
14
+ for (const K of globalThis.Object.getOwnPropertyNames(properties)) {
15
+ Acc[K] = Deref(properties[K], references);
16
+ }
17
+ return Acc;
16
18
  }
17
19
  // prettier-ignore
18
20
  function FromConstructor(schema, references) {
@@ -2,9 +2,10 @@ import { MappedResult } from '../mapped/index.mjs';
2
2
  import { Exclude } from './exclude.mjs';
3
3
  // prettier-ignore
4
4
  function FromProperties(P, U) {
5
- return globalThis.Object.getOwnPropertyNames(P).reduce((Acc, K2) => {
6
- return { ...Acc, [K2]: Exclude(P[K2], U) };
7
- }, {});
5
+ const Acc = {};
6
+ for (const K2 of globalThis.Object.getOwnPropertyNames(P))
7
+ Acc[K2] = Exclude(P[K2], U);
8
+ return Acc;
8
9
  }
9
10
  // prettier-ignore
10
11
  function FromMappedResult(R, T) {
@@ -7,7 +7,7 @@ import { ExcludeFromTemplateLiteral } from './exclude-from-template-literal.mjs'
7
7
  // ------------------------------------------------------------------
8
8
  // TypeGuard
9
9
  // ------------------------------------------------------------------
10
- import { IsMappedResult, IsTemplateLiteral, IsUnion } from '../guard/type.mjs';
10
+ import { IsMappedResult, IsTemplateLiteral, IsUnion } from '../guard/kind.mjs';
11
11
  function ExcludeRest(L, R) {
12
12
  const excluded = L.filter((inner) => ExtendsCheck(inner, R) === ExtendsResult.False);
13
13
  return excluded.length === 1 ? excluded[0] : Union(excluded);
@@ -2,9 +2,10 @@ import { MappedResult } from '../mapped/index.mjs';
2
2
  import { Extends } from './extends.mjs';
3
3
  // prettier-ignore
4
4
  function FromProperties(P, Right, True, False, options) {
5
- return globalThis.Object.getOwnPropertyNames(P).reduce((Acc, K2) => {
6
- return { ...Acc, [K2]: Extends(P[K2], Right, True, False, options) };
7
- }, {});
5
+ const Acc = {};
6
+ for (const K2 of globalThis.Object.getOwnPropertyNames(P))
7
+ Acc[K2] = Extends(P[K2], Right, True, False, options);
8
+ return Acc;
8
9
  }
9
10
  // prettier-ignore
10
11
  function FromMappedResult(Left, Right, True, False, options) {
@@ -6,7 +6,7 @@ import { ExtendsFromMappedResult } from './extends-from-mapped-result.mjs';
6
6
  // ------------------------------------------------------------------
7
7
  // TypeGuard
8
8
  // ------------------------------------------------------------------
9
- import { IsMappedKey, IsMappedResult } from '../guard/type.mjs';
9
+ import { IsMappedKey, IsMappedResult } from '../guard/kind.mjs';
10
10
  // prettier-ignore
11
11
  function ExtendsResolve(left, right, trueType, falseType) {
12
12
  const R = ExtendsCheck(left, right);
@@ -2,9 +2,10 @@ import { MappedResult } from '../mapped/index.mjs';
2
2
  import { Extract } from './extract.mjs';
3
3
  // prettier-ignore
4
4
  function FromProperties(P, T) {
5
- return globalThis.Object.getOwnPropertyNames(P).reduce((Acc, K2) => {
6
- return { ...Acc, [K2]: Extract(P[K2], T) };
7
- }, {});
5
+ const Acc = {};
6
+ for (const K2 of globalThis.Object.getOwnPropertyNames(P))
7
+ Acc[K2] = Extract(P[K2], T);
8
+ return Acc;
8
9
  }
9
10
  // prettier-ignore
10
11
  function FromMappedResult(R, T) {
@@ -7,7 +7,7 @@ import { ExtractFromTemplateLiteral } from './extract-from-template-literal.mjs'
7
7
  // ------------------------------------------------------------------
8
8
  // TypeGuard
9
9
  // ------------------------------------------------------------------
10
- import { IsMappedResult, IsTemplateLiteral, IsUnion } from '../guard/type.mjs';
10
+ import { IsMappedResult, IsTemplateLiteral, IsUnion } from '../guard/kind.mjs';
11
11
  function ExtractRest(L, R) {
12
12
  const extracted = L.filter((inner) => ExtendsCheck(inner, R) !== ExtendsResult.False);
13
13
  return extracted.length === 1 ? extracted[0] : Union(extracted);
@@ -1,2 +1,3 @@
1
+ export * as KindGuard from './kind.mjs';
1
2
  export * as TypeGuard from './type.mjs';
2
3
  export * as ValueGuard from './value.mjs';
@@ -1,2 +1,3 @@
1
+ export * as KindGuard from './kind.mjs';
1
2
  export * as TypeGuard from './type.mjs';
2
3
  export * as ValueGuard from './value.mjs';
@@ -0,0 +1,136 @@
1
+ import { Kind, Hint, TransformKind } from '../symbols/index.mjs';
2
+ import { TransformOptions } from '../transform/index.mjs';
3
+ import { TTemplateLiteral } from '../template-literal/index.mjs';
4
+ import { TArray } from '../array/index.mjs';
5
+ import { TBoolean } from '../boolean/index.mjs';
6
+ import type { TRecord } from '../record/index.mjs';
7
+ import type { TString } from '../string/index.mjs';
8
+ import type { TUnion } from '../union/index.mjs';
9
+ import type { TAny } from '../any/index.mjs';
10
+ import type { TAsyncIterator } from '../async-iterator/index.mjs';
11
+ import type { TBigInt } from '../bigint/index.mjs';
12
+ import type { TConstructor } from '../constructor/index.mjs';
13
+ import type { TFunction } from '../function/index.mjs';
14
+ import type { TInteger } from '../integer/index.mjs';
15
+ import type { TIntersect } from '../intersect/index.mjs';
16
+ import type { TIterator } from '../iterator/index.mjs';
17
+ import type { TLiteral } from '../literal/index.mjs';
18
+ import type { TMappedKey, TMappedResult } from '../mapped/index.mjs';
19
+ import type { TNever } from '../never/index.mjs';
20
+ import type { TNot } from '../not/index.mjs';
21
+ import type { TNull } from '../null/index.mjs';
22
+ import type { TNumber } from '../number/index.mjs';
23
+ import type { TObject, TProperties } from '../object/index.mjs';
24
+ import type { TOptional } from '../optional/index.mjs';
25
+ import type { TPromise } from '../promise/index.mjs';
26
+ import type { TReadonly } from '../readonly/index.mjs';
27
+ import type { TRef } from '../ref/index.mjs';
28
+ import type { TRegExp } from '../regexp/index.mjs';
29
+ import type { TSchema } from '../schema/index.mjs';
30
+ import type { TSymbol } from '../symbol/index.mjs';
31
+ import type { TTuple } from '../tuple/index.mjs';
32
+ import type { TUint8Array } from '../uint8array/index.mjs';
33
+ import type { TUndefined } from '../undefined/index.mjs';
34
+ import type { TUnknown } from '../unknown/index.mjs';
35
+ import type { TUnsafe } from '../unsafe/index.mjs';
36
+ import type { TVoid } from '../void/index.mjs';
37
+ import type { TDate } from '../date/index.mjs';
38
+ import type { TThis } from '../recursive/index.mjs';
39
+ /** `[Kind-Only]` Returns true if this value has a Readonly symbol */
40
+ export declare function IsReadonly<T extends TSchema>(value: T): value is TReadonly<T>;
41
+ /** `[Kind-Only]` Returns true if this value has a Optional symbol */
42
+ export declare function IsOptional<T extends TSchema>(value: T): value is TOptional<T>;
43
+ /** `[Kind-Only]` Returns true if the given value is TAny */
44
+ export declare function IsAny(value: unknown): value is TAny;
45
+ /** `[Kind-Only]` Returns true if the given value is TArray */
46
+ export declare function IsArray(value: unknown): value is TArray;
47
+ /** `[Kind-Only]` Returns true if the given value is TAsyncIterator */
48
+ export declare function IsAsyncIterator(value: unknown): value is TAsyncIterator;
49
+ /** `[Kind-Only]` Returns true if the given value is TBigInt */
50
+ export declare function IsBigInt(value: unknown): value is TBigInt;
51
+ /** `[Kind-Only]` Returns true if the given value is TBoolean */
52
+ export declare function IsBoolean(value: unknown): value is TBoolean;
53
+ /** `[Kind-Only]` Returns true if the given value is TConstructor */
54
+ export declare function IsConstructor(value: unknown): value is TConstructor;
55
+ /** `[Kind-Only]` Returns true if the given value is TDate */
56
+ export declare function IsDate(value: unknown): value is TDate;
57
+ /** `[Kind-Only]` Returns true if the given value is TFunction */
58
+ export declare function IsFunction(value: unknown): value is TFunction;
59
+ /** `[Kind-Only]` Returns true if the given value is TInteger */
60
+ export declare function IsInteger(value: unknown): value is TInteger;
61
+ /** `[Kind-Only]` Returns true if the given schema is TProperties */
62
+ export declare function IsProperties(value: unknown): value is TProperties;
63
+ /** `[Kind-Only]` Returns true if the given value is TIntersect */
64
+ export declare function IsIntersect(value: unknown): value is TIntersect;
65
+ /** `[Kind-Only]` Returns true if the given value is TIterator */
66
+ export declare function IsIterator(value: unknown): value is TIterator;
67
+ /** `[Kind-Only]` Returns true if the given value is a TKind with the given name. */
68
+ export declare function IsKindOf<T extends string>(value: unknown, kind: T): value is Record<PropertyKey, unknown> & {
69
+ [Kind]: T;
70
+ };
71
+ /** `[Kind-Only]` Returns true if the given value is TLiteral<string> */
72
+ export declare function IsLiteralString(value: unknown): value is TLiteral<string>;
73
+ /** `[Kind-Only]` Returns true if the given value is TLiteral<number> */
74
+ export declare function IsLiteralNumber(value: unknown): value is TLiteral<number>;
75
+ /** `[Kind-Only]` Returns true if the given value is TLiteral<boolean> */
76
+ export declare function IsLiteralBoolean(value: unknown): value is TLiteral<boolean>;
77
+ /** `[Kind-Only]` Returns true if the given value is TLiteral */
78
+ export declare function IsLiteral(value: unknown): value is TLiteral;
79
+ /** `[Kind-Only]` Returns true if the given value is a TMappedKey */
80
+ export declare function IsMappedKey(value: unknown): value is TMappedKey;
81
+ /** `[Kind-Only]` Returns true if the given value is TMappedResult */
82
+ export declare function IsMappedResult(value: unknown): value is TMappedResult;
83
+ /** `[Kind-Only]` Returns true if the given value is TNever */
84
+ export declare function IsNever(value: unknown): value is TNever;
85
+ /** `[Kind-Only]` Returns true if the given value is TNot */
86
+ export declare function IsNot(value: unknown): value is TNot;
87
+ /** `[Kind-Only]` Returns true if the given value is TNull */
88
+ export declare function IsNull(value: unknown): value is TNull;
89
+ /** `[Kind-Only]` Returns true if the given value is TNumber */
90
+ export declare function IsNumber(value: unknown): value is TNumber;
91
+ /** `[Kind-Only]` Returns true if the given value is TObject */
92
+ export declare function IsObject(value: unknown): value is TObject;
93
+ /** `[Kind-Only]` Returns true if the given value is TPromise */
94
+ export declare function IsPromise(value: unknown): value is TPromise;
95
+ /** `[Kind-Only]` Returns true if the given value is TRecord */
96
+ export declare function IsRecord(value: unknown): value is TRecord;
97
+ /** `[Kind-Only]` Returns true if this value is TRecursive */
98
+ export declare function IsRecursive(value: unknown): value is {
99
+ [Hint]: 'Recursive';
100
+ };
101
+ /** `[Kind-Only]` Returns true if the given value is TRef */
102
+ export declare function IsRef(value: unknown): value is TRef;
103
+ /** `[Kind-Only]` Returns true if the given value is TRegExp */
104
+ export declare function IsRegExp(value: unknown): value is TRegExp;
105
+ /** `[Kind-Only]` Returns true if the given value is TString */
106
+ export declare function IsString(value: unknown): value is TString;
107
+ /** `[Kind-Only]` Returns true if the given value is TSymbol */
108
+ export declare function IsSymbol(value: unknown): value is TSymbol;
109
+ /** `[Kind-Only]` Returns true if the given value is TTemplateLiteral */
110
+ export declare function IsTemplateLiteral(value: unknown): value is TTemplateLiteral;
111
+ /** `[Kind-Only]` Returns true if the given value is TThis */
112
+ export declare function IsThis(value: unknown): value is TThis;
113
+ /** `[Kind-Only]` Returns true of this value is TTransform */
114
+ export declare function IsTransform(value: unknown): value is {
115
+ [TransformKind]: TransformOptions;
116
+ };
117
+ /** `[Kind-Only]` Returns true if the given value is TTuple */
118
+ export declare function IsTuple(value: unknown): value is TTuple;
119
+ /** `[Kind-Only]` Returns true if the given value is TUndefined */
120
+ export declare function IsUndefined(value: unknown): value is TUndefined;
121
+ /** `[Kind-Only]` Returns true if the given value is TUnion */
122
+ export declare function IsUnion(value: unknown): value is TUnion;
123
+ /** `[Kind-Only]` Returns true if the given value is TUint8Array */
124
+ export declare function IsUint8Array(value: unknown): value is TUint8Array;
125
+ /** `[Kind-Only]` Returns true if the given value is TUnknown */
126
+ export declare function IsUnknown(value: unknown): value is TUnknown;
127
+ /** `[Kind-Only]` Returns true if the given value is a raw TUnsafe */
128
+ export declare function IsUnsafe(value: unknown): value is TUnsafe<unknown>;
129
+ /** `[Kind-Only]` Returns true if the given value is TVoid */
130
+ export declare function IsVoid(value: unknown): value is TVoid;
131
+ /** `[Kind-Only]` Returns true if the given value is TKind */
132
+ export declare function IsKind(value: unknown): value is Record<PropertyKey, unknown> & {
133
+ [Kind]: string;
134
+ };
135
+ /** `[Kind-Only]` Returns true if the given value is TSchema */
136
+ export declare function IsSchema(value: unknown): value is TSchema;
@@ -0,0 +1,217 @@
1
+ import * as ValueGuard from './value.mjs';
2
+ import { Kind, Hint, TransformKind, ReadonlyKind, OptionalKind } from '../symbols/index.mjs';
3
+ /** `[Kind-Only]` Returns true if this value has a Readonly symbol */
4
+ export function IsReadonly(value) {
5
+ return ValueGuard.IsObject(value) && value[ReadonlyKind] === 'Readonly';
6
+ }
7
+ /** `[Kind-Only]` Returns true if this value has a Optional symbol */
8
+ export function IsOptional(value) {
9
+ return ValueGuard.IsObject(value) && value[OptionalKind] === 'Optional';
10
+ }
11
+ /** `[Kind-Only]` Returns true if the given value is TAny */
12
+ export function IsAny(value) {
13
+ return IsKindOf(value, 'Any');
14
+ }
15
+ /** `[Kind-Only]` Returns true if the given value is TArray */
16
+ export function IsArray(value) {
17
+ return IsKindOf(value, 'Array');
18
+ }
19
+ /** `[Kind-Only]` Returns true if the given value is TAsyncIterator */
20
+ export function IsAsyncIterator(value) {
21
+ return IsKindOf(value, 'AsyncIterator');
22
+ }
23
+ /** `[Kind-Only]` Returns true if the given value is TBigInt */
24
+ export function IsBigInt(value) {
25
+ return IsKindOf(value, 'BigInt');
26
+ }
27
+ /** `[Kind-Only]` Returns true if the given value is TBoolean */
28
+ export function IsBoolean(value) {
29
+ return IsKindOf(value, 'Boolean');
30
+ }
31
+ /** `[Kind-Only]` Returns true if the given value is TConstructor */
32
+ export function IsConstructor(value) {
33
+ return IsKindOf(value, 'Constructor');
34
+ }
35
+ /** `[Kind-Only]` Returns true if the given value is TDate */
36
+ export function IsDate(value) {
37
+ return IsKindOf(value, 'Date');
38
+ }
39
+ /** `[Kind-Only]` Returns true if the given value is TFunction */
40
+ export function IsFunction(value) {
41
+ return IsKindOf(value, 'Function');
42
+ }
43
+ /** `[Kind-Only]` Returns true if the given value is TInteger */
44
+ export function IsInteger(value) {
45
+ return IsKindOf(value, 'Integer');
46
+ }
47
+ /** `[Kind-Only]` Returns true if the given schema is TProperties */
48
+ export function IsProperties(value) {
49
+ return ValueGuard.IsObject(value);
50
+ }
51
+ /** `[Kind-Only]` Returns true if the given value is TIntersect */
52
+ export function IsIntersect(value) {
53
+ return IsKindOf(value, 'Intersect');
54
+ }
55
+ /** `[Kind-Only]` Returns true if the given value is TIterator */
56
+ export function IsIterator(value) {
57
+ return IsKindOf(value, 'Iterator');
58
+ }
59
+ /** `[Kind-Only]` Returns true if the given value is a TKind with the given name. */
60
+ export function IsKindOf(value, kind) {
61
+ return ValueGuard.IsObject(value) && Kind in value && value[Kind] === kind;
62
+ }
63
+ /** `[Kind-Only]` Returns true if the given value is TLiteral<string> */
64
+ export function IsLiteralString(value) {
65
+ return IsLiteral(value) && ValueGuard.IsString(value.const);
66
+ }
67
+ /** `[Kind-Only]` Returns true if the given value is TLiteral<number> */
68
+ export function IsLiteralNumber(value) {
69
+ return IsLiteral(value) && ValueGuard.IsNumber(value.const);
70
+ }
71
+ /** `[Kind-Only]` Returns true if the given value is TLiteral<boolean> */
72
+ export function IsLiteralBoolean(value) {
73
+ return IsLiteral(value) && ValueGuard.IsBoolean(value.const);
74
+ }
75
+ /** `[Kind-Only]` Returns true if the given value is TLiteral */
76
+ export function IsLiteral(value) {
77
+ return IsKindOf(value, 'Literal');
78
+ }
79
+ /** `[Kind-Only]` Returns true if the given value is a TMappedKey */
80
+ export function IsMappedKey(value) {
81
+ return IsKindOf(value, 'MappedKey');
82
+ }
83
+ /** `[Kind-Only]` Returns true if the given value is TMappedResult */
84
+ export function IsMappedResult(value) {
85
+ return IsKindOf(value, 'MappedResult');
86
+ }
87
+ /** `[Kind-Only]` Returns true if the given value is TNever */
88
+ export function IsNever(value) {
89
+ return IsKindOf(value, 'Never');
90
+ }
91
+ /** `[Kind-Only]` Returns true if the given value is TNot */
92
+ export function IsNot(value) {
93
+ return IsKindOf(value, 'Not');
94
+ }
95
+ /** `[Kind-Only]` Returns true if the given value is TNull */
96
+ export function IsNull(value) {
97
+ return IsKindOf(value, 'Null');
98
+ }
99
+ /** `[Kind-Only]` Returns true if the given value is TNumber */
100
+ export function IsNumber(value) {
101
+ return IsKindOf(value, 'Number');
102
+ }
103
+ /** `[Kind-Only]` Returns true if the given value is TObject */
104
+ export function IsObject(value) {
105
+ return IsKindOf(value, 'Object');
106
+ }
107
+ /** `[Kind-Only]` Returns true if the given value is TPromise */
108
+ export function IsPromise(value) {
109
+ return IsKindOf(value, 'Promise');
110
+ }
111
+ /** `[Kind-Only]` Returns true if the given value is TRecord */
112
+ export function IsRecord(value) {
113
+ return IsKindOf(value, 'Record');
114
+ }
115
+ /** `[Kind-Only]` Returns true if this value is TRecursive */
116
+ export function IsRecursive(value) {
117
+ return ValueGuard.IsObject(value) && Hint in value && value[Hint] === 'Recursive';
118
+ }
119
+ /** `[Kind-Only]` Returns true if the given value is TRef */
120
+ export function IsRef(value) {
121
+ return IsKindOf(value, 'Ref');
122
+ }
123
+ /** `[Kind-Only]` Returns true if the given value is TRegExp */
124
+ export function IsRegExp(value) {
125
+ return IsKindOf(value, 'RegExp');
126
+ }
127
+ /** `[Kind-Only]` Returns true if the given value is TString */
128
+ export function IsString(value) {
129
+ return IsKindOf(value, 'String');
130
+ }
131
+ /** `[Kind-Only]` Returns true if the given value is TSymbol */
132
+ export function IsSymbol(value) {
133
+ return IsKindOf(value, 'Symbol');
134
+ }
135
+ /** `[Kind-Only]` Returns true if the given value is TTemplateLiteral */
136
+ export function IsTemplateLiteral(value) {
137
+ return IsKindOf(value, 'TemplateLiteral');
138
+ }
139
+ /** `[Kind-Only]` Returns true if the given value is TThis */
140
+ export function IsThis(value) {
141
+ return IsKindOf(value, 'This');
142
+ }
143
+ /** `[Kind-Only]` Returns true of this value is TTransform */
144
+ export function IsTransform(value) {
145
+ return ValueGuard.IsObject(value) && TransformKind in value;
146
+ }
147
+ /** `[Kind-Only]` Returns true if the given value is TTuple */
148
+ export function IsTuple(value) {
149
+ return IsKindOf(value, 'Tuple');
150
+ }
151
+ /** `[Kind-Only]` Returns true if the given value is TUndefined */
152
+ export function IsUndefined(value) {
153
+ return IsKindOf(value, 'Undefined');
154
+ }
155
+ /** `[Kind-Only]` Returns true if the given value is TUnion */
156
+ export function IsUnion(value) {
157
+ return IsKindOf(value, 'Union');
158
+ }
159
+ /** `[Kind-Only]` Returns true if the given value is TUint8Array */
160
+ export function IsUint8Array(value) {
161
+ return IsKindOf(value, 'Uint8Array');
162
+ }
163
+ /** `[Kind-Only]` Returns true if the given value is TUnknown */
164
+ export function IsUnknown(value) {
165
+ return IsKindOf(value, 'Unknown');
166
+ }
167
+ /** `[Kind-Only]` Returns true if the given value is a raw TUnsafe */
168
+ export function IsUnsafe(value) {
169
+ return IsKindOf(value, 'Unsafe');
170
+ }
171
+ /** `[Kind-Only]` Returns true if the given value is TVoid */
172
+ export function IsVoid(value) {
173
+ return IsKindOf(value, 'Void');
174
+ }
175
+ /** `[Kind-Only]` Returns true if the given value is TKind */
176
+ export function IsKind(value) {
177
+ return ValueGuard.IsObject(value) && Kind in value && ValueGuard.IsString(value[Kind]);
178
+ }
179
+ /** `[Kind-Only]` Returns true if the given value is TSchema */
180
+ export function IsSchema(value) {
181
+ // prettier-ignore
182
+ return (IsAny(value) ||
183
+ IsArray(value) ||
184
+ IsBoolean(value) ||
185
+ IsBigInt(value) ||
186
+ IsAsyncIterator(value) ||
187
+ IsConstructor(value) ||
188
+ IsDate(value) ||
189
+ IsFunction(value) ||
190
+ IsInteger(value) ||
191
+ IsIntersect(value) ||
192
+ IsIterator(value) ||
193
+ IsLiteral(value) ||
194
+ IsMappedKey(value) ||
195
+ IsMappedResult(value) ||
196
+ IsNever(value) ||
197
+ IsNot(value) ||
198
+ IsNull(value) ||
199
+ IsNumber(value) ||
200
+ IsObject(value) ||
201
+ IsPromise(value) ||
202
+ IsRecord(value) ||
203
+ IsRef(value) ||
204
+ IsRegExp(value) ||
205
+ IsString(value) ||
206
+ IsSymbol(value) ||
207
+ IsTemplateLiteral(value) ||
208
+ IsThis(value) ||
209
+ IsTuple(value) ||
210
+ IsUndefined(value) ||
211
+ IsUnion(value) ||
212
+ IsUint8Array(value) ||
213
+ IsUnknown(value) ||
214
+ IsUnsafe(value) ||
215
+ IsVoid(value) ||
216
+ IsKind(value));
217
+ }
@@ -1,7 +1,7 @@
1
1
  import { Kind, Hint, TransformKind } from '../symbols/index.mjs';
2
2
  import { TypeBoxError } from '../error/index.mjs';
3
3
  import { TransformOptions } from '../transform/index.mjs';
4
- import { TTemplateLiteral, TTemplateLiteralKind } from '../template-literal/index.mjs';
4
+ import { TTemplateLiteral } from '../template-literal/index.mjs';
5
5
  import { TArray } from '../array/index.mjs';
6
6
  import { TBoolean } from '../boolean/index.mjs';
7
7
  import type { TRecord } from '../record/index.mjs';
@@ -112,7 +112,7 @@ export declare function IsString(value: unknown): value is TString;
112
112
  /** Returns true if the given value is TSymbol */
113
113
  export declare function IsSymbol(value: unknown): value is TSymbol;
114
114
  /** Returns true if the given value is TTemplateLiteral */
115
- export declare function IsTemplateLiteral(value: unknown): value is TTemplateLiteral<TTemplateLiteralKind[]>;
115
+ export declare function IsTemplateLiteral(value: unknown): value is TTemplateLiteral;
116
116
  /** Returns true if the given value is TThis */
117
117
  export declare function IsThis(value: unknown): value is TThis;
118
118
  /** Returns true of this value is TTransform */
@@ -3,9 +3,11 @@ import { IndexPropertyKeys } from './indexed-property-keys.mjs';
3
3
  import { Index } from './index.mjs';
4
4
  // prettier-ignore
5
5
  function FromProperties(T, P, options) {
6
- return globalThis.Object.getOwnPropertyNames(P).reduce((Acc, K2) => {
7
- return { ...Acc, [K2]: Index(T, IndexPropertyKeys(P[K2]), options) };
8
- }, {});
6
+ const Acc = {};
7
+ for (const K2 of Object.getOwnPropertyNames(P)) {
8
+ Acc[K2] = Index(T, IndexPropertyKeys(P[K2]), options);
9
+ }
10
+ return Acc;
9
11
  }
10
12
  // prettier-ignore
11
13
  function FromMappedResult(T, R, options) {
@@ -2,7 +2,7 @@ import { TemplateLiteralGenerate } from '../template-literal/index.mjs';
2
2
  // ------------------------------------------------------------------
3
3
  // TypeGuard
4
4
  // ------------------------------------------------------------------
5
- import { IsTemplateLiteral, IsUnion, IsLiteral, IsNumber, IsInteger } from '../guard/type.mjs';
5
+ import { IsTemplateLiteral, IsUnion, IsLiteral, IsNumber, IsInteger } from '../guard/kind.mjs';
6
6
  // prettier-ignore
7
7
  function FromTemplateLiteral(T) {
8
8
  const R = TemplateLiteralGenerate(T);
@@ -10,9 +10,10 @@ function FromTemplateLiteral(T) {
10
10
  }
11
11
  // prettier-ignore
12
12
  function FromUnion(T) {
13
- return T.reduce((Acc, L) => {
14
- return [...Acc, ...IndexPropertyKeys(L)];
15
- }, []);
13
+ const Acc = [];
14
+ for (const L of T)
15
+ Acc.push(...IndexPropertyKeys(L));
16
+ return Acc;
16
17
  }
17
18
  // prettier-ignore
18
19
  function FromLiteral(T) {
@@ -8,7 +8,7 @@ import { IndexFromMappedResult } from './indexed-from-mapped-result.mjs';
8
8
  // ------------------------------------------------------------------
9
9
  // TypeGuard
10
10
  // ------------------------------------------------------------------
11
- import { IsArray, IsIntersect, IsObject, IsMappedKey, IsMappedResult, IsNever, IsSchema, IsTuple, IsUnion } from '../guard/type.mjs';
11
+ import { IsArray, IsIntersect, IsObject, IsMappedKey, IsMappedResult, IsNever, IsSchema, IsTuple, IsUnion } from '../guard/kind.mjs';
12
12
  // prettier-ignore
13
13
  function FromRest(T, K) {
14
14
  return T.map(L => IndexFromPropertyKey(L, K));
@@ -3,7 +3,7 @@ import { CloneType, CloneRest } from '../clone/type.mjs';
3
3
  // ------------------------------------------------------------------
4
4
  // TypeGuard
5
5
  // ------------------------------------------------------------------
6
- import { IsObject, IsSchema } from '../guard/type.mjs';
6
+ import { IsObject, IsSchema } from '../guard/kind.mjs';
7
7
  // ------------------------------------------------------------------
8
8
  // IntersectCreate
9
9
  // ------------------------------------------------------------------