@sinclair/typebox 0.27.8 → 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.
@@ -249,24 +249,19 @@ var TypeCompiler;
249
249
  yield `${value} <= ${schema.maximum}`;
250
250
  }
251
251
  function* Intersect(schema, references, value) {
252
- if (schema.unevaluatedProperties === undefined) {
253
- const expressions = schema.allOf.map((schema) => CreateExpression(schema, references, value));
254
- yield `${expressions.join(' && ')}`;
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 === false) {
257
- // prettier-ignore
258
- const schemaKeys = Types.KeyResolver.Resolve(schema).map((key) => `'${key}'`).join(', ');
259
- const expressions = schema.allOf.map((schema) => CreateExpression(schema, references, value));
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 if (typeof schema.unevaluatedProperties === 'object') {
264
- // prettier-ignore
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 [keyPattern, valueSchema] = globalThis.Object.entries(schema.patternProperties)[0];
349
- const local = PushLocal(`new RegExp(/${keyPattern}/)`);
350
- yield `(Object.getOwnPropertyNames(${value}).every(key => ${local}.test(key)))`;
351
- const expression = CreateExpression(valueSchema, references, 'value');
352
- yield `Object.values(${value}).every(value => ${expression})`;
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 subschema of schema.allOf) {
277
- const next = Visit(subschema, references, path, value).next();
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 schemaKeys = Types.KeyResolver.Resolve(schema);
286
- const valueKeys = globalThis.Object.getOwnPropertyNames(value);
287
- for (const valueKey of valueKeys) {
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 schemaKeys = Types.KeyResolver.Resolve(schema);
295
- const valueKeys = globalThis.Object.getOwnPropertyNames(value);
296
- for (const valueKey of valueKeys) {
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 [keyPattern, valueSchema] = globalThis.Object.entries(schema.patternProperties)[0];
411
- const regex = new RegExp(keyPattern);
412
- if (!globalThis.Object.getOwnPropertyNames(value).every((key) => regex.test(key))) {
413
- const numeric = keyPattern === Types.PatternNumberExact;
414
- const type = numeric ? ValueErrorType.RecordKeyNumeric : ValueErrorType.RecordKeyString;
415
- const message = numeric ? 'Expected all object property keys to be numeric' : 'Expected all object property keys to be strings';
416
- return yield { type, schema, path, value, message };
417
- }
418
- for (const [propKey, propValue] of globalThis.Object.entries(value)) {
419
- yield* Visit(valueSchema, references, `${path}/${propKey}`, propValue);
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sinclair/typebox",
3
- "version": "0.27.8",
3
+ "version": "0.28.0",
4
4
  "description": "JSONSchema Type Builder with Static Type Resolution for TypeScript",
5
5
  "keywords": [
6
6
  "typescript",
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 Literal](#types-template-literal)
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 │ ' 257 ms' │ ' 8 ms' │ ' 32.13 x' │
1327
- │ Literal_Number │ 1000 │ ' 203 ms' │ ' 4 ms' │ ' 50.75 x' │
1328
- │ Literal_Boolean │ 1000 │ ' 183 ms' │ ' 4 ms' │ ' 45.75 x' │
1329
- │ Primitive_Number │ 1000 │ ' 174 ms' │ ' 8 ms' │ ' 21.75 x' │
1330
- │ Primitive_String │ 1000 │ ' 158 ms' │ ' 9 ms' │ ' 17.56 x' │
1331
- │ Primitive_String_Pattern │ 1000 │ ' 213 ms' │ ' 13 ms' │ ' 16.38 x' │
1332
- │ Primitive_Boolean │ 1000 │ ' 136 ms' │ ' 6 ms' │ ' 22.67 x' │
1333
- │ Primitive_Null │ 1000 │ ' 144 ms' │ ' 6 ms' │ ' 24.00 x' │
1334
- │ Object_Unconstrained │ 1000 │ ' 1176 ms' │ ' 38 ms' │ ' 30.95 x' │
1335
- │ Object_Constrained │ 1000 │ ' 1181 ms' │ ' 31 ms' │ ' 38.10 x' │
1336
- │ Object_Vector3 │ 1000 │ ' 387 ms' │ ' 8 ms' │ ' 48.38 x' │
1337
- │ Object_Box3D │ 1000 │ ' 1693 ms' │ ' 25 ms' │ ' 67.72 x' │
1338
- │ Tuple_Primitive │ 1000 │ ' 470 ms' │ ' 15 ms' │ ' 31.33 x' │
1339
- │ Tuple_Object │ 1000 │ ' 1206 ms' │ ' 17 ms' │ ' 70.94 x' │
1340
- │ Composite_Intersect │ 1000 │ ' 567 ms' │ ' 20 ms' │ ' 28.35 x' │
1341
- │ Composite_Union │ 1000 │ ' 515 ms' │ ' 21 ms' │ ' 24.52 x' │
1342
- │ Math_Vector4 │ 1000 │ ' 787 ms' │ ' 10 ms' │ ' 78.70 x' │
1343
- │ Math_Matrix4 │ 1000 │ ' 386 ms' │ ' 8 ms' │ ' 48.25 x' │
1344
- │ Array_Primitive_Number │ 1000 │ ' 349 ms' │ ' 7 ms' │ ' 49.86 x' │
1345
- │ Array_Primitive_String │ 1000 │ ' 336 ms' │ ' 4 ms' │ ' 84.00 x' │
1346
- │ Array_Primitive_Boolean │ 1000 │ ' 284 ms' │ ' 3 ms' │ ' 94.67 x' │
1347
- │ Array_Object_Unconstrained │ 1000 │ ' 1704 ms' │ ' 19 ms' │ ' 89.68 x' │
1348
- │ Array_Object_Constrained │ 1000 │ ' 1456 ms' │ ' 18 ms' │ ' 80.89 x' │
1349
- │ Array_Tuple_Primitive │ 1000 │ ' 792 ms' │ ' 15 ms' │ ' 52.80 x' │
1350
- │ Array_Tuple_Object │ 1000 │ ' 1552 ms' │ ' 17 ms' │ ' 91.29 x' │
1351
- │ Array_Composite_Intersect │ 1000 │ ' 744 ms' │ ' 18 ms' │ ' 41.33 x' │
1352
- │ Array_Composite_Union │ 1000 │ ' 783 ms' │ ' 15 ms' │ ' 52.20 x' │
1353
- │ Array_Math_Vector4 │ 1000 │ ' 1093 ms' │ ' 14 ms' │ ' 78.07 x' │
1354
- │ Array_Math_Matrix4 │ 1000 │ ' 684 ms' │ ' 6 ms' │ ' 114.00 x' │
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 │ ' 27 ms' │ ' 6 ms' │ ' 5 ms' │ ' 1.20 x' │
1369
- │ Literal_Number │ 1000000 │ ' 23 ms' │ ' 21 ms' │ ' 11 ms' │ ' 1.91 x' │
1370
- │ Literal_Boolean │ 1000000 │ ' 21 ms' │ ' 20 ms' │ ' 10 ms' │ ' 2.00 x' │
1371
- │ Primitive_Number │ 1000000 │ ' 26 ms' │ ' 19 ms' │ ' 11 ms' │ ' 1.73 x' │
1372
- │ Primitive_String │ 1000000 │ ' 25 ms' │ ' 19 ms' │ ' 10 ms' │ ' 1.90 x' │
1373
- │ Primitive_String_Pattern │ 1000000 │ ' 155 ms' │ ' 49 ms' │ ' 43 ms' │ ' 1.14 x' │
1374
- │ Primitive_Boolean │ 1000000 │ ' 23 ms' │ ' 19 ms' │ ' 10 ms' │ ' 1.90 x' │
1375
- │ Primitive_Null │ 1000000 │ ' 24 ms' │ ' 19 ms' │ ' 10 ms' │ ' 1.90 x' │
1376
- │ Object_Unconstrained │ 1000000 │ ' 804 ms' │ ' 35 ms' │ ' 28 ms' │ ' 1.25 x' │
1377
- │ Object_Constrained │ 1000000 │ ' 1041 ms' │ ' 55 ms' │ ' 41 ms' │ ' 1.34 x' │
1378
- │ Object_Vector3 │ 1000000 │ ' 380 ms' │ ' 26 ms' │ ' 20 ms' │ ' 1.30 x' │
1379
- │ Object_Box3D │ 1000000 │ ' 1785 ms' │ ' 65 ms' │ ' 52 ms' │ ' 1.25 x' │
1380
- │ Object_Recursive │ 1000000 │ ' 4984 ms' │ ' 396 ms' │ ' 114 ms' │ ' 3.47 x' │
1381
- │ Tuple_Primitive │ 1000000 │ ' 168 ms' │ ' 24 ms' │ ' 16 ms' │ ' 1.50 x' │
1382
- │ Tuple_Object │ 1000000 │ ' 673 ms' │ ' 30 ms' │ ' 26 ms' │ ' 1.15 x' │
1383
- │ Composite_Intersect │ 1000000 │ ' 751 ms' │ ' 28 ms' │ ' 20 ms' │ ' 1.40 x' │
1384
- │ Composite_Union │ 1000000 │ ' 489 ms' │ ' 24 ms' │ ' 16 ms' │ ' 1.50 x' │
1385
- │ Math_Vector4 │ 1000000 │ ' 259 ms' │ ' 23 ms' │ ' 13 ms' │ ' 1.77 x' │
1386
- │ Math_Matrix4 │ 1000000 │ ' 1002 ms' │ ' 40 ms' │ ' 30 ms' │ ' 1.33 x' │
1387
- │ Array_Primitive_Number │ 1000000 │ ' 252 ms' │ ' 22 ms' │ ' 15 ms' │ ' 1.47 x' │
1388
- │ Array_Primitive_String │ 1000000 │ ' 227 ms' │ ' 22 ms' │ ' 18 ms' │ ' 1.22 x' │
1389
- │ Array_Primitive_Boolean │ 1000000 │ ' 150 ms' │ ' 23 ms' │ ' 22 ms' │ ' 1.05 x' │
1390
- │ Array_Object_Unconstrained │ 1000000 │ ' 4754 ms' │ ' 71 ms' │ ' 64 ms' │ ' 1.11 x' │
1391
- │ Array_Object_Constrained │ 1000000 │ ' 4787 ms' │ ' 142 ms' │ ' 123 ms' │ ' 1.15 x' │
1392
- │ Array_Object_Recursive │ 1000000 │ ' 19088 ms' │ ' 1735 ms' │ ' 314 ms' │ ' 5.53 x' │
1393
- │ Array_Tuple_Primitive │ 1000000 │ ' 650 ms' │ ' 41 ms' │ ' 31 ms' │ ' 1.32 x' │
1394
- │ Array_Tuple_Object │ 1000000 │ ' 2770 ms' │ ' 67 ms' │ ' 55 ms' │ ' 1.22 x' │
1395
- │ Array_Composite_Intersect │ 1000000 │ ' 2693 ms' │ ' 50 ms' │ ' 39 ms' │ ' 1.28 x' │
1396
- │ Array_Composite_Union │ 1000000 │ ' 1982 ms' │ ' 72 ms' │ ' 33 ms' │ ' 2.18 x' │
1397
- │ Array_Math_Vector4 │ 1000000 │ ' 1068 ms' │ ' 40 ms' │ ' 26 ms' │ ' 1.54 x' │
1398
- │ Array_Math_Matrix4 │ 1000000 │ ' 4609 ms' │ ' 115 ms' │ ' 88 ms' │ ' 1.31 x' │
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 │ '124.3 kb' │ ' 55.7 kb' │ '2.23 x' │
1413
- │ typebox/errors │ '107.8 kb' │ ' 47.9 kb' │ '2.25 x' │
1414
- │ typebox/system │ ' 73.3 kb' │ ' 30.2 kb' │ '2.43 x' │
1415
- │ typebox/value │ '170.7 kb' │ ' 74.2 kb' │ '2.30 x' │
1416
- │ typebox │ ' 72.0 kb' │ ' 29.7 kb' │ '2.43 x' │
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
 
@@ -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 = {}));