@sinclair/typebox 0.24.19 → 0.24.22

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.
@@ -29,6 +29,7 @@ THE SOFTWARE.
29
29
  Object.defineProperty(exports, "__esModule", { value: true });
30
30
  exports.TypeCompiler = exports.TypeCheck = void 0;
31
31
  const errors_1 = require("../value/errors");
32
+ const property_1 = require("./property");
32
33
  const Types = require("../typebox");
33
34
  // -------------------------------------------------------------------
34
35
  // TypeCheck
@@ -61,13 +62,13 @@ exports.TypeCheck = TypeCheck;
61
62
  var TypeCompiler;
62
63
  (function (TypeCompiler) {
63
64
  // -------------------------------------------------------------------
64
- // Schemas
65
+ // Types
65
66
  // -------------------------------------------------------------------
66
67
  function* Any(schema, value) {
67
68
  yield '(true)';
68
69
  }
69
70
  function* Array(schema, value) {
70
- const expression = [...Visit(schema.items, `value`)].map((condition) => condition).join(' && ');
71
+ const expression = CreateExpression(schema.items, 'value');
71
72
  if (schema.minItems !== undefined)
72
73
  yield `(${value}.length >= ${schema.minItems})`;
73
74
  if (schema.maxItems !== undefined)
@@ -143,13 +144,14 @@ var TypeCompiler;
143
144
  }
144
145
  }
145
146
  for (const propertyKey of propertyKeys) {
147
+ const memberExpression = property_1.Property.Check(propertyKey) ? `${value}.${propertyKey}` : `${value}['${propertyKey}']`;
146
148
  const propertySchema = schema.properties[propertyKey];
147
149
  if (schema.required && schema.required.includes(propertyKey)) {
148
- yield* Visit(propertySchema, `${value}.${propertyKey}`);
150
+ yield* Visit(propertySchema, memberExpression);
149
151
  }
150
152
  else {
151
- const expr = [...Visit(propertySchema, `${value}.${propertyKey}`)].map((condition) => condition).join(' && ');
152
- yield `(${value}.${propertyKey} === undefined ? true : (${expr}))`;
153
+ const expression = CreateExpression(propertySchema, memberExpression);
154
+ yield `(${memberExpression} === undefined ? true : (${expression}))`;
153
155
  }
154
156
  }
155
157
  }
@@ -159,25 +161,16 @@ var TypeCompiler;
159
161
  function* Record(schema, value) {
160
162
  yield `(typeof ${value} === 'object' && ${value} !== null && !Array.isArray(${value}))`;
161
163
  const [keyPattern, valueSchema] = globalThis.Object.entries(schema.patternProperties)[0];
162
- const local = PushLocal(`const local = new RegExp(/${keyPattern}/)`);
164
+ const local = PushLocal(`new RegExp(/${keyPattern}/)`);
163
165
  yield `(Object.keys(${value}).every(key => ${local}.test(key)))`;
164
- const expr = [...Visit(valueSchema, 'value')].map((condition) => condition).join(' && ');
165
- yield `(Object.values(${value}).every(value => ${expr}))`;
166
+ const expression = CreateExpression(valueSchema, 'value');
167
+ yield `(Object.values(${value}).every(value => ${expression}))`;
166
168
  }
167
169
  function* Ref(schema, value) {
168
- // reference: referenced schemas can originate from either additional
169
- // schemas or inline in the schema itself. Ideally the recursive
170
- // path should align to reference path. Consider for review.
171
- if (!functionNames.has(schema.$ref)) {
172
- const reference = referenceMap.get(schema.$ref);
173
- functionNames.add(schema.$ref);
174
- const conditions = [...Visit(reference, 'value')];
175
- const name = CreateFunctionName(schema.$ref);
176
- const body = CreateFunction(name, conditions);
177
- PushLocal(body);
178
- }
179
- const func = CreateFunctionName(schema.$ref);
180
- yield `(${func}(${value}))`;
170
+ if (!referenceMap.has(schema.$ref))
171
+ throw Error(`TypeCompiler.Ref: Cannot de-reference schema with $id '${schema.$ref}'`);
172
+ const reference = referenceMap.get(schema.$ref);
173
+ yield* Visit(reference, value);
181
174
  }
182
175
  function* Self(schema, value) {
183
176
  const func = CreateFunctionName(schema.$ref);
@@ -192,7 +185,7 @@ var TypeCompiler;
192
185
  yield `(${value}.length <= ${schema.maxLength})`;
193
186
  }
194
187
  if (schema.pattern !== undefined) {
195
- const local = PushLocal(`const local = new RegExp(/${schema.pattern}/);`);
188
+ const local = PushLocal(`new RegExp(/${schema.pattern}/);`);
196
189
  yield `(${local}.test(${value}))`;
197
190
  }
198
191
  }
@@ -202,16 +195,16 @@ var TypeCompiler;
202
195
  return yield `(${value}.length === 0)`;
203
196
  yield `(${value}.length === ${schema.maxItems})`;
204
197
  for (let i = 0; i < schema.items.length; i++) {
205
- const expr = [...Visit(schema.items[i], `${value}[${i}]`)].map((condition) => condition).join(' && ');
206
- yield `(${expr})`;
198
+ const expression = CreateExpression(schema.items[i], `${value}[${i}]`);
199
+ yield `(${expression})`;
207
200
  }
208
201
  }
209
202
  function* Undefined(schema, value) {
210
203
  yield `(${value} === undefined)`;
211
204
  }
212
205
  function* Union(schema, value) {
213
- const exprs = schema.anyOf.map((schema) => [...Visit(schema, value)].map((condition) => condition).join(' && '));
214
- yield `(${exprs.join(' || ')})`;
206
+ const expressions = schema.anyOf.map((schema) => CreateExpression(schema, value));
207
+ yield `(${expressions.join(' || ')})`;
215
208
  }
216
209
  function* Uint8Array(schema, value) {
217
210
  yield `(${value} instanceof Uint8Array)`;
@@ -230,12 +223,11 @@ var TypeCompiler;
230
223
  // reference: referenced schemas can originate from either additional
231
224
  // schemas or inline in the schema itself. Ideally the recursive
232
225
  // path should align to reference path. Consider for review.
233
- if (schema.$id && !functionNames.has(schema.$id)) {
234
- functionNames.add(schema.$id);
235
- const conditions = [...Visit(schema, 'value')];
226
+ if (schema.$id && !names.has(schema.$id)) {
227
+ names.add(schema.$id);
236
228
  const name = CreateFunctionName(schema.$id);
237
- const body = CreateFunction(name, conditions);
238
- PushLocal(body);
229
+ const body = CreateFunction(name, schema, 'value');
230
+ PushFunction(body);
239
231
  yield `(${name}(${value}))`;
240
232
  return;
241
233
  }
@@ -288,17 +280,17 @@ var TypeCompiler;
288
280
  }
289
281
  }
290
282
  // -------------------------------------------------------------------
291
- // Locals
283
+ // Compile State
292
284
  // -------------------------------------------------------------------
293
285
  const referenceMap = new Map();
294
- const functionLocals = new Set();
295
- const functionNames = new Set();
296
- function ClearLocals() {
297
- functionLocals.clear();
298
- functionNames.clear();
286
+ const locals = new Set(); // local variables and functions
287
+ const names = new Set(); // cache of local functions
288
+ function ResetCompiler() {
299
289
  referenceMap.clear();
290
+ locals.clear();
291
+ names.clear();
300
292
  }
301
- function PushReferences(schemas = []) {
293
+ function AddReferences(schemas = []) {
302
294
  for (const schema of schemas) {
303
295
  if (!schema.$id)
304
296
  throw new Error(`TypeCompiler: Referenced schemas must specify an $id.`);
@@ -307,33 +299,36 @@ var TypeCompiler;
307
299
  referenceMap.set(schema.$id, schema);
308
300
  }
309
301
  }
310
- function PushLocal(code) {
311
- const name = `local${functionLocals.size}`;
312
- functionLocals.add(code.replace('local', name));
313
- return name;
314
- }
315
- function GetLocals() {
316
- return [...functionLocals.values()];
302
+ function CreateExpression(schema, value) {
303
+ return [...Visit(schema, value)].join(' && ');
317
304
  }
318
- // -------------------------------------------------------------------
319
- // Functions
320
- // -------------------------------------------------------------------
321
305
  function CreateFunctionName($id) {
322
306
  return `check_${$id.replace(/-/g, '_')}`;
323
307
  }
324
- function CreateFunction(name, conditions) {
325
- const expression = conditions.map((condition) => ` ${condition}`).join(' &&\n');
308
+ function CreateFunction(name, schema, value) {
309
+ const expression = [...Visit(schema, value)].map((condition) => ` ${condition}`).join(' &&\n');
326
310
  return `function ${name}(value) {\n return (\n${expression}\n )\n}`;
327
311
  }
312
+ function PushFunction(functionBody) {
313
+ locals.add(functionBody);
314
+ }
315
+ function PushLocal(expression) {
316
+ const local = `local_${locals.size}`;
317
+ locals.add(`const ${local} = ${expression}`);
318
+ return local;
319
+ }
320
+ function GetLocals() {
321
+ return [...locals.values()];
322
+ }
328
323
  // -------------------------------------------------------------------
329
324
  // Compile
330
325
  // -------------------------------------------------------------------
331
326
  function Build(schema, references = []) {
332
- ClearLocals();
333
- PushReferences(references);
334
- const conditions = [...Visit(schema, 'value')]; // locals populated during yield
327
+ ResetCompiler();
328
+ AddReferences(references);
329
+ const check = CreateFunction('check', schema, 'value');
335
330
  const locals = GetLocals();
336
- return `${locals.join('\n')}\nreturn ${CreateFunction('check', conditions)}`;
331
+ return `${locals.join('\n')}\nreturn ${check}`;
337
332
  }
338
333
  /** Compiles the given type for runtime type checking. This compiler only accepts known TypeBox types non-inclusive of unsafe types. */
339
334
  function Compile(schema, references = []) {
@@ -0,0 +1,4 @@
1
+ export declare namespace Property {
2
+ /** Tests if this property name can be used in a member expression */
3
+ function Check(propertyName: string): boolean;
4
+ }
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ /*--------------------------------------------------------------------------
3
+
4
+ @sinclair/typebox/compiler
5
+
6
+ The MIT License (MIT)
7
+
8
+ Copyright (c) 2022 Haydn Paterson (sinclair) <haydn.developer@gmail.com>
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in
18
+ all copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
26
+ THE SOFTWARE.
27
+
28
+ ---------------------------------------------------------------------------*/
29
+ Object.defineProperty(exports, "__esModule", { value: true });
30
+ exports.Property = void 0;
31
+ var Property;
32
+ (function (Property) {
33
+ function DollarSign(char) {
34
+ return char === 36;
35
+ }
36
+ function Underscore(char) {
37
+ return char === 95;
38
+ }
39
+ function Numeric(char) {
40
+ return char >= 48 && char <= 57;
41
+ }
42
+ function Alpha(char) {
43
+ return (char >= 65 && char <= 90) || (char >= 97 && char <= 122);
44
+ }
45
+ /** Tests if this property name can be used in a member expression */
46
+ function Check(propertyName) {
47
+ if (propertyName.length === 0)
48
+ return false;
49
+ {
50
+ const code = propertyName.charCodeAt(0);
51
+ if (!(DollarSign(code) || Underscore(code) || Alpha(code))) {
52
+ return false;
53
+ }
54
+ }
55
+ for (let i = 1; i < propertyName.length; i++) {
56
+ const code = propertyName.charCodeAt(i);
57
+ if (!(DollarSign(code) || Underscore(code) || Alpha(code) || Numeric(code))) {
58
+ return false;
59
+ }
60
+ }
61
+ return true;
62
+ }
63
+ Property.Check = Check;
64
+ })(Property = exports.Property || (exports.Property = {}));
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@sinclair/typebox",
3
- "version": "0.24.19",
3
+ "version": "0.24.22",
4
4
  "description": "JSONSchema Type Builder with Static Type Resolution for TypeScript",
5
5
  "keywords": [
6
- "json-schema",
7
6
  "typescript",
8
- "static-types",
9
- "runtime-typechecking"
7
+ "json-schema",
8
+ "validate",
9
+ "typecheck"
10
10
  ],
11
11
  "author": "sinclairzx81",
12
12
  "license": "MIT",
package/readme.md CHANGED
@@ -114,9 +114,9 @@ const T = Type.Object({ // const T = {
114
114
  // }
115
115
  // },
116
116
  // required: [
117
- // "id",
118
- // "name",
119
- // "timestamp"
117
+ // 'id',
118
+ // 'name',
119
+ // 'timestamp'
120
120
  // ]
121
121
  // }
122
122
 
@@ -528,7 +528,7 @@ function test(node: Node) {
528
528
 
529
529
  ## Generic Types
530
530
 
531
- Generic types can be created using functions. The following creates a generic `Nullable<T>` type.
531
+ Use functions to create generic types. The following creates a generic `Nullable<T>` type.
532
532
 
533
533
  ```typescript
534
534
  import { Type, Static, TSchema } from '@sinclair/typebox'
@@ -594,12 +594,12 @@ type T = Static<typeof T> // type T = string | null
594
594
 
595
595
  //--------------------------------------------------------------------------------------------
596
596
  //
597
- // StringUnion<[...]>
597
+ // StringEnum<string[]>
598
598
  //
599
599
  //--------------------------------------------------------------------------------------------
600
600
 
601
601
  function StringEnum<T extends string[]>(values: [...T]) {
602
- return Type.Unsafe<T[number]>({ enum: values })
602
+ return Type.Unsafe<T[number]>({ type: 'string', enum: values })
603
603
  }
604
604
 
605
605
  const T = StringEnum(['A', 'B', 'C']) // const T = {
@@ -876,7 +876,7 @@ console.log(C.Code()) // return function check(va
876
876
 
877
877
  ## Benchmark
878
878
 
879
- This project maintains benchmarks that measure Ajv and TypeCompiler validation and compilation performance. These benchmarks can be run locally by cloning this repository and running `npm run benchmark`. Results show against Ajv version 8.11.0.
879
+ This project maintains benchmarks that measure Ajv and TypeCompiler validate and compile performance. These benchmarks can be run locally by cloning this repository and running `npm run benchmark`. Results show against Ajv version 8.11.0.
880
880
 
881
881
  ### Validate
882
882
 
@@ -886,31 +886,31 @@ This benchmark measures validation performance for varying types. You can review
886
886
  ┌──────────────────┬────────────┬──────────────┬──────────────┬──────────────┐
887
887
  │ (index) │ Iterations │ Ajv │ TypeCompiler │ Performance │
888
888
  ├──────────────────┼────────────┼──────────────┼──────────────┼──────────────┤
889
- │ Number │ 16000000 │ ' 73 ms' │ ' 65 ms' │ ' 1.12 x' │
890
- │ String │ 16000000 │ ' 281 ms' │ ' 161 ms' │ ' 1.75 x' │
891
- │ Boolean │ 16000000 │ ' 302 ms' │ ' 151 ms' │ ' 2.00 x' │
892
- │ Null │ 16000000 │ ' 281 ms' │ ' 149 ms' │ ' 1.89 x' │
893
- │ RegEx │ 16000000 │ ' 689 ms' │ ' 550 ms' │ ' 1.25 x' │
894
- │ ObjectA │ 16000000 │ ' 470 ms' │ ' 311 ms' │ ' 1.51 x' │
895
- │ ObjectB │ 16000000 │ ' 667 ms' │ ' 556 ms' │ ' 1.20 x' │
896
- │ Tuple │ 16000000 │ ' 362 ms' │ ' 190 ms' │ ' 1.91 x' │
897
- │ Union │ 16000000 │ ' 387 ms' │ ' 209 ms' │ ' 1.85 x' │
898
- │ Recursive │ 16000000 │ ' 6327 ms' │ ' 2773 ms' │ ' 2.28 x' │
899
- │ Vector4 │ 16000000 │ ' 362 ms' │ ' 172 ms' │ ' 2.10 x' │
900
- │ Matrix4 │ 16000000 │ ' 607 ms' │ ' 418 ms' │ ' 1.45 x' │
901
- │ Literal_String │ 16000000 │ ' 314 ms' │ ' 151 ms' │ ' 2.08 x' │
902
- │ Literal_Number │ 16000000 │ ' 281 ms' │ ' 147 ms' │ ' 1.91 x' │
903
- │ Literal_Boolean │ 16000000 │ ' 289 ms' │ ' 148 ms' │ ' 1.95 x' │
904
- │ Array_Number │ 16000000 │ ' 475 ms' │ ' 230 ms' │ ' 2.07 x' │
905
- │ Array_String │ 16000000 │ ' 463 ms' │ ' 297 ms' │ ' 1.56 x' │
906
- │ Array_Boolean │ 16000000 │ ' 521 ms' │ ' 348 ms' │ ' 1.50 x' │
907
- │ Array_ObjectA │ 16000000 │ ' 43842 ms' │ ' 28375 ms' │ ' 1.55 x' │
908
- │ Array_ObjectB │ 16000000 │ ' 45055 ms' │ ' 32882 ms' │ ' 1.37 x' │
909
- │ Array_Tuple │ 16000000 │ ' 1424 ms' │ ' 1105 ms' │ ' 1.29 x' │
910
- │ Array_Union │ 16000000 │ ' 3505 ms' │ ' 1350 ms' │ ' 2.60 x' │
911
- │ Array_Recursive │ 16000000 │ ' 117087 ms' │ ' 42982 ms' │ ' 2.72 x' │
912
- │ Array_Vector4 │ 16000000 │ ' 1500 ms' │ ' 817 ms' │ ' 1.84 x' │
913
- │ Array_Matrix4 │ 16000000 │ ' 6126 ms' │ ' 4965 ms' │ ' 1.23 x' │
889
+ │ Number │ 4000000 │ ' 17 ms' │ ' 16 ms' │ ' 1.06 x' │
890
+ │ String │ 4000000 │ ' 74 ms' │ ' 37 ms' │ ' 2.00 x' │
891
+ │ Boolean │ 4000000 │ ' 68 ms' │ ' 36 ms' │ ' 1.89 x' │
892
+ │ Null │ 4000000 │ ' 68 ms' │ ' 36 ms' │ ' 1.89 x' │
893
+ │ RegEx │ 4000000 │ ' 170 ms' │ ' 143 ms' │ ' 1.19 x' │
894
+ │ ObjectA │ 4000000 │ ' 122 ms' │ ' 84 ms' │ ' 1.45 x' │
895
+ │ ObjectB │ 4000000 │ ' 182 ms' │ ' 137 ms' │ ' 1.33 x' │
896
+ │ Tuple │ 4000000 │ ' 82 ms' │ ' 48 ms' │ ' 1.71 x' │
897
+ │ Union │ 4000000 │ ' 84 ms' │ ' 52 ms' │ ' 1.62 x' │
898
+ │ Recursive │ 4000000 │ ' 1526 ms' │ ' 631 ms' │ ' 2.42 x' │
899
+ │ Vector4 │ 4000000 │ ' 80 ms' │ ' 42 ms' │ ' 1.90 x' │
900
+ │ Matrix4 │ 4000000 │ ' 157 ms' │ ' 113 ms' │ ' 1.39 x' │
901
+ │ Literal_String │ 4000000 │ ' 69 ms' │ ' 36 ms' │ ' 1.92 x' │
902
+ │ Literal_Number │ 4000000 │ ' 69 ms' │ ' 35 ms' │ ' 1.97 x' │
903
+ │ Literal_Boolean │ 4000000 │ ' 68 ms' │ ' 35 ms' │ ' 1.94 x' │
904
+ │ Array_Number │ 4000000 │ ' 119 ms' │ ' 60 ms' │ ' 1.98 x' │
905
+ │ Array_String │ 4000000 │ ' 119 ms' │ ' 76 ms' │ ' 1.57 x' │
906
+ │ Array_Boolean │ 4000000 │ ' 131 ms' │ ' 88 ms' │ ' 1.49 x' │
907
+ │ Array_ObjectA │ 4000000 │ ' 10615 ms' │ ' 7053 ms' │ ' 1.51 x' │
908
+ │ Array_ObjectB │ 4000000 │ ' 11305 ms' │ ' 8128 ms' │ ' 1.39 x' │
909
+ │ Array_Tuple │ 4000000 │ ' 355 ms' │ ' 271 ms' │ ' 1.31 x' │
910
+ │ Array_Union │ 4000000 │ ' 910 ms' │ ' 340 ms' │ ' 2.68 x' │
911
+ │ Array_Recursive │ 4000000 │ ' 29101 ms' │ ' 10837 ms' │ ' 2.69 x' │
912
+ │ Array_Vector4 │ 4000000 │ ' 381 ms' │ ' 212 ms' │ ' 1.80 x' │
913
+ │ Array_Matrix4 │ 4000000 │ ' 1534 ms' │ ' 1344 ms' │ ' 1.14 x' │
914
914
  └──────────────────┴────────────┴──────────────┴──────────────┴──────────────┘
915
915
  ```
916
916
 
@@ -922,29 +922,29 @@ This benchmark measures compilation performance for varying types. You can revie
922
922
  ┌──────────────────┬────────────┬──────────────┬──────────────┬──────────────┐
923
923
  │ (index) │ Iterations │ Ajv │ TypeCompiler │ Performance │
924
924
  ├──────────────────┼────────────┼──────────────┼──────────────┼──────────────┤
925
- │ Number │ 2000 │ ' 387 ms' │ ' 7 ms' │ ' 55.29 x' │
926
- │ String │ 2000 │ ' 340 ms' │ ' 6 ms' │ ' 56.67 x' │
927
- │ Boolean │ 2000 │ ' 314 ms' │ ' 5 ms' │ ' 62.80 x' │
928
- │ Null │ 2000 │ ' 259 ms' │ ' 5 ms' │ ' 51.80 x' │
929
- │ RegEx │ 2000 │ ' 491 ms' │ ' 7 ms' │ ' 70.14 x' │
930
- │ ObjectA │ 2000 │ ' 2850 ms' │ ' 26 ms' │ ' 109.62 x' │
931
- │ ObjectB │ 2000 │ ' 2989 ms' │ ' 22 ms' │ ' 135.86 x' │
932
- │ Tuple │ 2000 │ ' 1283 ms' │ ' 17 ms' │ ' 75.47 x' │
933
- │ Union │ 2000 │ ' 1292 ms' │ ' 16 ms' │ ' 80.75 x' │
934
- │ Vector4 │ 2000 │ ' 1588 ms' │ ' 12 ms' │ ' 132.33 x' │
935
- │ Matrix4 │ 2000 │ ' 934 ms' │ ' 7 ms' │ ' 133.43 x' │
936
- │ Literal_String │ 2000 │ ' 340 ms' │ ' 5 ms' │ ' 68.00 x' │
937
- │ Literal_Number │ 2000 │ ' 402 ms' │ ' 4 ms' │ ' 100.50 x' │
938
- │ Literal_Boolean │ 2000 │ ' 381 ms' │ ' 6 ms' │ ' 63.50 x' │
939
- │ Array_Number │ 2000 │ ' 750 ms' │ ' 8 ms' │ ' 93.75 x' │
940
- │ Array_String │ 2000 │ ' 760 ms' │ ' 6 ms' │ ' 126.67 x' │
941
- │ Array_Boolean │ 2000 │ ' 796 ms' │ ' 7 ms' │ ' 113.71 x' │
942
- │ Array_ObjectA │ 2000 │ ' 3617 ms' │ ' 26 ms' │ ' 139.12 x' │
943
- │ Array_ObjectB │ 2000 │ ' 3823 ms' │ ' 26 ms' │ ' 147.04 x' │
944
- │ Array_Tuple │ 2000 │ ' 2263 ms' │ ' 13 ms' │ ' 174.08 x' │
945
- │ Array_Union │ 2000 │ ' 1725 ms' │ ' 16 ms' │ ' 107.81 x' │
946
- │ Array_Vector4 │ 2000 │ ' 2445 ms' │ ' 14 ms' │ ' 174.64 x' │
947
- │ Array_Matrix4 │ 2000 │ ' 1638 ms' │ ' 11 ms' │ ' 148.91 x' │
925
+ │ Number │ 2000 │ ' 384 ms' │ ' 7 ms' │ ' 54.86 x' │
926
+ │ String │ 2000 │ ' 311 ms' │ ' 6 ms' │ ' 51.83 x' │
927
+ │ Boolean │ 2000 │ ' 304 ms' │ ' 5 ms' │ ' 60.80 x' │
928
+ │ Null │ 2000 │ ' 252 ms' │ ' 5 ms' │ ' 50.40 x' │
929
+ │ RegEx │ 2000 │ ' 480 ms' │ ' 7 ms' │ ' 68.57 x' │
930
+ │ ObjectA │ 2000 │ ' 2786 ms' │ ' 27 ms' │ ' 103.19 x' │
931
+ │ ObjectB │ 2000 │ ' 2946 ms' │ ' 22 ms' │ ' 133.91 x' │
932
+ │ Tuple │ 2000 │ ' 1277 ms' │ ' 16 ms' │ ' 79.81 x' │
933
+ │ Union │ 2000 │ ' 1288 ms' │ ' 16 ms' │ ' 80.50 x' │
934
+ │ Vector4 │ 2000 │ ' 1628 ms' │ ' 12 ms' │ ' 135.67 x' │
935
+ │ Matrix4 │ 2000 │ ' 912 ms' │ ' 7 ms' │ ' 130.29 x' │
936
+ │ Literal_String │ 2000 │ ' 344 ms' │ ' 5 ms' │ ' 68.80 x' │
937
+ │ Literal_Number │ 2000 │ ' 432 ms' │ ' 5 ms' │ ' 86.40 x' │
938
+ │ Literal_Boolean │ 2000 │ ' 407 ms' │ ' 4 ms' │ ' 101.75 x' │
939
+ │ Array_Number │ 2000 │ ' 788 ms' │ ' 9 ms' │ ' 87.56 x' │
940
+ │ Array_String │ 2000 │ ' 823 ms' │ ' 7 ms' │ ' 117.57 x' │
941
+ │ Array_Boolean │ 2000 │ ' 816 ms' │ ' 5 ms' │ ' 163.20 x' │
942
+ │ Array_ObjectA │ 2000 │ ' 4270 ms' │ ' 24 ms' │ ' 177.92 x' │
943
+ │ Array_ObjectB │ 2000 │ ' 4008 ms' │ ' 28 ms' │ ' 143.14 x' │
944
+ │ Array_Tuple │ 2000 │ ' 2243 ms' │ ' 13 ms' │ ' 172.54 x' │
945
+ │ Array_Union │ 2000 │ ' 1734 ms' │ ' 16 ms' │ ' 108.38 x' │
946
+ │ Array_Vector4 │ 2000 │ ' 2348 ms' │ ' 14 ms' │ ' 167.71 x' │
947
+ │ Array_Matrix4 │ 2000 │ ' 1608 ms' │ ' 11 ms' │ ' 146.18 x' │
948
948
  └──────────────────┴────────────┴──────────────┴──────────────┴──────────────┘
949
949
  ```
950
950
 
package/value/check.js CHANGED
@@ -201,7 +201,7 @@ var ValueCheck;
201
201
  return true;
202
202
  }
203
203
  function Tuple(schema, references, value) {
204
- if (!global.Array.isArray(value)) {
204
+ if (!globalThis.Array.isArray(value)) {
205
205
  return false;
206
206
  }
207
207
  if (schema.items === undefined && !(value.length === 0)) {
package/value/errors.js CHANGED
@@ -195,7 +195,7 @@ var ValueErrors;
195
195
  }
196
196
  }
197
197
  function* Tuple(schema, references, path, value) {
198
- if (!global.Array.isArray(value)) {
198
+ if (!globalThis.Array.isArray(value)) {
199
199
  return yield { schema, path, value, message: 'Expected Array' };
200
200
  }
201
201
  if (schema.items === undefined && !(value.length === 0)) {