@sinclair/typebox 0.28.14 → 0.28.16

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,14 +199,15 @@ var TypeCompiler;
199
199
  yield 'true';
200
200
  }
201
201
  function* Array(schema, references, value) {
202
- const expression = CreateExpression(schema.items, references, 'value');
202
+ yield `Array.isArray(${value})`;
203
203
  if (IsNumber(schema.minItems))
204
204
  yield `${value}.length >= ${schema.minItems}`;
205
205
  if (IsNumber(schema.maxItems))
206
206
  yield `${value}.length <= ${schema.maxItems}`;
207
207
  if (schema.uniqueItems === true)
208
208
  yield `((function() { const set = new Set(); for(const element of ${value}) { const hashed = hash(element); if(set.has(hashed)) { return false } else { set.add(hashed) } } return true })())`;
209
- yield `Array.isArray(${value}) && ${value}.every(value => ${expression})`;
209
+ const expression = CreateExpression(schema.items, references, 'value');
210
+ yield `${value}.every(value => ${expression})`;
210
211
  }
211
212
  function* BigInt(schema, references, value) {
212
213
  yield `(typeof ${value} === 'bigint')`;
@@ -358,9 +359,9 @@ var TypeCompiler;
358
359
  if (index === -1)
359
360
  throw new TypeCompilerDereferenceError(schema);
360
361
  const target = references[index];
361
- // Reference: If we have seen this reference before we can just yield and return
362
- // the function call. If this isn't the case we defer to visit to generate and
363
- // set the function for subsequent passes. Consider for refactor.
362
+ // Reference: If we have seen this reference before we can just yield and
363
+ // return the function call. If this isn't the case we defer to visit to
364
+ // generate and set the function for subsequent passes.
364
365
  if (state_local_function_names.has(schema.$ref))
365
366
  return yield `${CreateFunctionName(schema.$ref)}(${value})`;
366
367
  yield* Visit(target, references, value);
@@ -392,7 +393,7 @@ var TypeCompiler;
392
393
  yield `${func}(${value})`;
393
394
  }
394
395
  function* Tuple(schema, references, value) {
395
- yield `(Array.isArray(${value}))`;
396
+ yield `Array.isArray(${value})`;
396
397
  if (schema.items === undefined)
397
398
  return yield `${value}.length === 0`;
398
399
  yield `(${value}.length === ${schema.maxItems})`;
@@ -426,19 +427,25 @@ var TypeCompiler;
426
427
  state_remote_custom_types.set(schema_key, schema);
427
428
  yield `custom('${schema[Types.Kind]}', '${schema_key}', ${value})`;
428
429
  }
429
- function* Visit(schema, references, value) {
430
+ function* Visit(schema, references, value, root = false) {
430
431
  const references_ = IsString(schema.$id) ? [...references, schema] : references;
431
432
  const schema_ = schema;
432
- // Reference: Referenced schemas can originate from either additional schemas
433
- // or inline in the schema itself. Ideally the recursive path should align to
434
- // reference path. Consider for refactor.
435
- if (IsString(schema.$id) && !state_local_function_names.has(schema.$id)) {
436
- state_local_function_names.add(schema.$id);
433
+ // Rule: Types with identifiers are hoisted into their own functions.
434
+ // The following will generate a function for the schema and yield the
435
+ // call to that function. This call is only made if NOT the root type
436
+ // which allows the generated function to yield its expression. The
437
+ // root argument is only true when making calls via CreateFunction().
438
+ // Note there is potential to omit the root argument and conditional
439
+ // by refactoring the logic below. Consider for review.
440
+ if (IsString(schema.$id)) {
437
441
  const name = CreateFunctionName(schema.$id);
438
- const body = CreateFunction(name, schema, references, 'value');
439
- PushFunction(body);
440
- yield `${name}(${value})`;
441
- return;
442
+ if (!state_local_function_names.has(schema.$id)) {
443
+ state_local_function_names.add(schema.$id);
444
+ const body = CreateFunction(name, schema, references, 'value');
445
+ PushFunction(body);
446
+ }
447
+ if (!root)
448
+ return yield `${name}(${value})`;
442
449
  }
443
450
  switch (schema_[Types.Kind]) {
444
451
  case 'Any':
@@ -521,7 +528,7 @@ var TypeCompiler;
521
528
  return `check_${Identifier.Encode($id)}`;
522
529
  }
523
530
  function CreateFunction(name, schema, references, value) {
524
- const expression = [...Visit(schema, references, value)].map((condition) => ` ${condition}`).join(' &&\n');
531
+ const expression = [...Visit(schema, references, value, true)].map((condition) => ` ${condition}`).join(' &&\n');
525
532
  return `function ${name}(value) {\n return (\n${expression}\n )\n}`;
526
533
  }
527
534
  function PushFunction(functionBody) {
@@ -540,9 +547,12 @@ var TypeCompiler;
540
547
  // -------------------------------------------------------------------
541
548
  function Build(schema, references) {
542
549
  ResetCompiler();
543
- const check = CreateFunction('check', schema, references, 'value');
550
+ const check = CreateFunction('check', schema, references, 'value'); // interior visit
544
551
  const locals = GetLocals();
545
- return `${locals.join('\n')}\nreturn ${check}`;
552
+ // prettier-ignore
553
+ return IsString(schema.$id) // ensure top level schemas with $id's are hoisted
554
+ ? `${locals.join('\n')}\nreturn function check(value) {\n return ${CreateFunctionName(schema.$id)}(value)\n}`
555
+ : `${locals.join('\n')}\nreturn ${check}`;
546
556
  }
547
557
  /** Returns the generated assertion code used to validate this type. */
548
558
  function Code(schema, references = []) {
@@ -576,4 +586,4 @@ var TypeCompiler;
576
586
  return new TypeCheck(schema, references, checkFunction, code);
577
587
  }
578
588
  TypeCompiler.Compile = Compile;
579
- })(TypeCompiler = exports.TypeCompiler || (exports.TypeCompiler = {}));
589
+ })(TypeCompiler || (exports.TypeCompiler = TypeCompiler = {}));
package/errors/errors.js CHANGED
@@ -95,7 +95,7 @@ var ValueErrorType;
95
95
  ValueErrorType[ValueErrorType["Uint8ArrayMaxByteLength"] = 56] = "Uint8ArrayMaxByteLength";
96
96
  ValueErrorType[ValueErrorType["Void"] = 57] = "Void";
97
97
  ValueErrorType[ValueErrorType["Custom"] = 58] = "Custom";
98
- })(ValueErrorType = exports.ValueErrorType || (exports.ValueErrorType = {}));
98
+ })(ValueErrorType || (exports.ValueErrorType = ValueErrorType = {}));
99
99
  // -------------------------------------------------------------------
100
100
  // ValueErrorIterator
101
101
  // -------------------------------------------------------------------
@@ -609,4 +609,4 @@ var ValueErrors;
609
609
  return new ValueErrorIterator(iterator);
610
610
  }
611
611
  ValueErrors.Errors = Errors;
612
- })(ValueErrors = exports.ValueErrors || (exports.ValueErrors = {}));
612
+ })(ValueErrors || (exports.ValueErrors = ValueErrors = {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sinclair/typebox",
3
- "version": "0.28.14",
3
+ "version": "0.28.16",
4
4
  "description": "JSONSchema Type Builder with Static Type Resolution for TypeScript",
5
5
  "keywords": [
6
6
  "typescript",
@@ -42,6 +42,6 @@
42
42
  "chai": "^4.3.6",
43
43
  "mocha": "^9.2.2",
44
44
  "prettier": "^2.7.1",
45
- "typescript": "^5.0.4"
45
+ "typescript": "^5.1.3"
46
46
  }
47
47
  }
package/readme.md CHANGED
@@ -483,7 +483,7 @@ The following table lists the Standard TypeBox types. These types are fully comp
483
483
  │ ]) │ │ ], │
484
484
  │ const T = Type.Tuple([ │ │ additionalItems: false, │
485
485
  | ...Type.Rest(A), │ │ minItems: 4, │
486
- | ...Type.Test(B) │ │ maxItems: 4 │
486
+ | ...Type.Rest(B) │ │ maxItems: 4 │
487
487
  │ ]) │ │ } │
488
488
  │ │ │ │
489
489
  ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
@@ -870,7 +870,7 @@ const T = Type.Object({ // const T = {
870
870
  z: Type.Boolean() // properties: {
871
871
  }) // x: { type: 'number' },
872
872
  // y: { type: 'string' },
873
- // z: { type: 'string' },
873
+ // z: { type: 'string' }
874
874
  // }
875
875
  // }
876
876
 
@@ -896,7 +896,7 @@ const C = Type.Index(T, Type.KeyOf(T)) // const C = {
896
896
 
897
897
  ### Rest Types
898
898
 
899
- Rest parameters are supported with `Type.Rest`. This function is used to extract interior type elements from tuples which enables them to compose with the JavaScript spread operator `...`. This type can be used for tuple concatination as well as for variadic functions.
899
+ Rest parameters are supported with `Type.Rest`. This function is used to extract interior type elements from tuples which enables them to compose with the JavaScript spread operator `...`. This type can be used for tuple concatenation as well as for variadic functions.
900
900
 
901
901
  ```typescript
902
902
  // TypeScript
@@ -908,14 +908,14 @@ type C = [...T, number] // type C = [number, number
908
908
  type F = (...param: C) => void // type F = (
909
909
  // param0: number,
910
910
  // param1: number,
911
- // param2: number,
911
+ // param2: number
912
912
  // ) => void
913
913
 
914
914
  // TypeBox
915
915
 
916
916
  const T = Type.Tuple([ // const T: TTuple<[
917
917
  Type.Number(), // TNumber,
918
- Type.Number() // TNumber,
918
+ Type.Number() // TNumber
919
919
  ]) // ]>
920
920
 
921
921
  const C = Type.Tuple([ // const C: TTuple<[
@@ -1335,7 +1335,7 @@ console.log(C.Code()) // return function check(va
1335
1335
 
1336
1336
  ## TypeSystem
1337
1337
 
1338
- The TypeBox TypeSystem module provides functionality to define types above and beyond the Standard and Extended type sets as well as control various assertion polices. Configurations made to the TypeSystem module are observed by both `TypeCompiler` and `Value` modules.
1338
+ The TypeBox TypeSystem module provides functionality to define types above and beyond the Standard and Extended type sets as well as control various assertion policies. Configurations made to the TypeSystem module are observed by both `TypeCompiler` and `Value` modules.
1339
1339
 
1340
1340
  The TypeSystem module is provided as an optional import.
1341
1341
 
@@ -1462,35 +1462,35 @@ This benchmark measures compilation performance for varying types. You can revie
1462
1462
  ┌────────────────────────────┬────────────┬──────────────┬──────────────┬──────────────┐
1463
1463
  │ (index) │ Iterations │ Ajv │ TypeCompiler │ Performance │
1464
1464
  ├────────────────────────────┼────────────┼──────────────┼──────────────┼──────────────┤
1465
- │ Literal_String │ 1000 │ ' 230 ms' │ ' 7 ms' │ ' 32.86 x' │
1466
- │ Literal_Number │ 1000 │ ' 171 ms' │ ' 4 ms' │ ' 42.75 x' │
1467
- │ Literal_Boolean │ 1000 │ ' 148 ms' │ ' 4 ms' │ ' 37.00 x' │
1468
- │ Primitive_Number │ 1000 │ ' 160 ms' │ ' 6 ms' │ ' 26.67 x' │
1469
- │ Primitive_String │ 1000 │ ' 149 ms' │ ' 6 ms' │ ' 24.83 x' │
1470
- │ Primitive_String_Pattern │ 1000 │ ' 199 ms' │ ' 9 ms' │ ' 22.11 x' │
1471
- │ Primitive_Boolean │ 1000 │ ' 126 ms' │ ' 3 ms' │ ' 42.00 x' │
1472
- │ Primitive_Null │ 1000 │ ' 141 ms' │ ' 4 ms' │ ' 35.25 x' │
1473
- │ Object_Unconstrained │ 1000 │ ' 1105 ms' │ ' 27 ms' │ ' 40.93 x' │
1474
- │ Object_Constrained │ 1000 │ ' 1178 ms' │ ' 22 ms' │ ' 53.55 x' │
1475
- │ Object_Vector3 │ 1000 │ ' 368 ms' │ ' 8 ms' │ ' 46.00 x' │
1476
- │ Object_Box3D │ 1000 │ ' 1668 ms' │ ' 28 ms' │ ' 59.57 x' │
1477
- │ Tuple_Primitive │ 1000 │ ' 446 ms' │ ' 12 ms' │ ' 37.17 x' │
1478
- │ Tuple_Object │ 1000 │ ' 1146 ms' │ ' 15 ms' │ ' 76.40 x' │
1479
- │ Composite_Intersect │ 1000 │ ' 661 ms' │ ' 18 ms' │ ' 36.72 x' │
1480
- │ Composite_Union │ 1000 │ ' 513 ms' │ ' 17 ms' │ ' 30.18 x' │
1481
- │ Math_Vector4 │ 1000 │ ' 767 ms' │ ' 10 ms' │ ' 76.70 x' │
1482
- │ Math_Matrix4 │ 1000 │ ' 396 ms' │ ' 10 ms' │ ' 39.60 x' │
1483
- │ Array_Primitive_Number │ 1000 │ ' 353 ms' │ ' 8 ms' │ ' 44.13 x' │
1484
- │ Array_Primitive_String │ 1000 │ ' 358 ms' │ ' 5 ms' │ ' 71.60 x' │
1485
- │ Array_Primitive_Boolean │ 1000 │ ' 265 ms' │ ' 3 ms' │ ' 88.33 x' │
1486
- │ Array_Object_Unconstrained │ 1000 │ ' 1476 ms' │ ' 19 ms' │ ' 77.68 x' │
1487
- │ Array_Object_Constrained │ 1000 │ ' 1698 ms' │ ' 20 ms' │ ' 84.90 x' │
1488
- │ Array_Tuple_Primitive │ 1000 │ ' 654 ms' │ ' 9 ms' │ ' 72.67 x' │
1489
- │ Array_Tuple_Object │ 1000 │ ' 1492 ms' │ ' 15 ms' │ ' 99.47 x' │
1490
- │ Array_Composite_Intersect │ 1000 │ ' 1045 ms' │ ' 16 ms' │ ' 65.31 x' │
1491
- │ Array_Composite_Union │ 1000 │ ' 702 ms' │ ' 14 ms' │ ' 50.14 x' │
1492
- │ Array_Math_Vector4 │ 1000 │ ' 1016 ms' │ ' 12 ms' │ ' 84.67 x' │
1493
- │ Array_Math_Matrix4 │ 1000 │ ' 621 ms' │ ' 5 ms' │ ' 124.20 x' │
1465
+ │ Literal_String │ 1000 │ ' 220 ms' │ ' 6 ms' │ ' 36.67 x' │
1466
+ │ Literal_Number │ 1000 │ ' 172 ms' │ ' 4 ms' │ ' 43.00 x' │
1467
+ │ Literal_Boolean │ 1000 │ ' 162 ms' │ ' 4 ms' │ ' 40.50 x' │
1468
+ │ Primitive_Number │ 1000 │ ' 161 ms' │ ' 6 ms' │ ' 26.83 x' │
1469
+ │ Primitive_String │ 1000 │ ' 154 ms' │ ' 4 ms' │ ' 38.50 x' │
1470
+ │ Primitive_String_Pattern │ 1000 │ ' 204 ms' │ ' 10 ms' │ ' 20.40 x' │
1471
+ │ Primitive_Boolean │ 1000 │ ' 131 ms' │ ' 4 ms' │ ' 32.75 x' │
1472
+ │ Primitive_Null │ 1000 │ ' 142 ms' │ ' 5 ms' │ ' 28.40 x' │
1473
+ │ Object_Unconstrained │ 1000 │ ' 1263 ms' │ ' 29 ms' │ ' 43.55 x' │
1474
+ │ Object_Constrained │ 1000 │ ' 1267 ms' │ ' 24 ms' │ ' 52.79 x' │
1475
+ │ Object_Vector3 │ 1000 │ ' 382 ms' │ ' 7 ms' │ ' 54.57 x' │
1476
+ │ Object_Box3D │ 1000 │ ' 1723 ms' │ ' 28 ms' │ ' 61.54 x' │
1477
+ │ Tuple_Primitive │ 1000 │ ' 495 ms' │ ' 13 ms' │ ' 38.08 x' │
1478
+ │ Tuple_Object │ 1000 │ ' 1271 ms' │ ' 16 ms' │ ' 79.44 x' │
1479
+ │ Composite_Intersect │ 1000 │ ' 656 ms' │ ' 19 ms' │ ' 34.53 x' │
1480
+ │ Composite_Union │ 1000 │ ' 529 ms' │ ' 18 ms' │ ' 29.39 x' │
1481
+ │ Math_Vector4 │ 1000 │ ' 802 ms' │ ' 14 ms' │ ' 57.29 x' │
1482
+ │ Math_Matrix4 │ 1000 │ ' 411 ms' │ ' 6 ms' │ ' 68.50 x' │
1483
+ │ Array_Primitive_Number │ 1000 │ ' 369 ms' │ ' 6 ms' │ ' 61.50 x' │
1484
+ │ Array_Primitive_String │ 1000 │ ' 369 ms' │ ' 4 ms' │ ' 92.25 x' │
1485
+ │ Array_Primitive_Boolean │ 1000 │ ' 297 ms' │ ' 3 ms' │ ' 99.00 x' │
1486
+ │ Array_Object_Unconstrained │ 1000 │ ' 1582 ms' │ ' 20 ms' │ ' 79.10 x' │
1487
+ │ Array_Object_Constrained │ 1000 │ ' 1629 ms' │ ' 19 ms' │ ' 85.74 x' │
1488
+ │ Array_Tuple_Primitive │ 1000 │ ' 652 ms' │ ' 12 ms' │ ' 54.33 x' │
1489
+ │ Array_Tuple_Object │ 1000 │ ' 1587 ms' │ ' 16 ms' │ ' 99.19 x' │
1490
+ │ Array_Composite_Intersect │ 1000 │ ' 1051 ms' │ ' 15 ms' │ ' 70.07 x' │
1491
+ │ Array_Composite_Union │ 1000 │ ' 733 ms' │ ' 15 ms' │ ' 48.87 x' │
1492
+ │ Array_Math_Vector4 │ 1000 │ ' 1071 ms' │ ' 12 ms' │ ' 89.25 x' │
1493
+ │ Array_Math_Matrix4 │ 1000 │ ' 636 ms' │ ' 5 ms' │ ' 127.20 x' │
1494
1494
  └────────────────────────────┴────────────┴──────────────┴──────────────┴──────────────┘
1495
1495
  ```
1496
1496
 
@@ -1504,37 +1504,37 @@ This benchmark measures validation performance for varying types. You can review
1504
1504
  ┌────────────────────────────┬────────────┬──────────────┬──────────────┬──────────────┬──────────────┐
1505
1505
  │ (index) │ Iterations │ ValueCheck │ Ajv │ TypeCompiler │ Performance │
1506
1506
  ├────────────────────────────┼────────────┼──────────────┼──────────────┼──────────────┼──────────────┤
1507
- │ Literal_String │ 1000000 │ ' 22 ms' │ ' 5 ms' │ ' 4 ms' │ ' 1.25 x' │
1508
- │ Literal_Number │ 1000000 │ ' 19 ms' │ ' 17 ms' │ ' 9 ms' │ ' 1.89 x' │
1509
- │ Literal_Boolean │ 1000000 │ ' 18 ms' │ ' 17 ms' │ ' 9 ms' │ ' 1.89 x' │
1510
- │ Primitive_Number │ 1000000 │ ' 23 ms' │ ' 17 ms' │ ' 9 ms' │ ' 1.89 x' │
1511
- │ Primitive_String │ 1000000 │ ' 23 ms' │ ' 18 ms' │ ' 9 ms' │ ' 2.00 x' │
1512
- │ Primitive_String_Pattern │ 1000000 │ ' 171 ms' │ ' 42 ms' │ ' 36 ms' │ ' 1.17 x' │
1513
- │ Primitive_Boolean │ 1000000 │ ' 20 ms' │ ' 17 ms' │ ' 9 ms' │ ' 1.89 x' │
1514
- │ Primitive_Null │ 1000000 │ ' 21 ms' │ ' 16 ms' │ ' 8 ms' │ ' 2.00 x' │
1515
- │ Object_Unconstrained │ 1000000 │ ' 1099 ms' │ ' 31 ms' │ ' 25 ms' │ ' 1.24 x' │
1516
- │ Object_Constrained │ 1000000 │ ' 1224 ms' │ ' 51 ms' │ ' 36 ms' │ ' 1.42 x' │
1517
- │ Object_Vector3 │ 1000000 │ ' 420 ms' │ ' 22 ms' │ ' 13 ms' │ ' 1.69 x' │
1518
- │ Object_Box3D │ 1000000 │ ' 2012 ms' │ ' 53 ms' │ ' 43 ms' │ ' 1.23 x' │
1519
- │ Object_Recursive │ 1000000 │ ' 5080 ms' │ ' 320 ms' │ ' 150 ms' │ ' 2.13 x' │
1520
- │ Tuple_Primitive │ 1000000 │ ' 154 ms' │ ' 20 ms' │ ' 12 ms' │ ' 1.67 x' │
1521
- │ Tuple_Object │ 1000000 │ ' 749 ms' │ ' 27 ms' │ ' 18 ms' │ ' 1.50 x' │
1522
- │ Composite_Intersect │ 1000000 │ ' 775 ms' │ ' 24 ms' │ ' 14 ms' │ ' 1.71 x' │
1523
- │ Composite_Union │ 1000000 │ ' 533 ms' │ ' 22 ms' │ ' 13 ms' │ ' 1.69 x' │
1524
- │ Math_Vector4 │ 1000000 │ ' 275 ms' │ ' 20 ms' │ ' 11 ms' │ ' 1.82 x' │
1525
- │ Math_Matrix4 │ 1000000 │ ' 1136 ms' │ ' 37 ms' │ ' 26 ms' │ ' 1.42 x' │
1526
- │ Array_Primitive_Number │ 1000000 │ ' 316 ms' │ ' 20 ms' │ ' 12 ms' │ ' 1.67 x' │
1527
- │ Array_Primitive_String │ 1000000 │ ' 239 ms' │ ' 20 ms' │ ' 12 ms' │ ' 1.67 x' │
1528
- │ Array_Primitive_Boolean │ 1000000 │ ' 151 ms' │ ' 20 ms' │ ' 15 ms' │ ' 1.33 x' │
1529
- │ Array_Object_Unconstrained │ 1000000 │ ' 5809 ms' │ ' 64 ms' │ ' 56 ms' │ ' 1.14 x' │
1530
- │ Array_Object_Constrained │ 1000000 │ ' 6210 ms' │ ' 123 ms' │ ' 101 ms' │ ' 1.22 x' │
1531
- │ Array_Object_Recursive │ 1000000 │ ' 21779 ms' │ ' 1466 ms' │ ' 548 ms' │ ' 2.68 x' │
1532
- │ Array_Tuple_Primitive │ 1000000 │ ' 730 ms' │ ' 36 ms' │ ' 29 ms' │ ' 1.24 x' │
1533
- │ Array_Tuple_Object │ 1000000 │ ' 3259 ms' │ ' 63 ms' │ ' 49 ms' │ ' 1.29 x' │
1534
- │ Array_Composite_Intersect │ 1000000 │ ' 3276 ms' │ ' 44 ms' │ ' 34 ms' │ ' 1.29 x' │
1535
- │ Array_Composite_Union │ 1000000 │ ' 2279 ms' │ ' 64 ms' │ ' 31 ms' │ ' 2.06 x' │
1536
- │ Array_Math_Vector4 │ 1000000 │ ' 1139 ms' │ ' 36 ms' │ ' 23 ms' │ ' 1.57 x' │
1537
- │ Array_Math_Matrix4 │ 1000000 │ ' 4924 ms' │ ' 110 ms' │ ' 92 ms' │ ' 1.20 x' │
1507
+ │ Literal_String │ 1000000 │ ' 24 ms' │ ' 5 ms' │ ' 5 ms' │ ' 1.00 x' │
1508
+ │ Literal_Number │ 1000000 │ ' 21 ms' │ ' 17 ms' │ ' 9 ms' │ ' 1.89 x' │
1509
+ │ Literal_Boolean │ 1000000 │ ' 18 ms' │ ' 18 ms' │ ' 9 ms' │ ' 2.00 x' │
1510
+ │ Primitive_Number │ 1000000 │ ' 25 ms' │ ' 18 ms' │ ' 9 ms' │ ' 2.00 x' │
1511
+ │ Primitive_String │ 1000000 │ ' 25 ms' │ ' 17 ms' │ ' 9 ms' │ ' 1.89 x' │
1512
+ │ Primitive_String_Pattern │ 1000000 │ ' 174 ms' │ ' 44 ms' │ ' 36 ms' │ ' 1.22 x' │
1513
+ │ Primitive_Boolean │ 1000000 │ ' 22 ms' │ ' 17 ms' │ ' 9 ms' │ ' 1.89 x' │
1514
+ │ Primitive_Null │ 1000000 │ ' 22 ms' │ ' 16 ms' │ ' 9 ms' │ ' 1.78 x' │
1515
+ │ Object_Unconstrained │ 1000000 │ ' 1065 ms' │ ' 33 ms' │ ' 25 ms' │ ' 1.32 x' │
1516
+ │ Object_Constrained │ 1000000 │ ' 1192 ms' │ ' 53 ms' │ ' 38 ms' │ ' 1.39 x' │
1517
+ │ Object_Vector3 │ 1000000 │ ' 410 ms' │ ' 23 ms' │ ' 14 ms' │ ' 1.64 x' │
1518
+ │ Object_Box3D │ 1000000 │ ' 1939 ms' │ ' 54 ms' │ ' 50 ms' │ ' 1.08 x' │
1519
+ │ Object_Recursive │ 1000000 │ ' 5248 ms' │ ' 355 ms' │ ' 149 ms' │ ' 2.38 x' │
1520
+ │ Tuple_Primitive │ 1000000 │ ' 163 ms' │ ' 21 ms' │ ' 13 ms' │ ' 1.62 x' │
1521
+ │ Tuple_Object │ 1000000 │ ' 737 ms' │ ' 29 ms' │ ' 20 ms' │ ' 1.45 x' │
1522
+ │ Composite_Intersect │ 1000000 │ ' 761 ms' │ ' 24 ms' │ ' 15 ms' │ ' 1.60 x' │
1523
+ │ Composite_Union │ 1000000 │ ' 519 ms' │ ' 23 ms' │ ' 13 ms' │ ' 1.77 x' │
1524
+ │ Math_Vector4 │ 1000000 │ ' 247 ms' │ ' 21 ms' │ ' 11 ms' │ ' 1.91 x' │
1525
+ │ Math_Matrix4 │ 1000000 │ ' 1045 ms' │ ' 39 ms' │ ' 27 ms' │ ' 1.44 x' │
1526
+ │ Array_Primitive_Number │ 1000000 │ ' 256 ms' │ ' 20 ms' │ ' 12 ms' │ ' 1.67 x' │
1527
+ │ Array_Primitive_String │ 1000000 │ ' 222 ms' │ ' 21 ms' │ ' 14 ms' │ ' 1.50 x' │
1528
+ │ Array_Primitive_Boolean │ 1000000 │ ' 149 ms' │ ' 22 ms' │ ' 16 ms' │ ' 1.38 x' │
1529
+ │ Array_Object_Unconstrained │ 1000000 │ ' 5473 ms' │ ' 67 ms' │ ' 59 ms' │ ' 1.14 x' │
1530
+ │ Array_Object_Constrained │ 1000000 │ ' 5548 ms' │ ' 130 ms' │ ' 116 ms' │ ' 1.12 x' │
1531
+ │ Array_Object_Recursive │ 1000000 │ ' 21047 ms' │ ' 1710 ms' │ ' 584 ms' │ ' 2.93 x' │
1532
+ │ Array_Tuple_Primitive │ 1000000 │ ' 691 ms' │ ' 35 ms' │ ' 29 ms' │ ' 1.21 x' │
1533
+ │ Array_Tuple_Object │ 1000000 │ ' 3075 ms' │ ' 63 ms' │ ' 50 ms' │ ' 1.26 x' │
1534
+ │ Array_Composite_Intersect │ 1000000 │ ' 3126 ms' │ ' 44 ms' │ ' 35 ms' │ ' 1.26 x' │
1535
+ │ Array_Composite_Union │ 1000000 │ ' 2086 ms' │ ' 68 ms' │ ' 33 ms' │ ' 2.06 x' │
1536
+ │ Array_Math_Vector4 │ 1000000 │ ' 1069 ms' │ ' 38 ms' │ ' 23 ms' │ ' 1.65 x' │
1537
+ │ Array_Math_Matrix4 │ 1000000 │ ' 4559 ms' │ ' 111 ms' │ ' 88 ms' │ ' 1.26 x' │
1538
1538
  └────────────────────────────┴────────────┴──────────────┴──────────────┴──────────────┴──────────────┘
1539
1539
  ```
1540
1540
 
@@ -1548,7 +1548,7 @@ The following table lists esbuild compiled and minified sizes for each TypeBox m
1548
1548
  ┌──────────────────────┬────────────┬────────────┬─────────────┐
1549
1549
  │ (index) │ Compiled │ Minified │ Compression │
1550
1550
  ├──────────────────────┼────────────┼────────────┼─────────────┤
1551
- │ typebox/compiler │ '128.0 kb' │ ' 56.9 kb' │ '2.25 x' │
1551
+ │ typebox/compiler │ '128.0 kb' │ ' 57.0 kb' │ '2.25 x' │
1552
1552
  │ typebox/errors │ '111.6 kb' │ ' 49.1 kb' │ '2.27 x' │
1553
1553
  │ typebox/system │ ' 77.0 kb' │ ' 31.5 kb' │ '2.45 x' │
1554
1554
  │ typebox/value │ '177.7 kb' │ ' 76.8 kb' │ '2.31 x' │
package/system/system.js CHANGED
@@ -74,4 +74,4 @@ var TypeSystem;
74
74
  return format;
75
75
  }
76
76
  TypeSystem.Format = Format;
77
- })(TypeSystem = exports.TypeSystem || (exports.TypeSystem = {}));
77
+ })(TypeSystem || (exports.TypeSystem = TypeSystem = {}));
package/typebox.js CHANGED
@@ -72,7 +72,7 @@ var TypeRegistry;
72
72
  return map.get(kind);
73
73
  }
74
74
  TypeRegistry.Get = Get;
75
- })(TypeRegistry = exports.TypeRegistry || (exports.TypeRegistry = {}));
75
+ })(TypeRegistry || (exports.TypeRegistry = TypeRegistry = {}));
76
76
  /** A registry for user defined string formats */
77
77
  var FormatRegistry;
78
78
  (function (FormatRegistry) {
@@ -102,7 +102,7 @@ var FormatRegistry;
102
102
  return map.get(format);
103
103
  }
104
104
  FormatRegistry.Get = Get;
105
- })(FormatRegistry = exports.FormatRegistry || (exports.FormatRegistry = {}));
105
+ })(FormatRegistry || (exports.FormatRegistry = FormatRegistry = {}));
106
106
  // --------------------------------------------------------------------------
107
107
  // TypeGuard
108
108
  // --------------------------------------------------------------------------
@@ -611,7 +611,7 @@ var TypeGuard;
611
611
  (TKind(schema) && TypeRegistry.Has(schema[exports.Kind]))));
612
612
  }
613
613
  TypeGuard.TSchema = TSchema;
614
- })(TypeGuard = exports.TypeGuard || (exports.TypeGuard = {}));
614
+ })(TypeGuard || (exports.TypeGuard = TypeGuard = {}));
615
615
  // --------------------------------------------------------------------------
616
616
  // ExtendsUndefined
617
617
  // --------------------------------------------------------------------------
@@ -636,7 +636,7 @@ var ExtendsUndefined;
636
636
  return false;
637
637
  }
638
638
  ExtendsUndefined.Check = Check;
639
- })(ExtendsUndefined = exports.ExtendsUndefined || (exports.ExtendsUndefined = {}));
639
+ })(ExtendsUndefined || (exports.ExtendsUndefined = ExtendsUndefined = {}));
640
640
  // --------------------------------------------------------------------------
641
641
  // TypeExtends
642
642
  // --------------------------------------------------------------------------
@@ -645,7 +645,7 @@ var TypeExtendsResult;
645
645
  TypeExtendsResult[TypeExtendsResult["Union"] = 0] = "Union";
646
646
  TypeExtendsResult[TypeExtendsResult["True"] = 1] = "True";
647
647
  TypeExtendsResult[TypeExtendsResult["False"] = 2] = "False";
648
- })(TypeExtendsResult = exports.TypeExtendsResult || (exports.TypeExtendsResult = {}));
648
+ })(TypeExtendsResult || (exports.TypeExtendsResult = TypeExtendsResult = {}));
649
649
  var TypeExtends;
650
650
  (function (TypeExtends) {
651
651
  // --------------------------------------------------------------------------
@@ -1369,7 +1369,7 @@ var TypeExtends;
1369
1369
  return Visit(left, right);
1370
1370
  }
1371
1371
  TypeExtends.Extends = Extends;
1372
- })(TypeExtends = exports.TypeExtends || (exports.TypeExtends = {}));
1372
+ })(TypeExtends || (exports.TypeExtends = TypeExtends = {}));
1373
1373
  // --------------------------------------------------------------------------
1374
1374
  // TypeClone
1375
1375
  // --------------------------------------------------------------------------
@@ -1406,7 +1406,7 @@ var TypeClone;
1406
1406
  return { ...Visit(schema), ...options };
1407
1407
  }
1408
1408
  TypeClone.Clone = Clone;
1409
- })(TypeClone = exports.TypeClone || (exports.TypeClone = {}));
1409
+ })(TypeClone || (exports.TypeClone = TypeClone = {}));
1410
1410
  // --------------------------------------------------------------------------
1411
1411
  // IndexedAccessor
1412
1412
  // --------------------------------------------------------------------------
@@ -1452,7 +1452,7 @@ var IndexedAccessor;
1452
1452
  return exports.Type.Union(keys.map((key) => Visit(schema, key.toString())), options);
1453
1453
  }
1454
1454
  IndexedAccessor.Resolve = Resolve;
1455
- })(IndexedAccessor = exports.IndexedAccessor || (exports.IndexedAccessor = {}));
1455
+ })(IndexedAccessor || (exports.IndexedAccessor = IndexedAccessor = {}));
1456
1456
  // --------------------------------------------------------------------------
1457
1457
  // ObjectMap
1458
1458
  // --------------------------------------------------------------------------
@@ -1486,7 +1486,7 @@ var ObjectMap;
1486
1486
  return { ...Visit(TypeClone.Clone(schema, {}), callback), ...options };
1487
1487
  }
1488
1488
  ObjectMap.Map = Map;
1489
- })(ObjectMap = exports.ObjectMap || (exports.ObjectMap = {}));
1489
+ })(ObjectMap || (exports.ObjectMap = ObjectMap = {}));
1490
1490
  var KeyResolver;
1491
1491
  (function (KeyResolver) {
1492
1492
  function UnwrapPattern(key) {
@@ -1528,7 +1528,7 @@ var KeyResolver;
1528
1528
  return `^(${pattern.join('|')})$`;
1529
1529
  }
1530
1530
  KeyResolver.ResolvePattern = ResolvePattern;
1531
- })(KeyResolver = exports.KeyResolver || (exports.KeyResolver = {}));
1531
+ })(KeyResolver || (exports.KeyResolver = KeyResolver = {}));
1532
1532
  // --------------------------------------------------------------------------
1533
1533
  // KeyArrayResolver
1534
1534
  // --------------------------------------------------------------------------
@@ -1551,7 +1551,7 @@ var KeyArrayResolver;
1551
1551
  return [];
1552
1552
  }
1553
1553
  KeyArrayResolver.Resolve = Resolve;
1554
- })(KeyArrayResolver = exports.KeyArrayResolver || (exports.KeyArrayResolver = {}));
1554
+ })(KeyArrayResolver || (exports.KeyArrayResolver = KeyArrayResolver = {}));
1555
1555
  // --------------------------------------------------------------------------
1556
1556
  // UnionResolver
1557
1557
  // --------------------------------------------------------------------------
@@ -1572,7 +1572,7 @@ var UnionResolver;
1572
1572
  return exports.Type.Union([...Union(union)], { ...union });
1573
1573
  }
1574
1574
  UnionResolver.Resolve = Resolve;
1575
- })(UnionResolver = exports.UnionResolver || (exports.UnionResolver = {}));
1575
+ })(UnionResolver || (exports.UnionResolver = UnionResolver = {}));
1576
1576
  // --------------------------------------------------------------------------
1577
1577
  // TemplateLiteralPattern
1578
1578
  // --------------------------------------------------------------------------
@@ -1619,7 +1619,7 @@ var TemplateLiteralPattern;
1619
1619
  return `^${kinds.map((schema) => Visit(schema, '')).join('')}\$`;
1620
1620
  }
1621
1621
  TemplateLiteralPattern.Create = Create;
1622
- })(TemplateLiteralPattern = exports.TemplateLiteralPattern || (exports.TemplateLiteralPattern = {}));
1622
+ })(TemplateLiteralPattern || (exports.TemplateLiteralPattern = TemplateLiteralPattern = {}));
1623
1623
  // --------------------------------------------------------------------------------------
1624
1624
  // TemplateLiteralResolver
1625
1625
  // --------------------------------------------------------------------------------------
@@ -1634,7 +1634,7 @@ var TemplateLiteralResolver;
1634
1634
  return exports.Type.Union(literals);
1635
1635
  }
1636
1636
  TemplateLiteralResolver.Resolve = Resolve;
1637
- })(TemplateLiteralResolver = exports.TemplateLiteralResolver || (exports.TemplateLiteralResolver = {}));
1637
+ })(TemplateLiteralResolver || (exports.TemplateLiteralResolver = TemplateLiteralResolver = {}));
1638
1638
  // --------------------------------------------------------------------------------------
1639
1639
  // TemplateLiteralParser
1640
1640
  // --------------------------------------------------------------------------------------
@@ -1778,7 +1778,7 @@ var TemplateLiteralParser;
1778
1778
  return Parse(pattern.slice(1, pattern.length - 1));
1779
1779
  }
1780
1780
  TemplateLiteralParser.ParseExact = ParseExact;
1781
- })(TemplateLiteralParser = exports.TemplateLiteralParser || (exports.TemplateLiteralParser = {}));
1781
+ })(TemplateLiteralParser || (exports.TemplateLiteralParser = TemplateLiteralParser = {}));
1782
1782
  // --------------------------------------------------------------------------------------
1783
1783
  // TemplateLiteralFinite
1784
1784
  // --------------------------------------------------------------------------------------
@@ -1819,7 +1819,7 @@ var TemplateLiteralFinite;
1819
1819
  throw Error(`TemplateLiteralFinite: Unknown expression type`);
1820
1820
  }
1821
1821
  TemplateLiteralFinite.Check = Check;
1822
- })(TemplateLiteralFinite = exports.TemplateLiteralFinite || (exports.TemplateLiteralFinite = {}));
1822
+ })(TemplateLiteralFinite || (exports.TemplateLiteralFinite = TemplateLiteralFinite = {}));
1823
1823
  // --------------------------------------------------------------------------------------
1824
1824
  // TemplateLiteralGenerator
1825
1825
  // --------------------------------------------------------------------------------------
@@ -1854,7 +1854,7 @@ var TemplateLiteralGenerator;
1854
1854
  throw Error('TemplateLiteralGenerator: Unknown expression');
1855
1855
  }
1856
1856
  TemplateLiteralGenerator.Generate = Generate;
1857
- })(TemplateLiteralGenerator = exports.TemplateLiteralGenerator || (exports.TemplateLiteralGenerator = {}));
1857
+ })(TemplateLiteralGenerator || (exports.TemplateLiteralGenerator = TemplateLiteralGenerator = {}));
1858
1858
  // ---------------------------------------------------------------------
1859
1859
  // TemplateLiteralDslParser
1860
1860
  // ---------------------------------------------------------------------
@@ -1902,7 +1902,7 @@ var TemplateLiteralDslParser;
1902
1902
  return [...ParseLiteral(template_dsl)];
1903
1903
  }
1904
1904
  TemplateLiteralDslParser.Parse = Parse;
1905
- })(TemplateLiteralDslParser = exports.TemplateLiteralDslParser || (exports.TemplateLiteralDslParser = {}));
1905
+ })(TemplateLiteralDslParser || (exports.TemplateLiteralDslParser = TemplateLiteralDslParser = {}));
1906
1906
  // --------------------------------------------------------------------------
1907
1907
  // TypeOrdinal: Used for auto $id generation
1908
1908
  // --------------------------------------------------------------------------
package/value/cast.js CHANGED
@@ -369,4 +369,4 @@ var ValueCast;
369
369
  return Visit(schema, references, clone_1.ValueClone.Clone(value));
370
370
  }
371
371
  ValueCast.Cast = Cast;
372
- })(ValueCast = exports.ValueCast || (exports.ValueCast = {}));
372
+ })(ValueCast || (exports.ValueCast = ValueCast = {}));
package/value/check.js CHANGED
@@ -489,4 +489,4 @@ var ValueCheck;
489
489
  return Visit(schema, references, value);
490
490
  }
491
491
  ValueCheck.Check = Check;
492
- })(ValueCheck = exports.ValueCheck || (exports.ValueCheck = {}));
492
+ })(ValueCheck || (exports.ValueCheck = ValueCheck = {}));
package/value/clone.js CHANGED
@@ -68,4 +68,4 @@ var ValueClone;
68
68
  }
69
69
  }
70
70
  ValueClone.Clone = Clone;
71
- })(ValueClone = exports.ValueClone || (exports.ValueClone = {}));
71
+ })(ValueClone || (exports.ValueClone = ValueClone = {}));
package/value/convert.js CHANGED
@@ -369,4 +369,4 @@ var ValueConvert;
369
369
  return Visit(schema, references, clone_1.ValueClone.Clone(value));
370
370
  }
371
371
  ValueConvert.Convert = Convert;
372
- })(ValueConvert = exports.ValueConvert || (exports.ValueConvert = {}));
372
+ })(ValueConvert || (exports.ValueConvert = ValueConvert = {}));
package/value/create.js CHANGED
@@ -477,4 +477,4 @@ var ValueCreate;
477
477
  return Visit(schema, references);
478
478
  }
479
479
  ValueCreate.Create = Create;
480
- })(ValueCreate = exports.ValueCreate || (exports.ValueCreate = {}));
480
+ })(ValueCreate || (exports.ValueCreate = ValueCreate = {}));
package/value/delta.js CHANGED
@@ -201,4 +201,4 @@ var ValueDelta;
201
201
  return clone;
202
202
  }
203
203
  ValueDelta.Patch = Patch;
204
- })(ValueDelta = exports.ValueDelta || (exports.ValueDelta = {}));
204
+ })(ValueDelta || (exports.ValueDelta = ValueDelta = {}));
package/value/equal.js CHANGED
@@ -77,4 +77,4 @@ var ValueEqual;
77
77
  }
78
78
  }
79
79
  ValueEqual.Equal = Equal;
80
- })(ValueEqual = exports.ValueEqual || (exports.ValueEqual = {}));
80
+ })(ValueEqual || (exports.ValueEqual = ValueEqual = {}));
package/value/hash.js CHANGED
@@ -205,4 +205,4 @@ var ValueHash;
205
205
  return Hash;
206
206
  }
207
207
  ValueHash.Create = Create;
208
- })(ValueHash = exports.ValueHash || (exports.ValueHash = {}));
208
+ })(ValueHash || (exports.ValueHash = ValueHash = {}));
package/value/is.js CHANGED
@@ -50,4 +50,4 @@ var Is;
50
50
  return ArrayBuffer.isView(value);
51
51
  }
52
52
  Is.TypedArray = TypedArray;
53
- })(Is = exports.Is || (exports.Is = {}));
53
+ })(Is || (exports.Is = Is = {}));
package/value/mutate.js CHANGED
@@ -118,4 +118,4 @@ var ValueMutate;
118
118
  Visit(current, '', current, next);
119
119
  }
120
120
  ValueMutate.Mutate = Mutate;
121
- })(ValueMutate = exports.ValueMutate || (exports.ValueMutate = {}));
121
+ })(ValueMutate || (exports.ValueMutate = ValueMutate = {}));
package/value/pointer.js CHANGED
@@ -139,4 +139,4 @@ var ValuePointer;
139
139
  return current;
140
140
  }
141
141
  ValuePointer.Get = Get;
142
- })(ValuePointer = exports.ValuePointer || (exports.ValuePointer = {}));
142
+ })(ValuePointer || (exports.ValuePointer = ValuePointer = {}));
package/value/value.js CHANGED
@@ -96,4 +96,4 @@ var Value;
96
96
  mutate_1.ValueMutate.Mutate(current, next);
97
97
  }
98
98
  Value.Mutate = Mutate;
99
- })(Value = exports.Value || (exports.Value = {}));
99
+ })(Value || (exports.Value = Value = {}));