@sinclair/typebox 0.32.24 → 0.32.26

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 (120) hide show
  1. package/build/import/compiler/compiler.mjs +2 -2
  2. package/build/import/system/policy.mjs +1 -2
  3. package/build/import/type/awaited/awaited.mjs +1 -1
  4. package/build/import/type/clone/value.mjs +8 -3
  5. package/build/import/type/composite/composite.mjs +14 -10
  6. package/build/import/type/const/const.mjs +4 -3
  7. package/build/import/type/deref/deref.d.mts +1 -1
  8. package/build/import/type/deref/deref.mjs +6 -4
  9. package/build/import/type/exclude/exclude-from-mapped-result.mjs +4 -3
  10. package/build/import/type/exclude/exclude.mjs +1 -1
  11. package/build/import/type/extends/extends-from-mapped-result.mjs +4 -3
  12. package/build/import/type/extends/extends.mjs +1 -1
  13. package/build/import/type/extract/extract-from-mapped-result.mjs +4 -3
  14. package/build/import/type/extract/extract.mjs +1 -1
  15. package/build/import/type/guard/index.d.mts +1 -0
  16. package/build/import/type/guard/index.mjs +1 -0
  17. package/build/import/type/guard/kind.d.mts +136 -0
  18. package/build/import/type/guard/kind.mjs +217 -0
  19. package/build/import/type/guard/type.d.mts +2 -2
  20. package/build/import/type/indexed/indexed-from-mapped-result.mjs +5 -3
  21. package/build/import/type/indexed/indexed-property-keys.mjs +5 -4
  22. package/build/import/type/indexed/indexed.mjs +1 -1
  23. package/build/import/type/intersect/intersect-create.mjs +1 -1
  24. package/build/import/type/intersect/intersect-evaluated.mjs +1 -2
  25. package/build/import/type/intersect/intersect.mjs +1 -1
  26. package/build/import/type/intrinsic/intrinsic.mjs +1 -1
  27. package/build/import/type/keyof/keyof-from-mapped-result.mjs +4 -3
  28. package/build/import/type/keyof/keyof-property-keys.mjs +5 -4
  29. package/build/import/type/keyof/keyof.mjs +1 -1
  30. package/build/import/type/mapped/mapped.d.mts +1 -1
  31. package/build/import/type/mapped/mapped.mjs +14 -12
  32. package/build/import/type/object/object.mjs +4 -2
  33. package/build/import/type/omit/omit-from-mapped-result.mjs +4 -3
  34. package/build/import/type/omit/omit.mjs +2 -4
  35. package/build/import/type/optional/optional-from-mapped-result.mjs +4 -3
  36. package/build/import/type/optional/optional.mjs +1 -1
  37. package/build/import/type/partial/partial-from-mapped-result.mjs +4 -3
  38. package/build/import/type/partial/partial.mjs +5 -4
  39. package/build/import/type/pick/pick-from-mapped-result.mjs +4 -3
  40. package/build/import/type/pick/pick.d.mts +1 -1
  41. package/build/import/type/pick/pick.mjs +6 -4
  42. package/build/import/type/readonly/readonly-from-mapped-result.mjs +4 -3
  43. package/build/import/type/readonly/readonly.mjs +1 -1
  44. package/build/import/type/record/record.mjs +5 -3
  45. package/build/import/type/required/required-from-mapped-result.mjs +4 -3
  46. package/build/import/type/required/required.mjs +5 -4
  47. package/build/import/type/rest/rest.mjs +4 -4
  48. package/build/import/type/sets/set.mjs +4 -1
  49. package/build/import/type/template-literal/pattern.mjs +1 -2
  50. package/build/import/type/transform/transform.mjs +1 -1
  51. package/build/import/type/union/union-evaluated.mjs +1 -1
  52. package/build/import/value/clean/clean.mjs +1 -1
  53. package/build/import/value/clone/clone.mjs +8 -2
  54. package/build/import/value/create/create.mjs +11 -7
  55. package/build/import/value/guard/guard.mjs +1 -1
  56. package/build/import/value/hash/hash.mjs +1 -1
  57. package/build/import/value/mutate/mutate.mjs +2 -2
  58. package/build/import/value/transform/decode.mjs +30 -30
  59. package/build/import/value/transform/encode.mjs +33 -30
  60. package/build/require/compiler/compiler.js +2 -2
  61. package/build/require/system/policy.js +1 -2
  62. package/build/require/type/awaited/awaited.js +4 -4
  63. package/build/require/type/clone/value.js +8 -3
  64. package/build/require/type/composite/composite.js +15 -11
  65. package/build/require/type/const/const.js +4 -3
  66. package/build/require/type/deref/deref.d.ts +1 -1
  67. package/build/require/type/deref/deref.js +17 -15
  68. package/build/require/type/exclude/exclude-from-mapped-result.js +4 -3
  69. package/build/require/type/exclude/exclude.js +4 -4
  70. package/build/require/type/extends/extends-from-mapped-result.js +4 -3
  71. package/build/require/type/extends/extends.js +3 -3
  72. package/build/require/type/extract/extract-from-mapped-result.js +4 -3
  73. package/build/require/type/extract/extract.js +4 -4
  74. package/build/require/type/guard/index.d.ts +1 -0
  75. package/build/require/type/guard/index.js +2 -1
  76. package/build/require/type/guard/kind.d.ts +136 -0
  77. package/build/require/type/guard/kind.js +266 -0
  78. package/build/require/type/guard/type.d.ts +2 -2
  79. package/build/require/type/indexed/indexed-from-mapped-result.js +5 -3
  80. package/build/require/type/indexed/indexed-property-keys.js +10 -9
  81. package/build/require/type/indexed/indexed.js +11 -11
  82. package/build/require/type/intersect/intersect-create.js +4 -4
  83. package/build/require/type/intersect/intersect-evaluated.js +4 -5
  84. package/build/require/type/intersect/intersect.js +2 -2
  85. package/build/require/type/intrinsic/intrinsic.js +5 -5
  86. package/build/require/type/keyof/keyof-from-mapped-result.js +4 -3
  87. package/build/require/type/keyof/keyof-property-keys.js +11 -10
  88. package/build/require/type/keyof/keyof.js +2 -2
  89. package/build/require/type/mapped/mapped.d.ts +1 -1
  90. package/build/require/type/mapped/mapped.js +29 -27
  91. package/build/require/type/object/object.js +6 -4
  92. package/build/require/type/omit/omit-from-mapped-result.js +4 -3
  93. package/build/require/type/omit/omit.js +8 -10
  94. package/build/require/type/optional/optional-from-mapped-result.js +4 -3
  95. package/build/require/type/optional/optional.js +2 -2
  96. package/build/require/type/partial/partial-from-mapped-result.js +4 -3
  97. package/build/require/type/partial/partial.js +9 -8
  98. package/build/require/type/pick/pick-from-mapped-result.js +4 -3
  99. package/build/require/type/pick/pick.d.ts +1 -1
  100. package/build/require/type/pick/pick.js +12 -10
  101. package/build/require/type/readonly/readonly-from-mapped-result.js +4 -3
  102. package/build/require/type/readonly/readonly.js +2 -2
  103. package/build/require/type/record/record.js +12 -10
  104. package/build/require/type/required/required-from-mapped-result.js +4 -3
  105. package/build/require/type/required/required.js +9 -8
  106. package/build/require/type/rest/rest.js +4 -4
  107. package/build/require/type/sets/set.js +4 -1
  108. package/build/require/type/template-literal/pattern.js +9 -10
  109. package/build/require/type/transform/transform.js +2 -2
  110. package/build/require/type/union/union-evaluated.js +3 -3
  111. package/build/require/value/clean/clean.js +1 -1
  112. package/build/require/value/clone/clone.js +8 -2
  113. package/build/require/value/create/create.js +11 -7
  114. package/build/require/value/guard/guard.js +1 -1
  115. package/build/require/value/hash/hash.js +1 -1
  116. package/build/require/value/mutate/mutate.js +2 -2
  117. package/build/require/value/transform/decode.js +30 -30
  118. package/build/require/value/transform/encode.js +33 -30
  119. package/package.json +1 -1
  120. package/readme.md +8 -8
@@ -0,0 +1,136 @@
1
+ import { Kind, Hint, TransformKind } from '../symbols/index';
2
+ import { TransformOptions } from '../transform/index';
3
+ import { TTemplateLiteral } from '../template-literal/index';
4
+ import { TArray } from '../array/index';
5
+ import { TBoolean } from '../boolean/index';
6
+ import type { TRecord } from '../record/index';
7
+ import type { TString } from '../string/index';
8
+ import type { TUnion } from '../union/index';
9
+ import type { TAny } from '../any/index';
10
+ import type { TAsyncIterator } from '../async-iterator/index';
11
+ import type { TBigInt } from '../bigint/index';
12
+ import type { TConstructor } from '../constructor/index';
13
+ import type { TFunction } from '../function/index';
14
+ import type { TInteger } from '../integer/index';
15
+ import type { TIntersect } from '../intersect/index';
16
+ import type { TIterator } from '../iterator/index';
17
+ import type { TLiteral } from '../literal/index';
18
+ import type { TMappedKey, TMappedResult } from '../mapped/index';
19
+ import type { TNever } from '../never/index';
20
+ import type { TNot } from '../not/index';
21
+ import type { TNull } from '../null/index';
22
+ import type { TNumber } from '../number/index';
23
+ import type { TObject, TProperties } from '../object/index';
24
+ import type { TOptional } from '../optional/index';
25
+ import type { TPromise } from '../promise/index';
26
+ import type { TReadonly } from '../readonly/index';
27
+ import type { TRef } from '../ref/index';
28
+ import type { TRegExp } from '../regexp/index';
29
+ import type { TSchema } from '../schema/index';
30
+ import type { TSymbol } from '../symbol/index';
31
+ import type { TTuple } from '../tuple/index';
32
+ import type { TUint8Array } from '../uint8array/index';
33
+ import type { TUndefined } from '../undefined/index';
34
+ import type { TUnknown } from '../unknown/index';
35
+ import type { TUnsafe } from '../unsafe/index';
36
+ import type { TVoid } from '../void/index';
37
+ import type { TDate } from '../date/index';
38
+ import type { TThis } from '../recursive/index';
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,266 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.IsSchema = exports.IsKind = exports.IsVoid = exports.IsUnsafe = exports.IsUnknown = exports.IsUint8Array = exports.IsUnion = exports.IsUndefined = exports.IsTuple = exports.IsTransform = exports.IsThis = exports.IsTemplateLiteral = exports.IsSymbol = exports.IsString = exports.IsRegExp = exports.IsRef = exports.IsRecursive = exports.IsRecord = exports.IsPromise = exports.IsObject = exports.IsNumber = exports.IsNull = exports.IsNot = exports.IsNever = exports.IsMappedResult = exports.IsMappedKey = exports.IsLiteral = exports.IsLiteralBoolean = exports.IsLiteralNumber = exports.IsLiteralString = exports.IsKindOf = exports.IsIterator = exports.IsIntersect = exports.IsProperties = exports.IsInteger = exports.IsFunction = exports.IsDate = exports.IsConstructor = exports.IsBoolean = exports.IsBigInt = exports.IsAsyncIterator = exports.IsArray = exports.IsAny = exports.IsOptional = exports.IsReadonly = void 0;
5
+ const ValueGuard = require("./value");
6
+ const index_1 = require("../symbols/index");
7
+ /** `[Kind-Only]` Returns true if this value has a Readonly symbol */
8
+ function IsReadonly(value) {
9
+ return ValueGuard.IsObject(value) && value[index_1.ReadonlyKind] === 'Readonly';
10
+ }
11
+ exports.IsReadonly = IsReadonly;
12
+ /** `[Kind-Only]` Returns true if this value has a Optional symbol */
13
+ function IsOptional(value) {
14
+ return ValueGuard.IsObject(value) && value[index_1.OptionalKind] === 'Optional';
15
+ }
16
+ exports.IsOptional = IsOptional;
17
+ /** `[Kind-Only]` Returns true if the given value is TAny */
18
+ function IsAny(value) {
19
+ return IsKindOf(value, 'Any');
20
+ }
21
+ exports.IsAny = IsAny;
22
+ /** `[Kind-Only]` Returns true if the given value is TArray */
23
+ function IsArray(value) {
24
+ return IsKindOf(value, 'Array');
25
+ }
26
+ exports.IsArray = IsArray;
27
+ /** `[Kind-Only]` Returns true if the given value is TAsyncIterator */
28
+ function IsAsyncIterator(value) {
29
+ return IsKindOf(value, 'AsyncIterator');
30
+ }
31
+ exports.IsAsyncIterator = IsAsyncIterator;
32
+ /** `[Kind-Only]` Returns true if the given value is TBigInt */
33
+ function IsBigInt(value) {
34
+ return IsKindOf(value, 'BigInt');
35
+ }
36
+ exports.IsBigInt = IsBigInt;
37
+ /** `[Kind-Only]` Returns true if the given value is TBoolean */
38
+ function IsBoolean(value) {
39
+ return IsKindOf(value, 'Boolean');
40
+ }
41
+ exports.IsBoolean = IsBoolean;
42
+ /** `[Kind-Only]` Returns true if the given value is TConstructor */
43
+ function IsConstructor(value) {
44
+ return IsKindOf(value, 'Constructor');
45
+ }
46
+ exports.IsConstructor = IsConstructor;
47
+ /** `[Kind-Only]` Returns true if the given value is TDate */
48
+ function IsDate(value) {
49
+ return IsKindOf(value, 'Date');
50
+ }
51
+ exports.IsDate = IsDate;
52
+ /** `[Kind-Only]` Returns true if the given value is TFunction */
53
+ function IsFunction(value) {
54
+ return IsKindOf(value, 'Function');
55
+ }
56
+ exports.IsFunction = IsFunction;
57
+ /** `[Kind-Only]` Returns true if the given value is TInteger */
58
+ function IsInteger(value) {
59
+ return IsKindOf(value, 'Integer');
60
+ }
61
+ exports.IsInteger = IsInteger;
62
+ /** `[Kind-Only]` Returns true if the given schema is TProperties */
63
+ function IsProperties(value) {
64
+ return ValueGuard.IsObject(value);
65
+ }
66
+ exports.IsProperties = IsProperties;
67
+ /** `[Kind-Only]` Returns true if the given value is TIntersect */
68
+ function IsIntersect(value) {
69
+ return IsKindOf(value, 'Intersect');
70
+ }
71
+ exports.IsIntersect = IsIntersect;
72
+ /** `[Kind-Only]` Returns true if the given value is TIterator */
73
+ function IsIterator(value) {
74
+ return IsKindOf(value, 'Iterator');
75
+ }
76
+ exports.IsIterator = IsIterator;
77
+ /** `[Kind-Only]` Returns true if the given value is a TKind with the given name. */
78
+ function IsKindOf(value, kind) {
79
+ return ValueGuard.IsObject(value) && index_1.Kind in value && value[index_1.Kind] === kind;
80
+ }
81
+ exports.IsKindOf = IsKindOf;
82
+ /** `[Kind-Only]` Returns true if the given value is TLiteral<string> */
83
+ function IsLiteralString(value) {
84
+ return IsLiteral(value) && ValueGuard.IsString(value.const);
85
+ }
86
+ exports.IsLiteralString = IsLiteralString;
87
+ /** `[Kind-Only]` Returns true if the given value is TLiteral<number> */
88
+ function IsLiteralNumber(value) {
89
+ return IsLiteral(value) && ValueGuard.IsNumber(value.const);
90
+ }
91
+ exports.IsLiteralNumber = IsLiteralNumber;
92
+ /** `[Kind-Only]` Returns true if the given value is TLiteral<boolean> */
93
+ function IsLiteralBoolean(value) {
94
+ return IsLiteral(value) && ValueGuard.IsBoolean(value.const);
95
+ }
96
+ exports.IsLiteralBoolean = IsLiteralBoolean;
97
+ /** `[Kind-Only]` Returns true if the given value is TLiteral */
98
+ function IsLiteral(value) {
99
+ return IsKindOf(value, 'Literal');
100
+ }
101
+ exports.IsLiteral = IsLiteral;
102
+ /** `[Kind-Only]` Returns true if the given value is a TMappedKey */
103
+ function IsMappedKey(value) {
104
+ return IsKindOf(value, 'MappedKey');
105
+ }
106
+ exports.IsMappedKey = IsMappedKey;
107
+ /** `[Kind-Only]` Returns true if the given value is TMappedResult */
108
+ function IsMappedResult(value) {
109
+ return IsKindOf(value, 'MappedResult');
110
+ }
111
+ exports.IsMappedResult = IsMappedResult;
112
+ /** `[Kind-Only]` Returns true if the given value is TNever */
113
+ function IsNever(value) {
114
+ return IsKindOf(value, 'Never');
115
+ }
116
+ exports.IsNever = IsNever;
117
+ /** `[Kind-Only]` Returns true if the given value is TNot */
118
+ function IsNot(value) {
119
+ return IsKindOf(value, 'Not');
120
+ }
121
+ exports.IsNot = IsNot;
122
+ /** `[Kind-Only]` Returns true if the given value is TNull */
123
+ function IsNull(value) {
124
+ return IsKindOf(value, 'Null');
125
+ }
126
+ exports.IsNull = IsNull;
127
+ /** `[Kind-Only]` Returns true if the given value is TNumber */
128
+ function IsNumber(value) {
129
+ return IsKindOf(value, 'Number');
130
+ }
131
+ exports.IsNumber = IsNumber;
132
+ /** `[Kind-Only]` Returns true if the given value is TObject */
133
+ function IsObject(value) {
134
+ return IsKindOf(value, 'Object');
135
+ }
136
+ exports.IsObject = IsObject;
137
+ /** `[Kind-Only]` Returns true if the given value is TPromise */
138
+ function IsPromise(value) {
139
+ return IsKindOf(value, 'Promise');
140
+ }
141
+ exports.IsPromise = IsPromise;
142
+ /** `[Kind-Only]` Returns true if the given value is TRecord */
143
+ function IsRecord(value) {
144
+ return IsKindOf(value, 'Record');
145
+ }
146
+ exports.IsRecord = IsRecord;
147
+ /** `[Kind-Only]` Returns true if this value is TRecursive */
148
+ function IsRecursive(value) {
149
+ return ValueGuard.IsObject(value) && index_1.Hint in value && value[index_1.Hint] === 'Recursive';
150
+ }
151
+ exports.IsRecursive = IsRecursive;
152
+ /** `[Kind-Only]` Returns true if the given value is TRef */
153
+ function IsRef(value) {
154
+ return IsKindOf(value, 'Ref');
155
+ }
156
+ exports.IsRef = IsRef;
157
+ /** `[Kind-Only]` Returns true if the given value is TRegExp */
158
+ function IsRegExp(value) {
159
+ return IsKindOf(value, 'RegExp');
160
+ }
161
+ exports.IsRegExp = IsRegExp;
162
+ /** `[Kind-Only]` Returns true if the given value is TString */
163
+ function IsString(value) {
164
+ return IsKindOf(value, 'String');
165
+ }
166
+ exports.IsString = IsString;
167
+ /** `[Kind-Only]` Returns true if the given value is TSymbol */
168
+ function IsSymbol(value) {
169
+ return IsKindOf(value, 'Symbol');
170
+ }
171
+ exports.IsSymbol = IsSymbol;
172
+ /** `[Kind-Only]` Returns true if the given value is TTemplateLiteral */
173
+ function IsTemplateLiteral(value) {
174
+ return IsKindOf(value, 'TemplateLiteral');
175
+ }
176
+ exports.IsTemplateLiteral = IsTemplateLiteral;
177
+ /** `[Kind-Only]` Returns true if the given value is TThis */
178
+ function IsThis(value) {
179
+ return IsKindOf(value, 'This');
180
+ }
181
+ exports.IsThis = IsThis;
182
+ /** `[Kind-Only]` Returns true of this value is TTransform */
183
+ function IsTransform(value) {
184
+ return ValueGuard.IsObject(value) && index_1.TransformKind in value;
185
+ }
186
+ exports.IsTransform = IsTransform;
187
+ /** `[Kind-Only]` Returns true if the given value is TTuple */
188
+ function IsTuple(value) {
189
+ return IsKindOf(value, 'Tuple');
190
+ }
191
+ exports.IsTuple = IsTuple;
192
+ /** `[Kind-Only]` Returns true if the given value is TUndefined */
193
+ function IsUndefined(value) {
194
+ return IsKindOf(value, 'Undefined');
195
+ }
196
+ exports.IsUndefined = IsUndefined;
197
+ /** `[Kind-Only]` Returns true if the given value is TUnion */
198
+ function IsUnion(value) {
199
+ return IsKindOf(value, 'Union');
200
+ }
201
+ exports.IsUnion = IsUnion;
202
+ /** `[Kind-Only]` Returns true if the given value is TUint8Array */
203
+ function IsUint8Array(value) {
204
+ return IsKindOf(value, 'Uint8Array');
205
+ }
206
+ exports.IsUint8Array = IsUint8Array;
207
+ /** `[Kind-Only]` Returns true if the given value is TUnknown */
208
+ function IsUnknown(value) {
209
+ return IsKindOf(value, 'Unknown');
210
+ }
211
+ exports.IsUnknown = IsUnknown;
212
+ /** `[Kind-Only]` Returns true if the given value is a raw TUnsafe */
213
+ function IsUnsafe(value) {
214
+ return IsKindOf(value, 'Unsafe');
215
+ }
216
+ exports.IsUnsafe = IsUnsafe;
217
+ /** `[Kind-Only]` Returns true if the given value is TVoid */
218
+ function IsVoid(value) {
219
+ return IsKindOf(value, 'Void');
220
+ }
221
+ exports.IsVoid = IsVoid;
222
+ /** `[Kind-Only]` Returns true if the given value is TKind */
223
+ function IsKind(value) {
224
+ return ValueGuard.IsObject(value) && index_1.Kind in value && ValueGuard.IsString(value[index_1.Kind]);
225
+ }
226
+ exports.IsKind = IsKind;
227
+ /** `[Kind-Only]` Returns true if the given value is TSchema */
228
+ function IsSchema(value) {
229
+ // prettier-ignore
230
+ return (IsAny(value) ||
231
+ IsArray(value) ||
232
+ IsBoolean(value) ||
233
+ IsBigInt(value) ||
234
+ IsAsyncIterator(value) ||
235
+ IsConstructor(value) ||
236
+ IsDate(value) ||
237
+ IsFunction(value) ||
238
+ IsInteger(value) ||
239
+ IsIntersect(value) ||
240
+ IsIterator(value) ||
241
+ IsLiteral(value) ||
242
+ IsMappedKey(value) ||
243
+ IsMappedResult(value) ||
244
+ IsNever(value) ||
245
+ IsNot(value) ||
246
+ IsNull(value) ||
247
+ IsNumber(value) ||
248
+ IsObject(value) ||
249
+ IsPromise(value) ||
250
+ IsRecord(value) ||
251
+ IsRef(value) ||
252
+ IsRegExp(value) ||
253
+ IsString(value) ||
254
+ IsSymbol(value) ||
255
+ IsTemplateLiteral(value) ||
256
+ IsThis(value) ||
257
+ IsTuple(value) ||
258
+ IsUndefined(value) ||
259
+ IsUnion(value) ||
260
+ IsUint8Array(value) ||
261
+ IsUnknown(value) ||
262
+ IsUnsafe(value) ||
263
+ IsVoid(value) ||
264
+ IsKind(value));
265
+ }
266
+ exports.IsSchema = IsSchema;
@@ -1,7 +1,7 @@
1
1
  import { Kind, Hint, TransformKind } from '../symbols/index';
2
2
  import { TypeBoxError } from '../error/index';
3
3
  import { TransformOptions } from '../transform/index';
4
- import { TTemplateLiteral, TTemplateLiteralKind } from '../template-literal/index';
4
+ import { TTemplateLiteral } from '../template-literal/index';
5
5
  import { TArray } from '../array/index';
6
6
  import { TBoolean } from '../boolean/index';
7
7
  import type { TRecord } from '../record/index';
@@ -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 */
@@ -7,9 +7,11 @@ const indexed_property_keys_1 = require("./indexed-property-keys");
7
7
  const index_2 = require("./index");
8
8
  // prettier-ignore
9
9
  function FromProperties(T, P, options) {
10
- return globalThis.Object.getOwnPropertyNames(P).reduce((Acc, K2) => {
11
- return { ...Acc, [K2]: (0, index_2.Index)(T, (0, indexed_property_keys_1.IndexPropertyKeys)(P[K2]), options) };
12
- }, {});
10
+ const Acc = {};
11
+ for (const K2 of Object.getOwnPropertyNames(P)) {
12
+ Acc[K2] = (0, index_2.Index)(T, (0, indexed_property_keys_1.IndexPropertyKeys)(P[K2]), options);
13
+ }
14
+ return Acc;
13
15
  }
14
16
  // prettier-ignore
15
17
  function FromMappedResult(T, R, options) {
@@ -6,7 +6,7 @@ const index_1 = require("../template-literal/index");
6
6
  // ------------------------------------------------------------------
7
7
  // TypeGuard
8
8
  // ------------------------------------------------------------------
9
- const type_1 = require("../guard/type");
9
+ const kind_1 = require("../guard/kind");
10
10
  // prettier-ignore
11
11
  function FromTemplateLiteral(T) {
12
12
  const R = (0, index_1.TemplateLiteralGenerate)(T);
@@ -14,9 +14,10 @@ function FromTemplateLiteral(T) {
14
14
  }
15
15
  // prettier-ignore
16
16
  function FromUnion(T) {
17
- return T.reduce((Acc, L) => {
18
- return [...Acc, ...IndexPropertyKeys(L)];
19
- }, []);
17
+ const Acc = [];
18
+ for (const L of T)
19
+ Acc.push(...IndexPropertyKeys(L));
20
+ return Acc;
20
21
  }
21
22
  // prettier-ignore
22
23
  function FromLiteral(T) {
@@ -26,11 +27,11 @@ function FromLiteral(T) {
26
27
  /** Returns a tuple of PropertyKeys derived from the given TSchema */
27
28
  // prettier-ignore
28
29
  function IndexPropertyKeys(T) {
29
- return [...new Set(((0, type_1.IsTemplateLiteral)(T) ? FromTemplateLiteral(T) :
30
- (0, type_1.IsUnion)(T) ? FromUnion(T.anyOf) :
31
- (0, type_1.IsLiteral)(T) ? FromLiteral(T.const) :
32
- (0, type_1.IsNumber)(T) ? ['[number]'] :
33
- (0, type_1.IsInteger)(T) ? ['[number]'] :
30
+ return [...new Set(((0, kind_1.IsTemplateLiteral)(T) ? FromTemplateLiteral(T) :
31
+ (0, kind_1.IsUnion)(T) ? FromUnion(T.anyOf) :
32
+ (0, kind_1.IsLiteral)(T) ? FromLiteral(T.const) :
33
+ (0, kind_1.IsNumber)(T) ? ['[number]'] :
34
+ (0, kind_1.IsInteger)(T) ? ['[number]'] :
34
35
  []))];
35
36
  }
36
37
  exports.IndexPropertyKeys = IndexPropertyKeys;
@@ -12,14 +12,14 @@ const indexed_from_mapped_result_1 = require("./indexed-from-mapped-result");
12
12
  // ------------------------------------------------------------------
13
13
  // TypeGuard
14
14
  // ------------------------------------------------------------------
15
- const type_2 = require("../guard/type");
15
+ const kind_1 = require("../guard/kind");
16
16
  // prettier-ignore
17
17
  function FromRest(T, K) {
18
18
  return T.map(L => IndexFromPropertyKey(L, K));
19
19
  }
20
20
  // prettier-ignore
21
21
  function FromIntersectRest(T) {
22
- return T.filter(L => !(0, type_2.IsNever)(L));
22
+ return T.filter(L => !(0, kind_1.IsNever)(L));
23
23
  }
24
24
  // prettier-ignore
25
25
  function FromIntersect(T, K) {
@@ -27,7 +27,7 @@ function FromIntersect(T, K) {
27
27
  }
28
28
  // prettier-ignore
29
29
  function FromUnionRest(T) {
30
- return (T.some(L => (0, type_2.IsNever)(L))
30
+ return (T.some(L => (0, kind_1.IsNever)(L))
31
31
  ? []
32
32
  : T);
33
33
  }
@@ -53,11 +53,11 @@ function FromProperty(T, K) {
53
53
  }
54
54
  // prettier-ignore
55
55
  function IndexFromPropertyKey(T, K) {
56
- return ((0, type_2.IsIntersect)(T) ? FromIntersect(T.allOf, K) :
57
- (0, type_2.IsUnion)(T) ? FromUnion(T.anyOf, K) :
58
- (0, type_2.IsTuple)(T) ? FromTuple(T.items ?? [], K) :
59
- (0, type_2.IsArray)(T) ? FromArray(T.items, K) :
60
- (0, type_2.IsObject)(T) ? FromProperty(T.properties, K) :
56
+ return ((0, kind_1.IsIntersect)(T) ? FromIntersect(T.allOf, K) :
57
+ (0, kind_1.IsUnion)(T) ? FromUnion(T.anyOf, K) :
58
+ (0, kind_1.IsTuple)(T) ? FromTuple(T.items ?? [], K) :
59
+ (0, kind_1.IsArray)(T) ? FromArray(T.items, K) :
60
+ (0, kind_1.IsObject)(T) ? FromProperty(T.properties, K) :
61
61
  (0, index_1.Never)());
62
62
  }
63
63
  exports.IndexFromPropertyKey = IndexFromPropertyKey;
@@ -73,9 +73,9 @@ function FromSchema(T, K) {
73
73
  /** `[Json]` Returns an Indexed property type for the given keys */
74
74
  function Index(T, K, options = {}) {
75
75
  // prettier-ignore
76
- return ((0, type_2.IsMappedResult)(K) ? (0, type_1.CloneType)((0, indexed_from_mapped_result_1.IndexFromMappedResult)(T, K, options)) :
77
- (0, type_2.IsMappedKey)(K) ? (0, type_1.CloneType)((0, indexed_from_mapped_key_1.IndexFromMappedKey)(T, K, options)) :
78
- (0, type_2.IsSchema)(K) ? (0, type_1.CloneType)(FromSchema(T, (0, indexed_property_keys_1.IndexPropertyKeys)(K)), options) :
76
+ return ((0, kind_1.IsMappedResult)(K) ? (0, type_1.CloneType)((0, indexed_from_mapped_result_1.IndexFromMappedResult)(T, K, options)) :
77
+ (0, kind_1.IsMappedKey)(K) ? (0, type_1.CloneType)((0, indexed_from_mapped_key_1.IndexFromMappedKey)(T, K, options)) :
78
+ (0, kind_1.IsSchema)(K) ? (0, type_1.CloneType)(FromSchema(T, (0, indexed_property_keys_1.IndexPropertyKeys)(K)), options) :
79
79
  (0, type_1.CloneType)(FromSchema(T, K), options));
80
80
  }
81
81
  exports.Index = Index;
@@ -7,17 +7,17 @@ const type_1 = require("../clone/type");
7
7
  // ------------------------------------------------------------------
8
8
  // TypeGuard
9
9
  // ------------------------------------------------------------------
10
- const type_2 = require("../guard/type");
10
+ const kind_1 = require("../guard/kind");
11
11
  // ------------------------------------------------------------------
12
12
  // IntersectCreate
13
13
  // ------------------------------------------------------------------
14
14
  // prettier-ignore
15
15
  function IntersectCreate(T, options) {
16
- const allObjects = T.every((schema) => (0, type_2.IsObject)(schema));
17
- const clonedUnevaluatedProperties = (0, type_2.IsSchema)(options.unevaluatedProperties)
16
+ const allObjects = T.every((schema) => (0, kind_1.IsObject)(schema));
17
+ const clonedUnevaluatedProperties = (0, kind_1.IsSchema)(options.unevaluatedProperties)
18
18
  ? { unevaluatedProperties: (0, type_1.CloneType)(options.unevaluatedProperties) }
19
19
  : {};
20
- return ((options.unevaluatedProperties === false || (0, type_2.IsSchema)(options.unevaluatedProperties) || allObjects
20
+ return ((options.unevaluatedProperties === false || (0, kind_1.IsSchema)(options.unevaluatedProperties) || allObjects
21
21
  ? { ...options, ...clonedUnevaluatedProperties, [index_1.Kind]: 'Intersect', type: 'object', allOf: (0, type_1.CloneRest)(T) }
22
22
  : { ...options, ...clonedUnevaluatedProperties, [index_1.Kind]: 'Intersect', allOf: (0, type_1.CloneRest)(T) }));
23
23
  }
@@ -11,11 +11,10 @@ const intersect_create_1 = require("./intersect-create");
11
11
  // ------------------------------------------------------------------
12
12
  // TypeGuard
13
13
  // ------------------------------------------------------------------
14
- // prettier-ignore
15
- const type_2 = require("../guard/type");
14
+ const kind_1 = require("../guard/kind");
16
15
  // prettier-ignore
17
16
  function IsIntersectOptional(T) {
18
- return T.every(L => (0, type_2.IsOptional)(L));
17
+ return T.every(L => (0, kind_1.IsOptional)(L));
19
18
  }
20
19
  // prettier-ignore
21
20
  function RemoveOptionalFromType(T) {
@@ -23,7 +22,7 @@ function RemoveOptionalFromType(T) {
23
22
  }
24
23
  // prettier-ignore
25
24
  function RemoveOptionalFromRest(T) {
26
- return T.map(L => (0, type_2.IsOptional)(L) ? RemoveOptionalFromType(L) : L);
25
+ return T.map(L => (0, kind_1.IsOptional)(L) ? RemoveOptionalFromType(L) : L);
27
26
  }
28
27
  // prettier-ignore
29
28
  function ResolveIntersect(T, options) {
@@ -37,7 +36,7 @@ function IntersectEvaluated(T, options = {}) {
37
36
  return (0, index_3.Never)(options);
38
37
  if (T.length === 1)
39
38
  return (0, type_1.CloneType)(T[0], options);
40
- if (T.some((schema) => (0, type_2.IsTransform)(schema)))
39
+ if (T.some((schema) => (0, kind_1.IsTransform)(schema)))
41
40
  throw new Error('Cannot intersect transform types');
42
41
  return ResolveIntersect(T, options);
43
42
  }
@@ -8,14 +8,14 @@ const intersect_create_1 = require("./intersect-create");
8
8
  // ------------------------------------------------------------------
9
9
  // TypeGuard
10
10
  // ------------------------------------------------------------------
11
- const type_2 = require("../guard/type");
11
+ const kind_1 = require("../guard/kind");
12
12
  /** `[Json]` Creates an evaluated Intersect type */
13
13
  function Intersect(T, options = {}) {
14
14
  if (T.length === 0)
15
15
  return (0, index_1.Never)(options);
16
16
  if (T.length === 1)
17
17
  return (0, type_1.CloneType)(T[0], options);
18
- if (T.some((schema) => (0, type_2.IsTransform)(schema)))
18
+ if (T.some((schema) => (0, kind_1.IsTransform)(schema)))
19
19
  throw new Error('Cannot intersect transform types');
20
20
  return (0, intersect_create_1.IntersectCreate)(T, options);
21
21
  }
@@ -9,7 +9,7 @@ const index_3 = require("../union/index");
9
9
  // ------------------------------------------------------------------
10
10
  // TypeGuard
11
11
  // ------------------------------------------------------------------
12
- const type_1 = require("../guard/type");
12
+ const kind_1 = require("../guard/kind");
13
13
  // ------------------------------------------------------------------
14
14
  // Apply
15
15
  // ------------------------------------------------------------------
@@ -57,11 +57,11 @@ function Intrinsic(schema, mode, options = {}) {
57
57
  // prettier-ignore
58
58
  return (
59
59
  // Intrinsic-Mapped-Inference
60
- (0, type_1.IsMappedKey)(schema) ? (0, intrinsic_from_mapped_key_1.IntrinsicFromMappedKey)(schema, mode, options) :
60
+ (0, kind_1.IsMappedKey)(schema) ? (0, intrinsic_from_mapped_key_1.IntrinsicFromMappedKey)(schema, mode, options) :
61
61
  // Standard-Inference
62
- (0, type_1.IsTemplateLiteral)(schema) ? FromTemplateLiteral(schema, mode, schema) :
63
- (0, type_1.IsUnion)(schema) ? (0, index_3.Union)(FromRest(schema.anyOf, mode), options) :
64
- (0, type_1.IsLiteral)(schema) ? (0, index_2.Literal)(FromLiteralValue(schema.const, mode), options) :
62
+ (0, kind_1.IsTemplateLiteral)(schema) ? FromTemplateLiteral(schema, mode, schema) :
63
+ (0, kind_1.IsUnion)(schema) ? (0, index_3.Union)(FromRest(schema.anyOf, mode), options) :
64
+ (0, kind_1.IsLiteral)(schema) ? (0, index_2.Literal)(FromLiteralValue(schema.const, mode), options) :
65
65
  schema);
66
66
  }
67
67
  exports.Intrinsic = Intrinsic;
@@ -6,9 +6,10 @@ const index_1 = require("../mapped/index");
6
6
  const keyof_1 = require("./keyof");
7
7
  // prettier-ignore
8
8
  function FromProperties(K, options) {
9
- return globalThis.Object.getOwnPropertyNames(K).reduce((Acc, K2) => {
10
- return { ...Acc, [K2]: (0, keyof_1.KeyOf)(K[K2], options) };
11
- }, {});
9
+ const Acc = {};
10
+ for (const K2 of globalThis.Object.getOwnPropertyNames(K))
11
+ Acc[K2] = (0, keyof_1.KeyOf)(K[K2], options);
12
+ return Acc;
12
13
  }
13
14
  // prettier-ignore
14
15
  function FromMappedResult(R, options) {