@sinclair/typebox 0.34.13 → 0.34.15
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.
- package/build/cjs/compiler/compiler.js +1 -1
- package/build/cjs/value/convert/convert.js +1 -1
- package/build/cjs/value/guard/guard.js +8 -8
- package/build/esm/compiler/compiler.mjs +1 -1
- package/build/esm/value/convert/convert.mjs +1 -1
- package/build/esm/value/guard/guard.mjs +8 -8
- package/license +1 -1
- package/package.json +1 -1
- package/readme.md +0 -1
|
@@ -376,7 +376,7 @@ var TypeCompiler;
|
|
|
376
376
|
}
|
|
377
377
|
}
|
|
378
378
|
function* FromPromise(schema, references, value) {
|
|
379
|
-
yield
|
|
379
|
+
yield `${value} instanceof Promise`;
|
|
380
380
|
}
|
|
381
381
|
function* FromRecord(schema, references, value) {
|
|
382
382
|
yield Policy.IsRecordLike(value);
|
|
@@ -76,7 +76,7 @@ function TryConvertNumber(value) {
|
|
|
76
76
|
return IsStringNumeric(value) ? parseFloat(value) : IsValueTrue(value) ? 1 : IsValueFalse(value) ? 0 : value;
|
|
77
77
|
}
|
|
78
78
|
function TryConvertInteger(value) {
|
|
79
|
-
return IsStringNumeric(value) ? parseInt(value) : (0, index_5.IsNumber)(value) ? value
|
|
79
|
+
return IsStringNumeric(value) ? parseInt(value) : (0, index_5.IsNumber)(value) ? Math.trunc(value) : IsValueTrue(value) ? 1 : IsValueFalse(value) ? 0 : value;
|
|
80
80
|
}
|
|
81
81
|
function TryConvertNull(value) {
|
|
82
82
|
return (0, index_5.IsString)(value) && value.toLowerCase() === 'null' ? null : value;
|
|
@@ -40,18 +40,18 @@ exports.IsValueType = IsValueType;
|
|
|
40
40
|
// --------------------------------------------------------------------------
|
|
41
41
|
/** Returns true if this value is an async iterator */
|
|
42
42
|
function IsAsyncIterator(value) {
|
|
43
|
-
return IsObject(value) && Symbol.asyncIterator in value;
|
|
43
|
+
return IsObject(value) && globalThis.Symbol.asyncIterator in value;
|
|
44
44
|
}
|
|
45
45
|
/** Returns true if this value is an iterator */
|
|
46
46
|
function IsIterator(value) {
|
|
47
|
-
return IsObject(value) && Symbol.iterator in value;
|
|
47
|
+
return IsObject(value) && globalThis.Symbol.iterator in value;
|
|
48
48
|
}
|
|
49
49
|
// --------------------------------------------------------------------------
|
|
50
50
|
// Object Instances
|
|
51
51
|
// --------------------------------------------------------------------------
|
|
52
52
|
/** Returns true if this value is not an instance of a class */
|
|
53
53
|
function IsStandardObject(value) {
|
|
54
|
-
return IsObject(value) && (Object.getPrototypeOf(value) === Object.prototype || Object.getPrototypeOf(value) === null);
|
|
54
|
+
return IsObject(value) && (globalThis.Object.getPrototypeOf(value) === Object.prototype || globalThis.Object.getPrototypeOf(value) === null);
|
|
55
55
|
}
|
|
56
56
|
/** Returns true if this value is an instance of a class */
|
|
57
57
|
function IsInstanceObject(value) {
|
|
@@ -62,11 +62,11 @@ function IsInstanceObject(value) {
|
|
|
62
62
|
// --------------------------------------------------------------------------
|
|
63
63
|
/** Returns true if this value is a Promise */
|
|
64
64
|
function IsPromise(value) {
|
|
65
|
-
return value instanceof Promise;
|
|
65
|
+
return value instanceof globalThis.Promise;
|
|
66
66
|
}
|
|
67
67
|
/** Returns true if this value is a Date */
|
|
68
68
|
function IsDate(value) {
|
|
69
|
-
return value instanceof Date && Number.isFinite(value.getTime());
|
|
69
|
+
return value instanceof Date && globalThis.Number.isFinite(value.getTime());
|
|
70
70
|
}
|
|
71
71
|
/** Returns true if this value is an instance of Map<K, T> */
|
|
72
72
|
function IsMap(value) {
|
|
@@ -82,7 +82,7 @@ function IsRegExp(value) {
|
|
|
82
82
|
}
|
|
83
83
|
/** Returns true if this value is a typed array */
|
|
84
84
|
function IsTypedArray(value) {
|
|
85
|
-
return ArrayBuffer.isView(value);
|
|
85
|
+
return globalThis.ArrayBuffer.isView(value);
|
|
86
86
|
}
|
|
87
87
|
/** Returns true if the value is a Int8Array */
|
|
88
88
|
function IsInt8Array(value) {
|
|
@@ -144,7 +144,7 @@ function IsObject(value) {
|
|
|
144
144
|
}
|
|
145
145
|
/** Returns true if this value is an array, but not a typed array */
|
|
146
146
|
function IsArray(value) {
|
|
147
|
-
return Array.isArray(value) && !ArrayBuffer.isView(value);
|
|
147
|
+
return globalThis.Array.isArray(value) && !globalThis.ArrayBuffer.isView(value);
|
|
148
148
|
}
|
|
149
149
|
/** Returns true if this value is an undefined */
|
|
150
150
|
function IsUndefined(value) {
|
|
@@ -164,7 +164,7 @@ function IsNumber(value) {
|
|
|
164
164
|
}
|
|
165
165
|
/** Returns true if this value is an integer */
|
|
166
166
|
function IsInteger(value) {
|
|
167
|
-
return Number.isInteger(value);
|
|
167
|
+
return globalThis.Number.isInteger(value);
|
|
168
168
|
}
|
|
169
169
|
/** Returns true if this value is bigint */
|
|
170
170
|
function IsBigInt(value) {
|
|
@@ -369,7 +369,7 @@ export var TypeCompiler;
|
|
|
369
369
|
}
|
|
370
370
|
}
|
|
371
371
|
function* FromPromise(schema, references, value) {
|
|
372
|
-
yield
|
|
372
|
+
yield `${value} instanceof Promise`;
|
|
373
373
|
}
|
|
374
374
|
function* FromRecord(schema, references, value) {
|
|
375
375
|
yield Policy.IsRecordLike(value);
|
|
@@ -72,7 +72,7 @@ function TryConvertNumber(value) {
|
|
|
72
72
|
return IsStringNumeric(value) ? parseFloat(value) : IsValueTrue(value) ? 1 : IsValueFalse(value) ? 0 : value;
|
|
73
73
|
}
|
|
74
74
|
function TryConvertInteger(value) {
|
|
75
|
-
return IsStringNumeric(value) ? parseInt(value) : IsNumber(value) ? value
|
|
75
|
+
return IsStringNumeric(value) ? parseInt(value) : IsNumber(value) ? Math.trunc(value) : IsValueTrue(value) ? 1 : IsValueFalse(value) ? 0 : value;
|
|
76
76
|
}
|
|
77
77
|
function TryConvertNull(value) {
|
|
78
78
|
return IsString(value) && value.toLowerCase() === 'null' ? null : value;
|
|
@@ -3,18 +3,18 @@
|
|
|
3
3
|
// --------------------------------------------------------------------------
|
|
4
4
|
/** Returns true if this value is an async iterator */
|
|
5
5
|
export function IsAsyncIterator(value) {
|
|
6
|
-
return IsObject(value) && Symbol.asyncIterator in value;
|
|
6
|
+
return IsObject(value) && globalThis.Symbol.asyncIterator in value;
|
|
7
7
|
}
|
|
8
8
|
/** Returns true if this value is an iterator */
|
|
9
9
|
export function IsIterator(value) {
|
|
10
|
-
return IsObject(value) && Symbol.iterator in value;
|
|
10
|
+
return IsObject(value) && globalThis.Symbol.iterator in value;
|
|
11
11
|
}
|
|
12
12
|
// --------------------------------------------------------------------------
|
|
13
13
|
// Object Instances
|
|
14
14
|
// --------------------------------------------------------------------------
|
|
15
15
|
/** Returns true if this value is not an instance of a class */
|
|
16
16
|
export function IsStandardObject(value) {
|
|
17
|
-
return IsObject(value) && (Object.getPrototypeOf(value) === Object.prototype || Object.getPrototypeOf(value) === null);
|
|
17
|
+
return IsObject(value) && (globalThis.Object.getPrototypeOf(value) === Object.prototype || globalThis.Object.getPrototypeOf(value) === null);
|
|
18
18
|
}
|
|
19
19
|
/** Returns true if this value is an instance of a class */
|
|
20
20
|
export function IsInstanceObject(value) {
|
|
@@ -25,11 +25,11 @@ export function IsInstanceObject(value) {
|
|
|
25
25
|
// --------------------------------------------------------------------------
|
|
26
26
|
/** Returns true if this value is a Promise */
|
|
27
27
|
export function IsPromise(value) {
|
|
28
|
-
return value instanceof Promise;
|
|
28
|
+
return value instanceof globalThis.Promise;
|
|
29
29
|
}
|
|
30
30
|
/** Returns true if this value is a Date */
|
|
31
31
|
export function IsDate(value) {
|
|
32
|
-
return value instanceof Date && Number.isFinite(value.getTime());
|
|
32
|
+
return value instanceof Date && globalThis.Number.isFinite(value.getTime());
|
|
33
33
|
}
|
|
34
34
|
/** Returns true if this value is an instance of Map<K, T> */
|
|
35
35
|
export function IsMap(value) {
|
|
@@ -45,7 +45,7 @@ export function IsRegExp(value) {
|
|
|
45
45
|
}
|
|
46
46
|
/** Returns true if this value is a typed array */
|
|
47
47
|
export function IsTypedArray(value) {
|
|
48
|
-
return ArrayBuffer.isView(value);
|
|
48
|
+
return globalThis.ArrayBuffer.isView(value);
|
|
49
49
|
}
|
|
50
50
|
/** Returns true if the value is a Int8Array */
|
|
51
51
|
export function IsInt8Array(value) {
|
|
@@ -107,7 +107,7 @@ export function IsObject(value) {
|
|
|
107
107
|
}
|
|
108
108
|
/** Returns true if this value is an array, but not a typed array */
|
|
109
109
|
export function IsArray(value) {
|
|
110
|
-
return Array.isArray(value) && !ArrayBuffer.isView(value);
|
|
110
|
+
return globalThis.Array.isArray(value) && !globalThis.ArrayBuffer.isView(value);
|
|
111
111
|
}
|
|
112
112
|
/** Returns true if this value is an undefined */
|
|
113
113
|
export function IsUndefined(value) {
|
|
@@ -127,7 +127,7 @@ export function IsNumber(value) {
|
|
|
127
127
|
}
|
|
128
128
|
/** Returns true if this value is an integer */
|
|
129
129
|
export function IsInteger(value) {
|
|
130
|
-
return Number.isInteger(value);
|
|
130
|
+
return globalThis.Number.isInteger(value);
|
|
131
131
|
}
|
|
132
132
|
/** Returns true if this value is bigint */
|
|
133
133
|
export function IsBigInt(value) {
|
package/license
CHANGED
|
@@ -4,7 +4,7 @@ Json Schema Type Builder with Static Type Resolution for TypeScript
|
|
|
4
4
|
|
|
5
5
|
The MIT License (MIT)
|
|
6
6
|
|
|
7
|
-
Copyright (c) 2017-
|
|
7
|
+
Copyright (c) 2017-2025 Haydn Paterson (sinclair) <haydn.developer@gmail.com>
|
|
8
8
|
|
|
9
9
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
10
10
|
of this software and associated documentation files (the "Software"), to deal
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -1779,7 +1779,6 @@ The following is a list of community packages that offer general tooling, extend
|
|
|
1779
1779
|
| [sveltekit-superforms](https://github.com/ciscoheat/sveltekit-superforms) | A comprehensive SvelteKit form library for server and client validation |
|
|
1780
1780
|
| [ts2typebox](https://github.com/xddq/ts2typebox) | Creating TypeBox code from Typescript types |
|
|
1781
1781
|
| [typebox-form-parser](https://github.com/jtlapp/typebox-form-parser) | Parses form and query data based on TypeBox schemas |
|
|
1782
|
-
| [typebox-validators](https://github.com/jtlapp/typebox-validators) | Advanced validators supporting discriminated and heterogeneous unions |
|
|
1783
1782
|
|
|
1784
1783
|
<a name='benchmark'></a>
|
|
1785
1784
|
|