typebox 1.0.71 → 1.0.73
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.
|
@@ -16,7 +16,7 @@ import { AsyncIterator, IsAsyncIterator, AsyncIteratorOptions } from '../types/a
|
|
|
16
16
|
import { IsBase } from '../types/base.mjs';
|
|
17
17
|
import { Constructor, IsConstructor, ConstructorOptions } from '../types/constructor.mjs';
|
|
18
18
|
import { Deferred, IsDeferred } from '../types/deferred.mjs';
|
|
19
|
-
import {
|
|
19
|
+
import { _Function_, IsFunction, FunctionOptions } from '../types/function.mjs';
|
|
20
20
|
import { IsCall } from '../types/call.mjs';
|
|
21
21
|
import { Intersect, IsIntersect, IntersectOptions } from '../types/intersect.mjs';
|
|
22
22
|
import { Iterator, IsIterator, IteratorOptions } from '../types/iterator.mjs';
|
|
@@ -152,7 +152,7 @@ export function InstantiateType(context, state, input) {
|
|
|
152
152
|
IsCall(type) ? CallInstantiate(context, state, type.target, type.arguments) :
|
|
153
153
|
IsConstructor(type) ? Constructor(InstantiateTypes(context, state, type.parameters), InstantiateType(context, state, type.instanceType), ConstructorOptions(type)) :
|
|
154
154
|
IsDeferred(type) ? InstantiateDeferred(context, state, type.action, type.parameters, type.options) :
|
|
155
|
-
IsFunction(type) ?
|
|
155
|
+
IsFunction(type) ? _Function_(InstantiateTypes(context, state, type.parameters), InstantiateType(context, state, type.returnType), FunctionOptions(type)) :
|
|
156
156
|
IsIntersect(type) ? Intersect(InstantiateTypes(context, state, type.allOf), IntersectOptions(type)) :
|
|
157
157
|
IsIterator(type) ? Iterator(InstantiateType(context, state, type.iteratorItems), IteratorOptions(type)) :
|
|
158
158
|
IsObject(type) ? Object(InstantiateProperties(context, state, type.properties), ObjectOptions(type)) :
|
|
@@ -371,7 +371,7 @@ export function ParameterListMapping(input) {
|
|
|
371
371
|
return Delimited(input);
|
|
372
372
|
}
|
|
373
373
|
export function _Function_Mapping(input) {
|
|
374
|
-
return T.
|
|
374
|
+
return T._Function_(input[1], input[4]);
|
|
375
375
|
}
|
|
376
376
|
export function ConstructorMapping(input) {
|
|
377
377
|
return T.Constructor(input[2], input[5]);
|
|
@@ -13,7 +13,8 @@ export interface TFunction<Parameters extends TSchema[] = TSchema[], ReturnType
|
|
|
13
13
|
returnType: ReturnType;
|
|
14
14
|
}
|
|
15
15
|
/** Creates a Function type. */
|
|
16
|
-
export declare function
|
|
16
|
+
export declare function _Function_<Parameters extends TSchema[], ReturnType extends TSchema>(parameters: [...Parameters], returnType: ReturnType, options?: TSchemaOptions): TFunction<Parameters, ReturnType>;
|
|
17
|
+
export { _Function_ as Function };
|
|
17
18
|
/** Returns true if the given value is TFunction. */
|
|
18
19
|
export declare function IsFunction(value: unknown): value is TFunction;
|
|
19
20
|
/** Extracts options from a TFunction. */
|
|
@@ -5,9 +5,10 @@ import { IsKind } from './schema.mjs';
|
|
|
5
5
|
// Factory
|
|
6
6
|
// ------------------------------------------------------------------
|
|
7
7
|
/** Creates a Function type. */
|
|
8
|
-
export function
|
|
8
|
+
export function _Function_(parameters, returnType, options = {}) {
|
|
9
9
|
return Memory.Create({ ['~kind']: 'Function' }, { type: 'function', parameters, returnType }, options);
|
|
10
10
|
}
|
|
11
|
+
export { _Function_ as Function };
|
|
11
12
|
// ------------------------------------------------------------------
|
|
12
13
|
// Guard
|
|
13
14
|
// ------------------------------------------------------------------
|
|
@@ -10,11 +10,9 @@ export interface TObject<Properties extends TProperties = TProperties> extends T
|
|
|
10
10
|
required: TRequiredArray<Properties>;
|
|
11
11
|
}
|
|
12
12
|
/** Creates an Object type. */
|
|
13
|
-
declare function _Object_<Properties extends TProperties>(properties: Properties, options?: TObjectOptions): TObject<Properties>;
|
|
14
|
-
|
|
15
|
-
export declare var Object: typeof _Object_;
|
|
13
|
+
export declare function _Object_<Properties extends TProperties>(properties: Properties, options?: TObjectOptions): TObject<Properties>;
|
|
14
|
+
export { _Object_ as Object };
|
|
16
15
|
/** Returns true if the given value is TObject. */
|
|
17
16
|
export declare function IsObject(value: unknown): value is TObject;
|
|
18
17
|
/** Extracts options from a TObject. */
|
|
19
18
|
export declare function ObjectOptions(type: TObject): TObjectOptions;
|
|
20
|
-
export {};
|
|
@@ -6,13 +6,12 @@ import { RequiredArray } from './properties.mjs';
|
|
|
6
6
|
// Factory
|
|
7
7
|
// ------------------------------------------------------------------
|
|
8
8
|
/** Creates an Object type. */
|
|
9
|
-
function _Object_(properties, options = {}) {
|
|
9
|
+
export function _Object_(properties, options = {}) {
|
|
10
10
|
const requiredKeys = RequiredArray(properties);
|
|
11
11
|
const required = requiredKeys.length > 0 ? { required: requiredKeys } : {};
|
|
12
12
|
return Memory.Create({ '~kind': 'Object' }, { type: 'object', ...required, properties }, options);
|
|
13
13
|
}
|
|
14
|
-
|
|
15
|
-
export var Object = _Object_; // Required for CommonJS ES Interop
|
|
14
|
+
export { _Object_ as Object }; // Required for CommonJS ES Interop
|
|
16
15
|
// ------------------------------------------------------------------
|
|
17
16
|
// Guard
|
|
18
17
|
// ------------------------------------------------------------------
|