@sinclair/typebox 0.34.5 → 0.34.6
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.
|
@@ -199,7 +199,11 @@ function IsBoolean(value) {
|
|
|
199
199
|
}
|
|
200
200
|
/** Returns true if the given value is TComputed */
|
|
201
201
|
function IsComputed(value) {
|
|
202
|
-
|
|
202
|
+
// prettier-ignore
|
|
203
|
+
return (IsKindOf(value, 'Computed') &&
|
|
204
|
+
ValueGuard.IsString(value.target) &&
|
|
205
|
+
ValueGuard.IsArray(value.parameters) &&
|
|
206
|
+
value.parameters.every((schema) => IsSchema(schema)));
|
|
203
207
|
}
|
|
204
208
|
/** Returns true if the given value is TConstructor */
|
|
205
209
|
function IsConstructor(value) {
|
|
@@ -517,6 +521,7 @@ function IsSchema(value) {
|
|
|
517
521
|
IsBoolean(value) ||
|
|
518
522
|
IsBigInt(value) ||
|
|
519
523
|
IsAsyncIterator(value) ||
|
|
524
|
+
IsComputed(value) ||
|
|
520
525
|
IsConstructor(value) ||
|
|
521
526
|
IsDate(value) ||
|
|
522
527
|
IsFunction(value) ||
|
|
@@ -145,7 +145,11 @@ export function IsBoolean(value) {
|
|
|
145
145
|
}
|
|
146
146
|
/** Returns true if the given value is TComputed */
|
|
147
147
|
export function IsComputed(value) {
|
|
148
|
-
|
|
148
|
+
// prettier-ignore
|
|
149
|
+
return (IsKindOf(value, 'Computed') &&
|
|
150
|
+
ValueGuard.IsString(value.target) &&
|
|
151
|
+
ValueGuard.IsArray(value.parameters) &&
|
|
152
|
+
value.parameters.every((schema) => IsSchema(schema)));
|
|
149
153
|
}
|
|
150
154
|
/** Returns true if the given value is TConstructor */
|
|
151
155
|
export function IsConstructor(value) {
|
|
@@ -463,6 +467,7 @@ export function IsSchema(value) {
|
|
|
463
467
|
IsBoolean(value) ||
|
|
464
468
|
IsBigInt(value) ||
|
|
465
469
|
IsAsyncIterator(value) ||
|
|
470
|
+
IsComputed(value) ||
|
|
466
471
|
IsConstructor(value) ||
|
|
467
472
|
IsDate(value) ||
|
|
468
473
|
IsFunction(value) ||
|
|
@@ -4,7 +4,7 @@ import { Awaited } from '../awaited/index.mjs';
|
|
|
4
4
|
import { AsyncIterator } from '../async-iterator/index.mjs';
|
|
5
5
|
import { Constructor } from '../constructor/index.mjs';
|
|
6
6
|
import { Index } from '../indexed/index.mjs';
|
|
7
|
-
import { Function } from '../function/index.mjs';
|
|
7
|
+
import { Function as FunctionType } from '../function/index.mjs';
|
|
8
8
|
import { Intersect } from '../intersect/index.mjs';
|
|
9
9
|
import { Iterator } from '../iterator/index.mjs';
|
|
10
10
|
import { KeyOf } from '../keyof/index.mjs';
|
|
@@ -93,7 +93,7 @@ function FromConstructor(moduleProperties, parameters, instanceType) {
|
|
|
93
93
|
}
|
|
94
94
|
// prettier-ignore
|
|
95
95
|
function FromFunction(moduleProperties, parameters, returnType) {
|
|
96
|
-
return
|
|
96
|
+
return FunctionType(FromRest(moduleProperties, parameters), FromType(moduleProperties, returnType));
|
|
97
97
|
}
|
|
98
98
|
function FromTuple(moduleProperties, types) {
|
|
99
99
|
return Tuple(FromRest(moduleProperties, types));
|