@sinclair/typebox 0.27.7 → 0.28.0
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/compiler/compiler.js +17 -21
- package/errors/errors.js +23 -20
- package/package.json +1 -1
- package/readme.md +94 -67
- package/system/system.d.ts +0 -4
- package/system/system.js +0 -13
- package/typebox.d.ts +136 -76
- package/typebox.js +157 -63
- package/value/check.js +22 -20
- package/value/delta.d.ts +6 -6
package/compiler/compiler.js
CHANGED
|
@@ -249,24 +249,19 @@ var TypeCompiler;
|
|
|
249
249
|
yield `${value} <= ${schema.maximum}`;
|
|
250
250
|
}
|
|
251
251
|
function* Intersect(schema, references, value) {
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
252
|
+
const check1 = schema.allOf.map((schema) => CreateExpression(schema, references, value)).join(' && ');
|
|
253
|
+
if (schema.unevaluatedProperties === false) {
|
|
254
|
+
const keyCheck = PushLocal(`${new RegExp(Types.KeyResolver.ResolvePattern(schema))};`);
|
|
255
|
+
const check2 = `Object.getOwnPropertyNames(${value}).every(key => ${keyCheck}.test(key))`;
|
|
256
|
+
yield `${check1} && ${check2}`;
|
|
255
257
|
}
|
|
256
|
-
else if (schema.unevaluatedProperties
|
|
257
|
-
|
|
258
|
-
const
|
|
259
|
-
|
|
260
|
-
const expression1 = `Object.getOwnPropertyNames(${value}).every(key => [${schemaKeys}].includes(key))`;
|
|
261
|
-
yield `${expressions.join(' && ')} && ${expression1}`;
|
|
258
|
+
else if (Types.TypeGuard.TSchema(schema.unevaluatedProperties)) {
|
|
259
|
+
const keyCheck = PushLocal(`${new RegExp(Types.KeyResolver.ResolvePattern(schema))};`);
|
|
260
|
+
const check2 = `Object.getOwnPropertyNames(${value}).every(key => ${keyCheck}.test(key) || ${CreateExpression(schema.unevaluatedProperties, references, 'value[key]')})`;
|
|
261
|
+
yield `${check1} && ${check2}`;
|
|
262
262
|
}
|
|
263
|
-
else
|
|
264
|
-
|
|
265
|
-
const schemaKeys = Types.KeyResolver.Resolve(schema).map((key) => `'${key}'`).join(', ');
|
|
266
|
-
const expressions = schema.allOf.map((schema) => CreateExpression(schema, references, value));
|
|
267
|
-
const expression1 = CreateExpression(schema.unevaluatedProperties, references, 'value[key]');
|
|
268
|
-
const expression2 = `Object.getOwnPropertyNames(${value}).every(key => [${schemaKeys}].includes(key) || ${expression1})`;
|
|
269
|
-
yield `${expressions.join(' && ')} && ${expression2}`;
|
|
263
|
+
else {
|
|
264
|
+
yield `${check1}`;
|
|
270
265
|
}
|
|
271
266
|
}
|
|
272
267
|
function* Literal(schema, references, value) {
|
|
@@ -345,11 +340,12 @@ var TypeCompiler;
|
|
|
345
340
|
yield `Object.getOwnPropertyNames(${value}).length >= ${schema.minProperties}`;
|
|
346
341
|
if (IsNumber(schema.maxProperties))
|
|
347
342
|
yield `Object.getOwnPropertyNames(${value}).length <= ${schema.maxProperties}`;
|
|
348
|
-
const [
|
|
349
|
-
const local = PushLocal(`new RegExp(/${
|
|
350
|
-
|
|
351
|
-
const
|
|
352
|
-
|
|
343
|
+
const [patternKey, patternSchema] = globalThis.Object.entries(schema.patternProperties)[0];
|
|
344
|
+
const local = PushLocal(`new RegExp(/${patternKey}/)`);
|
|
345
|
+
const check1 = CreateExpression(patternSchema, references, value);
|
|
346
|
+
const check2 = Types.TypeGuard.TSchema(schema.additionalProperties) ? CreateExpression(schema.additionalProperties, references, value) : schema.additionalProperties === false ? 'false' : 'true';
|
|
347
|
+
const expression = `(${local}.test(key) ? ${check1} : ${check2})`;
|
|
348
|
+
yield `(Object.entries(${value}).every(([key, value]) => ${expression}))`;
|
|
353
349
|
}
|
|
354
350
|
function* Ref(schema, references, value) {
|
|
355
351
|
const index = references.findIndex((foreign) => foreign.$id === schema.$ref);
|
package/errors/errors.js
CHANGED
|
@@ -273,8 +273,8 @@ var ValueErrors;
|
|
|
273
273
|
}
|
|
274
274
|
}
|
|
275
275
|
function* Intersect(schema, references, path, value) {
|
|
276
|
-
for (const
|
|
277
|
-
const next = Visit(
|
|
276
|
+
for (const inner of schema.allOf) {
|
|
277
|
+
const next = Visit(inner, references, path, value).next();
|
|
278
278
|
if (!next.done) {
|
|
279
279
|
yield next.value;
|
|
280
280
|
yield { type: ValueErrorType.Intersect, schema, path, value, message: `Expected all sub schemas to be valid` };
|
|
@@ -282,19 +282,17 @@ var ValueErrors;
|
|
|
282
282
|
}
|
|
283
283
|
}
|
|
284
284
|
if (schema.unevaluatedProperties === false) {
|
|
285
|
-
const
|
|
286
|
-
const
|
|
287
|
-
|
|
288
|
-
if (!schemaKeys.includes(valueKey)) {
|
|
285
|
+
const keyCheck = new RegExp(Types.KeyResolver.ResolvePattern(schema));
|
|
286
|
+
for (const valueKey of globalThis.Object.getOwnPropertyNames(value)) {
|
|
287
|
+
if (!keyCheck.test(valueKey)) {
|
|
289
288
|
yield { type: ValueErrorType.IntersectUnevaluatedProperties, schema, path: `${path}/${valueKey}`, value, message: `Unexpected property` };
|
|
290
289
|
}
|
|
291
290
|
}
|
|
292
291
|
}
|
|
293
292
|
if (typeof schema.unevaluatedProperties === 'object') {
|
|
294
|
-
const
|
|
295
|
-
const
|
|
296
|
-
|
|
297
|
-
if (!schemaKeys.includes(valueKey)) {
|
|
293
|
+
const keyCheck = new RegExp(Types.KeyResolver.ResolvePattern(schema));
|
|
294
|
+
for (const valueKey of globalThis.Object.getOwnPropertyNames(value)) {
|
|
295
|
+
if (!keyCheck.test(valueKey)) {
|
|
298
296
|
const next = Visit(schema.unevaluatedProperties, references, `${path}/${valueKey}`, value[valueKey]).next();
|
|
299
297
|
if (!next.done) {
|
|
300
298
|
yield next.value;
|
|
@@ -407,16 +405,21 @@ var ValueErrors;
|
|
|
407
405
|
if (IsDefined(schema.maxProperties) && !(globalThis.Object.getOwnPropertyNames(value).length <= schema.maxProperties)) {
|
|
408
406
|
yield { type: ValueErrorType.ObjectMaxProperties, schema, path, value, message: `Expected object to have less than ${schema.minProperties} properties` };
|
|
409
407
|
}
|
|
410
|
-
const [
|
|
411
|
-
const regex = new RegExp(
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
408
|
+
const [patternKey, patternSchema] = globalThis.Object.entries(schema.patternProperties)[0];
|
|
409
|
+
const regex = new RegExp(patternKey);
|
|
410
|
+
for (const [propertyKey, propertyValue] of globalThis.Object.entries(value)) {
|
|
411
|
+
if (regex.test(propertyKey)) {
|
|
412
|
+
yield* Visit(patternSchema, references, `${path}/${propertyKey}`, propertyValue);
|
|
413
|
+
continue;
|
|
414
|
+
}
|
|
415
|
+
if (typeof schema.additionalProperties === 'object') {
|
|
416
|
+
yield* Visit(schema.additionalProperties, references, `${path}/${propertyKey}`, propertyValue);
|
|
417
|
+
}
|
|
418
|
+
if (schema.additionalProperties === false) {
|
|
419
|
+
const propertyPath = `${path}/${propertyKey}`;
|
|
420
|
+
const message = `Unexpected property '${propertyPath}'`;
|
|
421
|
+
return yield { type: ValueErrorType.ObjectAdditionalProperties, schema, path: propertyPath, value: propertyValue, message };
|
|
422
|
+
}
|
|
420
423
|
}
|
|
421
424
|
}
|
|
422
425
|
function* Ref(schema, references, path, value) {
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -81,7 +81,8 @@ License MIT
|
|
|
81
81
|
- [References](#types-references)
|
|
82
82
|
- [Recursive](#types-recursive)
|
|
83
83
|
- [Conditional](#types-conditional)
|
|
84
|
-
- [Template
|
|
84
|
+
- [Template](#types-template-literal)
|
|
85
|
+
- [Indexed](#types-indexed)
|
|
85
86
|
- [Guards](#types-guards)
|
|
86
87
|
- [Unsafe](#types-unsafe)
|
|
87
88
|
- [Strict](#types-strict)
|
|
@@ -276,6 +277,14 @@ The following table lists the Standard TypeBox types. These types are fully comp
|
|
|
276
277
|
│ │ │ │
|
|
277
278
|
│ │ │ │
|
|
278
279
|
├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
|
|
280
|
+
│ const T = Type.Index( │ type T = { │ const T = { │
|
|
281
|
+
│ Type.Object({ │ x: number, │ type: number │
|
|
282
|
+
│ x: Type.Number(), │ y: string │ } │
|
|
283
|
+
│ y: Type.String() │ }['x'] │ │
|
|
284
|
+
│ }), ['x'] │ │ │
|
|
285
|
+
│ ) │ │ │
|
|
286
|
+
│ │ │ │
|
|
287
|
+
├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
|
|
279
288
|
│ enum Foo { │ enum Foo { │ const T = { │
|
|
280
289
|
│ A, │ A, │ anyOf: [{ │
|
|
281
290
|
│ B │ B │ type: 'number', │
|
|
@@ -830,6 +839,24 @@ type R = Static<typeof R> // type R = {
|
|
|
830
839
|
// }
|
|
831
840
|
```
|
|
832
841
|
|
|
842
|
+
<a name='types-indexed'></a>
|
|
843
|
+
|
|
844
|
+
### Indexed Access Types
|
|
845
|
+
|
|
846
|
+
Indexed Access types are supported with `Type.Index`
|
|
847
|
+
|
|
848
|
+
```typescript
|
|
849
|
+
const T = Type.Object({ // type T = {
|
|
850
|
+
x: Type.Number(), // x: number
|
|
851
|
+
y: Type.String(), // y: string
|
|
852
|
+
z: Type.Boolean() // z: boolean
|
|
853
|
+
}) // }
|
|
854
|
+
|
|
855
|
+
const A = Type.Index(T, ['x']) // type A = T['x']
|
|
856
|
+
|
|
857
|
+
const B = Type.Index(T, Type.KeyOf(T)) // type B = T[keyof T]
|
|
858
|
+
```
|
|
859
|
+
|
|
833
860
|
<a name='types-unsafe'></a>
|
|
834
861
|
|
|
835
862
|
### Unsafe
|
|
@@ -1309,7 +1336,7 @@ TypeSystem.AllowNaN = true
|
|
|
1309
1336
|
|
|
1310
1337
|
## Benchmark
|
|
1311
1338
|
|
|
1312
|
-
This project maintains a set of benchmarks that measure Ajv, Value and TypeCompiler compilation and validation performance. These benchmarks can be run locally by cloning this repository and running `npm run benchmark`. The results below show for Ajv version 8.12.0.
|
|
1339
|
+
This project maintains a set of benchmarks that measure Ajv, Value and TypeCompiler compilation and validation performance. These benchmarks can be run locally by cloning this repository and running `npm run benchmark`. The results below show for Ajv version 8.12.0 running on Node 20.0.0.
|
|
1313
1340
|
|
|
1314
1341
|
For additional comparative benchmarks, please refer to [typescript-runtime-type-benchmarks](https://moltar.github.io/typescript-runtime-type-benchmarks/).
|
|
1315
1342
|
|
|
@@ -1323,35 +1350,35 @@ This benchmark measures compilation performance for varying types. You can revie
|
|
|
1323
1350
|
┌────────────────────────────┬────────────┬──────────────┬──────────────┬──────────────┐
|
|
1324
1351
|
│ (index) │ Iterations │ Ajv │ TypeCompiler │ Performance │
|
|
1325
1352
|
├────────────────────────────┼────────────┼──────────────┼──────────────┼──────────────┤
|
|
1326
|
-
│ Literal_String │ 1000 │ '
|
|
1327
|
-
│ Literal_Number │ 1000 │ '
|
|
1328
|
-
│ Literal_Boolean │ 1000 │ '
|
|
1329
|
-
│ Primitive_Number │ 1000 │ '
|
|
1330
|
-
│ Primitive_String │ 1000 │ '
|
|
1331
|
-
│ Primitive_String_Pattern │ 1000 │ '
|
|
1332
|
-
│ Primitive_Boolean │ 1000 │ '
|
|
1333
|
-
│ Primitive_Null │ 1000 │ '
|
|
1334
|
-
│ Object_Unconstrained │ 1000 │ '
|
|
1335
|
-
│ Object_Constrained │ 1000 │ '
|
|
1336
|
-
│ Object_Vector3 │ 1000 │ '
|
|
1337
|
-
│ Object_Box3D │ 1000 │ '
|
|
1338
|
-
│ Tuple_Primitive │ 1000 │ '
|
|
1339
|
-
│ Tuple_Object │ 1000 │ '
|
|
1340
|
-
│ Composite_Intersect │ 1000 │ '
|
|
1341
|
-
│ Composite_Union │ 1000 │ '
|
|
1342
|
-
│ Math_Vector4 │ 1000 │ '
|
|
1343
|
-
│ Math_Matrix4 │ 1000 │ '
|
|
1344
|
-
│ Array_Primitive_Number │ 1000 │ '
|
|
1345
|
-
│ Array_Primitive_String │ 1000 │ '
|
|
1346
|
-
│ Array_Primitive_Boolean │ 1000 │ '
|
|
1347
|
-
│ Array_Object_Unconstrained │ 1000 │ '
|
|
1348
|
-
│ Array_Object_Constrained │ 1000 │ '
|
|
1349
|
-
│ Array_Tuple_Primitive │ 1000 │ '
|
|
1350
|
-
│ Array_Tuple_Object │ 1000 │ '
|
|
1351
|
-
│ Array_Composite_Intersect │ 1000 │ '
|
|
1352
|
-
│ Array_Composite_Union │ 1000 │ '
|
|
1353
|
-
│ Array_Math_Vector4 │ 1000 │ '
|
|
1354
|
-
│ Array_Math_Matrix4 │ 1000 │ '
|
|
1353
|
+
│ Literal_String │ 1000 │ ' 243 ms' │ ' 8 ms' │ ' 30.38 x' │
|
|
1354
|
+
│ Literal_Number │ 1000 │ ' 195 ms' │ ' 5 ms' │ ' 39.00 x' │
|
|
1355
|
+
│ Literal_Boolean │ 1000 │ ' 162 ms' │ ' 4 ms' │ ' 40.50 x' │
|
|
1356
|
+
│ Primitive_Number │ 1000 │ ' 168 ms' │ ' 6 ms' │ ' 28.00 x' │
|
|
1357
|
+
│ Primitive_String │ 1000 │ ' 164 ms' │ ' 5 ms' │ ' 32.80 x' │
|
|
1358
|
+
│ Primitive_String_Pattern │ 1000 │ ' 214 ms' │ ' 9 ms' │ ' 23.78 x' │
|
|
1359
|
+
│ Primitive_Boolean │ 1000 │ ' 132 ms' │ ' 4 ms' │ ' 33.00 x' │
|
|
1360
|
+
│ Primitive_Null │ 1000 │ ' 148 ms' │ ' 4 ms' │ ' 37.00 x' │
|
|
1361
|
+
│ Object_Unconstrained │ 1000 │ ' 1158 ms' │ ' 30 ms' │ ' 38.60 x' │
|
|
1362
|
+
│ Object_Constrained │ 1000 │ ' 1263 ms' │ ' 25 ms' │ ' 50.52 x' │
|
|
1363
|
+
│ Object_Vector3 │ 1000 │ ' 384 ms' │ ' 7 ms' │ ' 54.86 x' │
|
|
1364
|
+
│ Object_Box3D │ 1000 │ ' 1932 ms' │ ' 27 ms' │ ' 71.56 x' │
|
|
1365
|
+
│ Tuple_Primitive │ 1000 │ ' 478 ms' │ ' 14 ms' │ ' 34.14 x' │
|
|
1366
|
+
│ Tuple_Object │ 1000 │ ' 1232 ms' │ ' 14 ms' │ ' 88.00 x' │
|
|
1367
|
+
│ Composite_Intersect │ 1000 │ ' 671 ms' │ ' 17 ms' │ ' 39.47 x' │
|
|
1368
|
+
│ Composite_Union │ 1000 │ ' 537 ms' │ ' 18 ms' │ ' 29.83 x' │
|
|
1369
|
+
│ Math_Vector4 │ 1000 │ ' 816 ms' │ ' 14 ms' │ ' 58.29 x' │
|
|
1370
|
+
│ Math_Matrix4 │ 1000 │ ' 417 ms' │ ' 6 ms' │ ' 69.50 x' │
|
|
1371
|
+
│ Array_Primitive_Number │ 1000 │ ' 378 ms' │ ' 5 ms' │ ' 75.60 x' │
|
|
1372
|
+
│ Array_Primitive_String │ 1000 │ ' 353 ms' │ ' 6 ms' │ ' 58.83 x' │
|
|
1373
|
+
│ Array_Primitive_Boolean │ 1000 │ ' 279 ms' │ ' 5 ms' │ ' 55.80 x' │
|
|
1374
|
+
│ Array_Object_Unconstrained │ 1000 │ ' 1794 ms' │ ' 20 ms' │ ' 89.70 x' │
|
|
1375
|
+
│ Array_Object_Constrained │ 1000 │ ' 1586 ms' │ ' 19 ms' │ ' 83.47 x' │
|
|
1376
|
+
│ Array_Tuple_Primitive │ 1000 │ ' 791 ms' │ ' 13 ms' │ ' 60.85 x' │
|
|
1377
|
+
│ Array_Tuple_Object │ 1000 │ ' 1638 ms' │ ' 17 ms' │ ' 96.35 x' │
|
|
1378
|
+
│ Array_Composite_Intersect │ 1000 │ ' 796 ms' │ ' 17 ms' │ ' 46.82 x' │
|
|
1379
|
+
│ Array_Composite_Union │ 1000 │ ' 798 ms' │ ' 15 ms' │ ' 53.20 x' │
|
|
1380
|
+
│ Array_Math_Vector4 │ 1000 │ ' 1127 ms' │ ' 14 ms' │ ' 80.50 x' │
|
|
1381
|
+
│ Array_Math_Matrix4 │ 1000 │ ' 677 ms' │ ' 9 ms' │ ' 75.22 x' │
|
|
1355
1382
|
└────────────────────────────┴────────────┴──────────────┴──────────────┴──────────────┘
|
|
1356
1383
|
```
|
|
1357
1384
|
|
|
@@ -1365,37 +1392,37 @@ This benchmark measures validation performance for varying types. You can review
|
|
|
1365
1392
|
┌────────────────────────────┬────────────┬──────────────┬──────────────┬──────────────┬──────────────┐
|
|
1366
1393
|
│ (index) │ Iterations │ ValueCheck │ Ajv │ TypeCompiler │ Performance │
|
|
1367
1394
|
├────────────────────────────┼────────────┼──────────────┼──────────────┼──────────────┼──────────────┤
|
|
1368
|
-
│ Literal_String │ 1000000 │ '
|
|
1369
|
-
│ Literal_Number │ 1000000 │ '
|
|
1370
|
-
│ Literal_Boolean │ 1000000 │ '
|
|
1371
|
-
│ Primitive_Number │ 1000000 │ '
|
|
1372
|
-
│ Primitive_String │ 1000000 │ '
|
|
1373
|
-
│ Primitive_String_Pattern │ 1000000 │ '
|
|
1374
|
-
│ Primitive_Boolean │ 1000000 │ '
|
|
1375
|
-
│ Primitive_Null │ 1000000 │ '
|
|
1376
|
-
│ Object_Unconstrained │ 1000000 │ '
|
|
1377
|
-
│ Object_Constrained │ 1000000 │ '
|
|
1378
|
-
│ Object_Vector3 │ 1000000 │ '
|
|
1379
|
-
│ Object_Box3D │ 1000000 │ '
|
|
1380
|
-
│ Object_Recursive │ 1000000 │ '
|
|
1381
|
-
│ Tuple_Primitive │ 1000000 │ ' 168 ms' │ ' 24 ms' │ '
|
|
1382
|
-
│ Tuple_Object │ 1000000 │ '
|
|
1383
|
-
│ Composite_Intersect │ 1000000 │ '
|
|
1384
|
-
│ Composite_Union │ 1000000 │ '
|
|
1385
|
-
│ Math_Vector4 │ 1000000 │ '
|
|
1386
|
-
│ Math_Matrix4 │ 1000000 │ '
|
|
1387
|
-
│ Array_Primitive_Number │ 1000000 │ '
|
|
1388
|
-
│ Array_Primitive_String │ 1000000 │ '
|
|
1389
|
-
│ Array_Primitive_Boolean │ 1000000 │ '
|
|
1390
|
-
│ Array_Object_Unconstrained │ 1000000 │ '
|
|
1391
|
-
│ Array_Object_Constrained │ 1000000 │ '
|
|
1392
|
-
│ Array_Object_Recursive │ 1000000 │ '
|
|
1393
|
-
│ Array_Tuple_Primitive │ 1000000 │ '
|
|
1394
|
-
│ Array_Tuple_Object │ 1000000 │ '
|
|
1395
|
-
│ Array_Composite_Intersect │ 1000000 │ '
|
|
1396
|
-
│ Array_Composite_Union │ 1000000 │ '
|
|
1397
|
-
│ Array_Math_Vector4 │ 1000000 │ '
|
|
1398
|
-
│ Array_Math_Matrix4 │ 1000000 │ '
|
|
1395
|
+
│ Literal_String │ 1000000 │ ' 24 ms' │ ' 5 ms' │ ' 4 ms' │ ' 1.25 x' │
|
|
1396
|
+
│ Literal_Number │ 1000000 │ ' 21 ms' │ ' 17 ms' │ ' 10 ms' │ ' 1.70 x' │
|
|
1397
|
+
│ Literal_Boolean │ 1000000 │ ' 19 ms' │ ' 19 ms' │ ' 10 ms' │ ' 1.90 x' │
|
|
1398
|
+
│ Primitive_Number │ 1000000 │ ' 24 ms' │ ' 18 ms' │ ' 10 ms' │ ' 1.80 x' │
|
|
1399
|
+
│ Primitive_String │ 1000000 │ ' 26 ms' │ ' 17 ms' │ ' 9 ms' │ ' 1.89 x' │
|
|
1400
|
+
│ Primitive_String_Pattern │ 1000000 │ ' 159 ms' │ ' 45 ms' │ ' 36 ms' │ ' 1.25 x' │
|
|
1401
|
+
│ Primitive_Boolean │ 1000000 │ ' 22 ms' │ ' 17 ms' │ ' 10 ms' │ ' 1.70 x' │
|
|
1402
|
+
│ Primitive_Null │ 1000000 │ ' 23 ms' │ ' 17 ms' │ ' 9 ms' │ ' 1.89 x' │
|
|
1403
|
+
│ Object_Unconstrained │ 1000000 │ ' 914 ms' │ ' 34 ms' │ ' 26 ms' │ ' 1.31 x' │
|
|
1404
|
+
│ Object_Constrained │ 1000000 │ ' 1095 ms' │ ' 50 ms' │ ' 38 ms' │ ' 1.32 x' │
|
|
1405
|
+
│ Object_Vector3 │ 1000000 │ ' 414 ms' │ ' 23 ms' │ ' 14 ms' │ ' 1.64 x' │
|
|
1406
|
+
│ Object_Box3D │ 1000000 │ ' 1933 ms' │ ' 55 ms' │ ' 53 ms' │ ' 1.04 x' │
|
|
1407
|
+
│ Object_Recursive │ 1000000 │ ' 4995 ms' │ ' 378 ms' │ ' 177 ms' │ ' 2.14 x' │
|
|
1408
|
+
│ Tuple_Primitive │ 1000000 │ ' 168 ms' │ ' 24 ms' │ ' 13 ms' │ ' 1.85 x' │
|
|
1409
|
+
│ Tuple_Object │ 1000000 │ ' 681 ms' │ ' 31 ms' │ ' 19 ms' │ ' 1.63 x' │
|
|
1410
|
+
│ Composite_Intersect │ 1000000 │ ' 718 ms' │ ' 25 ms' │ ' 15 ms' │ ' 1.67 x' │
|
|
1411
|
+
│ Composite_Union │ 1000000 │ ' 511 ms' │ ' 24 ms' │ ' 14 ms' │ ' 1.71 x' │
|
|
1412
|
+
│ Math_Vector4 │ 1000000 │ ' 285 ms' │ ' 23 ms' │ ' 12 ms' │ ' 1.92 x' │
|
|
1413
|
+
│ Math_Matrix4 │ 1000000 │ ' 1197 ms' │ ' 39 ms' │ ' 28 ms' │ ' 1.39 x' │
|
|
1414
|
+
│ Array_Primitive_Number │ 1000000 │ ' 294 ms' │ ' 22 ms' │ ' 12 ms' │ ' 1.83 x' │
|
|
1415
|
+
│ Array_Primitive_String │ 1000000 │ ' 251 ms' │ ' 22 ms' │ ' 14 ms' │ ' 1.57 x' │
|
|
1416
|
+
│ Array_Primitive_Boolean │ 1000000 │ ' 131 ms' │ ' 22 ms' │ ' 14 ms' │ ' 1.57 x' │
|
|
1417
|
+
│ Array_Object_Unconstrained │ 1000000 │ ' 5249 ms' │ ' 69 ms' │ ' 56 ms' │ ' 1.23 x' │
|
|
1418
|
+
│ Array_Object_Constrained │ 1000000 │ ' 5299 ms' │ ' 127 ms' │ ' 123 ms' │ ' 1.03 x' │
|
|
1419
|
+
│ Array_Object_Recursive │ 1000000 │ ' 19609 ms' │ ' 1711 ms' │ ' 608 ms' │ ' 2.81 x' │
|
|
1420
|
+
│ Array_Tuple_Primitive │ 1000000 │ ' 734 ms' │ ' 38 ms' │ ' 30 ms' │ ' 1.27 x' │
|
|
1421
|
+
│ Array_Tuple_Object │ 1000000 │ ' 2843 ms' │ ' 63 ms' │ ' 51 ms' │ ' 1.24 x' │
|
|
1422
|
+
│ Array_Composite_Intersect │ 1000000 │ ' 2794 ms' │ ' 43 ms' │ ' 36 ms' │ ' 1.19 x' │
|
|
1423
|
+
│ Array_Composite_Union │ 1000000 │ ' 1892 ms' │ ' 66 ms' │ ' 33 ms' │ ' 2.00 x' │
|
|
1424
|
+
│ Array_Math_Vector4 │ 1000000 │ ' 1177 ms' │ ' 37 ms' │ ' 23 ms' │ ' 1.61 x' │
|
|
1425
|
+
│ Array_Math_Matrix4 │ 1000000 │ ' 5115 ms' │ ' 110 ms' │ ' 85 ms' │ ' 1.29 x' │
|
|
1399
1426
|
└────────────────────────────┴────────────┴──────────────┴──────────────┴──────────────┴──────────────┘
|
|
1400
1427
|
```
|
|
1401
1428
|
|
|
@@ -1409,11 +1436,11 @@ The following table lists esbuild compiled and minified sizes for each TypeBox m
|
|
|
1409
1436
|
┌──────────────────────┬────────────┬────────────┬─────────────┐
|
|
1410
1437
|
│ (index) │ Compiled │ Minified │ Compression │
|
|
1411
1438
|
├──────────────────────┼────────────┼────────────┼─────────────┤
|
|
1412
|
-
│ typebox/compiler │ '
|
|
1413
|
-
│ typebox/errors │ '
|
|
1414
|
-
│ typebox/system │ '
|
|
1415
|
-
│ typebox/value │ '
|
|
1416
|
-
│ typebox │ '
|
|
1439
|
+
│ typebox/compiler │ '127.2 kb' │ ' 56.9 kb' │ '2.23 x' │
|
|
1440
|
+
│ typebox/errors │ '110.9 kb' │ ' 49.2 kb' │ '2.25 x' │
|
|
1441
|
+
│ typebox/system │ ' 76.4 kb' │ ' 31.5 kb' │ '2.42 x' │
|
|
1442
|
+
│ typebox/value │ '176.9 kb' │ ' 76.8 kb' │ '2.30 x' │
|
|
1443
|
+
│ typebox │ ' 75.3 kb' │ ' 31.1 kb' │ '2.42 x' │
|
|
1417
1444
|
└──────────────────────┴────────────┴────────────┴─────────────┘
|
|
1418
1445
|
```
|
|
1419
1446
|
|
package/system/system.d.ts
CHANGED
|
@@ -19,8 +19,4 @@ export declare namespace TypeSystem {
|
|
|
19
19
|
function Type<Type, Options = object>(kind: string, check: (options: Options, value: unknown) => boolean): (options?: Partial<Options>) => Types.TUnsafe<Type>;
|
|
20
20
|
/** Creates a new string format */
|
|
21
21
|
function Format<F extends string>(format: F, check: (value: string) => boolean): F;
|
|
22
|
-
/** @deprecated Use `TypeSystem.Type()` instead. */
|
|
23
|
-
function CreateType<Type, Options = object>(kind: string, check: (options: Options, value: unknown) => boolean): (options?: Partial<Options>) => Types.TUnsafe<Type>;
|
|
24
|
-
/** @deprecated Use `TypeSystem.Format()` instead. */
|
|
25
|
-
function CreateFormat<F extends string>(format: F, check: (value: string) => boolean): F;
|
|
26
22
|
}
|
package/system/system.js
CHANGED
|
@@ -74,17 +74,4 @@ var TypeSystem;
|
|
|
74
74
|
return format;
|
|
75
75
|
}
|
|
76
76
|
TypeSystem.Format = Format;
|
|
77
|
-
// ------------------------------------------------------------------------
|
|
78
|
-
// Deprecated
|
|
79
|
-
// ------------------------------------------------------------------------
|
|
80
|
-
/** @deprecated Use `TypeSystem.Type()` instead. */
|
|
81
|
-
function CreateType(kind, check) {
|
|
82
|
-
return Type(kind, check);
|
|
83
|
-
}
|
|
84
|
-
TypeSystem.CreateType = CreateType;
|
|
85
|
-
/** @deprecated Use `TypeSystem.Format()` instead. */
|
|
86
|
-
function CreateFormat(format, check) {
|
|
87
|
-
return Format(format, check);
|
|
88
|
-
}
|
|
89
|
-
TypeSystem.CreateFormat = CreateFormat;
|
|
90
77
|
})(TypeSystem = exports.TypeSystem || (exports.TypeSystem = {}));
|