@sinclair/typebox 0.32.0-dev-26 → 0.32.0-dev-28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/import/compiler/compiler.mjs +7 -0
- package/build/import/errors/errors.d.mts +16 -15
- package/build/import/errors/errors.mjs +24 -15
- package/build/import/errors/function.mjs +2 -0
- package/build/import/index.d.mts +2 -2
- package/build/import/type/awaited/awaited.mjs +2 -6
- package/build/import/type/clone/value.mjs +6 -2
- package/build/import/type/composite/composite.d.mts +1 -2
- package/build/import/type/composite/composite.mjs +2 -2
- package/build/import/type/const/const.mjs +6 -6
- package/build/import/type/constructor/constructor.d.mts +1 -1
- package/build/import/type/constructor/constructor.mjs +1 -1
- package/build/import/type/deref/deref.mjs +1 -2
- package/build/import/type/discard/discard.mjs +2 -2
- package/build/import/type/enum/enum.mjs +3 -0
- package/build/import/type/exclude/exclude-from-mapped-result.d.mts +5 -5
- package/build/import/type/exclude/exclude-from-mapped-result.mjs +7 -7
- package/build/import/type/exclude/exclude.mjs +0 -1
- package/build/import/type/extends/extends-check.mjs +137 -125
- package/build/import/type/extends/extends-from-mapped-key.d.mts +1 -1
- package/build/import/type/extends/extends-from-mapped-key.mjs +4 -5
- package/build/import/type/extends/extends-from-mapped-result.d.mts +5 -5
- package/build/import/type/extends/extends-from-mapped-result.mjs +7 -7
- package/build/import/type/extends/extends.mjs +0 -1
- package/build/import/type/extract/extract-from-mapped-result.d.mts +5 -5
- package/build/import/type/extract/extract-from-mapped-result.mjs +7 -7
- package/build/import/type/extract/extract.d.mts +1 -2
- package/build/import/type/extract/extract.mjs +4 -2
- package/build/import/type/guard/type.d.mts +3 -0
- package/build/import/type/guard/type.mjs +10 -0
- package/build/import/type/guard/value.d.mts +2 -0
- package/build/import/type/guard/value.mjs +4 -0
- package/build/import/type/index.d.mts +1 -1
- package/build/import/type/index.mjs +1 -1
- package/build/import/type/indexed/indexed-from-mapped-key.d.mts +2 -2
- package/build/import/type/indexed/indexed-from-mapped-key.mjs +4 -5
- package/build/import/type/indexed/indexed-from-mapped-result.d.mts +1 -1
- package/build/import/type/indexed/indexed-property-keys.d.mts +6 -6
- package/build/import/type/indexed/indexed-property-keys.mjs +3 -5
- package/build/import/type/indexed/indexed.d.mts +1 -1
- package/build/import/type/indexed/indexed.mjs +9 -27
- package/build/import/type/intersect/intersect-evaluated.mjs +3 -13
- package/build/import/type/intrinsic/capitalize.d.mts +2 -2
- package/build/import/type/intrinsic/intrinsic-from-mapped-key.d.mts +1 -1
- package/build/import/type/intrinsic/intrinsic-from-mapped-key.mjs +4 -5
- package/build/import/type/intrinsic/intrinsic.d.mts +2 -3
- package/build/import/type/intrinsic/intrinsic.mjs +2 -5
- package/build/import/type/intrinsic/lowercase.d.mts +2 -2
- package/build/import/type/intrinsic/uncapitalize.d.mts +2 -2
- package/build/import/type/intrinsic/uppercase.d.mts +2 -2
- package/build/import/type/iterator/iterator.mjs +1 -1
- package/build/import/type/keyof/keyof-from-mapped-result.d.mts +3 -3
- package/build/import/type/keyof/keyof-from-mapped-result.mjs +4 -4
- package/build/import/type/keyof/keyof-property-keys.d.mts +3 -3
- package/build/import/type/keyof/keyof-property-keys.mjs +9 -15
- package/build/import/type/keyof/keyof.mjs +2 -8
- package/build/import/type/mapped/mapped.d.mts +6 -1
- package/build/import/type/mapped/mapped.mjs +21 -14
- package/build/import/type/not/not.mjs +1 -1
- package/build/import/type/object/object.d.mts +1 -1
- package/build/import/type/object/object.mjs +0 -1
- package/build/import/type/omit/index.d.mts +1 -0
- package/build/import/type/omit/index.mjs +1 -0
- package/build/import/type/omit/omit-from-mapped-key.mjs +4 -5
- package/build/import/type/omit/omit-from-mapped-result.d.mts +11 -0
- package/build/import/type/omit/omit-from-mapped-result.mjs +17 -0
- package/build/import/type/omit/omit.d.mts +6 -3
- package/build/import/type/omit/omit.mjs +11 -9
- package/build/import/type/optional/optional-from-mapped-result.d.mts +5 -5
- package/build/import/type/optional/optional-from-mapped-result.mjs +7 -7
- package/build/import/type/partial/partial-from-mapped-result.d.mts +5 -5
- package/build/import/type/partial/partial-from-mapped-result.mjs +4 -4
- package/build/import/type/partial/partial.d.mts +2 -3
- package/build/import/type/partial/partial.mjs +8 -21
- package/build/import/type/pick/index.d.mts +1 -0
- package/build/import/type/pick/index.mjs +1 -0
- package/build/import/type/pick/pick-from-mapped-key.mjs +4 -5
- package/build/import/type/pick/pick-from-mapped-result.d.mts +11 -0
- package/build/import/type/pick/pick-from-mapped-result.mjs +17 -0
- package/build/import/type/pick/pick.d.mts +5 -2
- package/build/import/type/pick/pick.mjs +11 -10
- package/build/import/type/promise/promise.mjs +1 -1
- package/build/import/type/readonly/readonly-from-mapped-result.d.mts +5 -5
- package/build/import/type/readonly/readonly-from-mapped-result.mjs +4 -4
- package/build/import/type/record/record.d.mts +5 -3
- package/build/import/type/record/record.mjs +13 -5
- package/build/import/type/ref/ref.mjs +1 -1
- package/build/import/type/regexp/regexp.d.mts +11 -4
- package/build/import/type/regexp/regexp.mjs +3 -3
- package/build/import/type/required/required-from-mapped-result.d.mts +5 -5
- package/build/import/type/required/required-from-mapped-result.mjs +7 -7
- package/build/import/type/required/required.d.mts +2 -3
- package/build/import/type/required/required.mjs +4 -14
- package/build/import/type/rest/rest.d.mts +2 -2
- package/build/import/type/rest/rest.mjs +1 -2
- package/build/import/type/schema/anyschema.d.mts +2 -1
- package/build/import/type/sets/index.d.mts +1 -0
- package/build/import/type/sets/index.mjs +1 -0
- package/build/import/type/sets/set.d.mts +24 -0
- package/build/import/type/sets/set.mjs +35 -0
- package/build/import/type/strict/strict.d.mts +1 -1
- package/build/import/type/strict/strict.mjs +1 -1
- package/build/import/type/template-literal/syntax.d.mts +1 -1
- package/build/import/type/template-literal/template-literal.d.mts +1 -1
- package/build/import/type/transform/transform.mjs +1 -1
- package/build/import/type/type/javascript.d.mts +2 -2
- package/build/import/type/type/javascript.mjs +1 -1
- package/build/import/type/type/json.d.mts +6 -2
- package/build/import/type/union/union-evaluated.mjs +3 -14
- package/build/import/value/cast/cast.d.mts +2 -15
- package/build/import/value/cast/cast.mjs +5 -28
- package/build/import/value/check/check.mjs +6 -1
- package/build/import/value/convert/convert.d.mts +0 -5
- package/build/import/value/convert/convert.mjs +0 -12
- package/build/import/value/create/create.d.mts +2 -23
- package/build/import/value/create/create.mjs +30 -53
- package/build/import/value/default/default.mjs +0 -2
- package/build/import/value/delta/delta.d.mts +4 -4
- package/build/import/value/delta/delta.mjs +12 -12
- package/build/import/value/index.d.mts +7 -7
- package/build/import/value/index.mjs +6 -6
- package/build/import/value/mutate/mutate.d.mts +2 -5
- package/build/import/value/mutate/mutate.mjs +5 -10
- package/build/require/compiler/compiler.js +7 -0
- package/build/require/errors/errors.d.ts +16 -15
- package/build/require/errors/errors.js +24 -15
- package/build/require/errors/function.js +2 -0
- package/build/require/index.d.ts +2 -2
- package/build/require/type/awaited/awaited.js +2 -6
- package/build/require/type/clone/value.js +6 -2
- package/build/require/type/composite/composite.d.ts +1 -2
- package/build/require/type/composite/composite.js +5 -6
- package/build/require/type/const/const.js +6 -6
- package/build/require/type/constructor/constructor.d.ts +1 -1
- package/build/require/type/constructor/constructor.js +1 -1
- package/build/require/type/deref/deref.js +0 -1
- package/build/require/type/discard/discard.js +2 -2
- package/build/require/type/enum/enum.js +3 -0
- package/build/require/type/exclude/exclude-from-mapped-result.d.ts +5 -5
- package/build/require/type/exclude/exclude-from-mapped-result.js +7 -7
- package/build/require/type/exclude/exclude.js +0 -1
- package/build/require/type/extends/extends-check.js +137 -125
- package/build/require/type/extends/extends-from-mapped-key.d.ts +1 -1
- package/build/require/type/extends/extends-from-mapped-key.js +4 -5
- package/build/require/type/extends/extends-from-mapped-result.d.ts +5 -5
- package/build/require/type/extends/extends-from-mapped-result.js +7 -7
- package/build/require/type/extends/extends.js +0 -1
- package/build/require/type/extract/extract-from-mapped-result.d.ts +5 -5
- package/build/require/type/extract/extract-from-mapped-result.js +7 -7
- package/build/require/type/extract/extract.d.ts +1 -2
- package/build/require/type/extract/extract.js +4 -3
- package/build/require/type/guard/type.d.ts +3 -0
- package/build/require/type/guard/type.js +12 -1
- package/build/require/type/guard/value.d.ts +2 -0
- package/build/require/type/guard/value.js +6 -1
- package/build/require/type/index.d.ts +1 -1
- package/build/require/type/index.js +1 -1
- package/build/require/type/indexed/indexed-from-mapped-key.d.ts +2 -2
- package/build/require/type/indexed/indexed-from-mapped-key.js +4 -5
- package/build/require/type/indexed/indexed-from-mapped-result.d.ts +1 -1
- package/build/require/type/indexed/indexed-property-keys.d.ts +6 -6
- package/build/require/type/indexed/indexed-property-keys.js +3 -5
- package/build/require/type/indexed/indexed.d.ts +1 -1
- package/build/require/type/indexed/indexed.js +9 -27
- package/build/require/type/intersect/intersect-evaluated.js +3 -13
- package/build/require/type/intrinsic/capitalize.d.ts +2 -2
- package/build/require/type/intrinsic/intrinsic-from-mapped-key.d.ts +1 -1
- package/build/require/type/intrinsic/intrinsic-from-mapped-key.js +4 -5
- package/build/require/type/intrinsic/intrinsic.d.ts +2 -3
- package/build/require/type/intrinsic/intrinsic.js +2 -5
- package/build/require/type/intrinsic/lowercase.d.ts +2 -2
- package/build/require/type/intrinsic/uncapitalize.d.ts +2 -2
- package/build/require/type/intrinsic/uppercase.d.ts +2 -2
- package/build/require/type/iterator/iterator.js +1 -1
- package/build/require/type/keyof/keyof-from-mapped-result.d.ts +3 -3
- package/build/require/type/keyof/keyof-from-mapped-result.js +4 -4
- package/build/require/type/keyof/keyof-property-keys.d.ts +3 -3
- package/build/require/type/keyof/keyof-property-keys.js +9 -15
- package/build/require/type/keyof/keyof.js +2 -8
- package/build/require/type/mapped/mapped.d.ts +6 -1
- package/build/require/type/mapped/mapped.js +21 -14
- package/build/require/type/not/not.js +1 -1
- package/build/require/type/object/object.d.ts +1 -1
- package/build/require/type/object/object.js +0 -1
- package/build/require/type/omit/index.d.ts +1 -0
- package/build/require/type/omit/index.js +1 -0
- package/build/require/type/omit/omit-from-mapped-key.js +4 -5
- package/build/require/type/omit/omit-from-mapped-result.d.ts +11 -0
- package/build/require/type/omit/omit-from-mapped-result.js +22 -0
- package/build/require/type/omit/omit.d.ts +6 -3
- package/build/require/type/omit/omit.js +10 -8
- package/build/require/type/optional/optional-from-mapped-result.d.ts +5 -5
- package/build/require/type/optional/optional-from-mapped-result.js +7 -7
- package/build/require/type/partial/partial-from-mapped-result.d.ts +5 -5
- package/build/require/type/partial/partial-from-mapped-result.js +4 -4
- package/build/require/type/partial/partial.d.ts +2 -3
- package/build/require/type/partial/partial.js +8 -21
- package/build/require/type/pick/index.d.ts +1 -0
- package/build/require/type/pick/index.js +1 -0
- package/build/require/type/pick/pick-from-mapped-key.js +4 -5
- package/build/require/type/pick/pick-from-mapped-result.d.ts +11 -0
- package/build/require/type/pick/pick-from-mapped-result.js +22 -0
- package/build/require/type/pick/pick.d.ts +5 -2
- package/build/require/type/pick/pick.js +10 -9
- package/build/require/type/promise/promise.js +1 -1
- package/build/require/type/readonly/readonly-from-mapped-result.d.ts +5 -5
- package/build/require/type/readonly/readonly-from-mapped-result.js +4 -4
- package/build/require/type/record/record.d.ts +5 -3
- package/build/require/type/record/record.js +12 -4
- package/build/require/type/ref/ref.js +1 -1
- package/build/require/type/regexp/regexp.d.ts +11 -4
- package/build/require/type/regexp/regexp.js +3 -3
- package/build/require/type/required/required-from-mapped-result.d.ts +5 -5
- package/build/require/type/required/required-from-mapped-result.js +7 -7
- package/build/require/type/required/required.d.ts +2 -3
- package/build/require/type/required/required.js +4 -14
- package/build/require/type/rest/rest.d.ts +2 -2
- package/build/require/type/rest/rest.js +1 -3
- package/build/require/type/schema/anyschema.d.ts +2 -1
- package/build/require/type/sets/index.d.ts +1 -0
- package/build/require/type/{operators → sets}/index.js +1 -1
- package/build/require/type/sets/set.d.ts +24 -0
- package/build/require/type/sets/set.js +47 -0
- package/build/require/type/strict/strict.d.ts +1 -1
- package/build/require/type/strict/strict.js +1 -1
- package/build/require/type/template-literal/parse.js +1 -1
- package/build/require/type/template-literal/syntax.d.ts +1 -1
- package/build/require/type/template-literal/template-literal.d.ts +1 -1
- package/build/require/type/transform/transform.js +1 -1
- package/build/require/type/type/javascript.d.ts +2 -2
- package/build/require/type/type/javascript.js +1 -1
- package/build/require/type/type/json.d.ts +6 -2
- package/build/require/type/union/union-evaluated.js +3 -14
- package/build/require/value/cast/cast.d.ts +2 -15
- package/build/require/value/cast/cast.js +7 -29
- package/build/require/value/check/check.js +6 -1
- package/build/require/value/convert/convert.d.ts +0 -5
- package/build/require/value/convert/convert.js +31 -43
- package/build/require/value/create/create.d.ts +2 -23
- package/build/require/value/create/create.js +32 -54
- package/build/require/value/default/default.js +0 -2
- package/build/require/value/delta/delta.d.ts +4 -4
- package/build/require/value/delta/delta.js +14 -14
- package/build/require/value/index.d.ts +7 -7
- package/build/require/value/index.js +8 -19
- package/build/require/value/mutate/mutate.d.ts +2 -5
- package/build/require/value/mutate/mutate.js +7 -13
- package/package.json +1 -1
- package/readme.md +68 -67
- package/build/import/type/operators/index.d.mts +0 -1
- package/build/import/type/operators/index.mjs +0 -1
- package/build/import/type/operators/operators.d.mts +0 -24
- package/build/import/type/operators/operators.mjs +0 -77
- package/build/require/type/operators/index.d.ts +0 -1
- package/build/require/type/operators/operators.d.ts +0 -24
- package/build/require/type/operators/operators.js +0 -89
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.Mutate = exports.
|
|
4
|
+
exports.Mutate = exports.ValueMutateError = void 0;
|
|
5
5
|
const index_1 = require("../guard/index");
|
|
6
6
|
const index_2 = require("../pointer/index");
|
|
7
7
|
const index_3 = require("../clone/index");
|
|
@@ -9,18 +9,12 @@ const index_4 = require("../../type/error/index");
|
|
|
9
9
|
// ------------------------------------------------------------------
|
|
10
10
|
// Errors
|
|
11
11
|
// ------------------------------------------------------------------
|
|
12
|
-
class
|
|
13
|
-
constructor() {
|
|
14
|
-
super(
|
|
12
|
+
class ValueMutateError extends index_4.TypeBoxError {
|
|
13
|
+
constructor(message) {
|
|
14
|
+
super(message);
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
|
-
exports.
|
|
18
|
-
class ValueMutateInvalidRootMutationError extends index_4.TypeBoxError {
|
|
19
|
-
constructor() {
|
|
20
|
-
super('Only object and array types can be mutated at the root level');
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
exports.ValueMutateInvalidRootMutationError = ValueMutateInvalidRootMutationError;
|
|
17
|
+
exports.ValueMutateError = ValueMutateError;
|
|
24
18
|
function ObjectType(root, path, current, next) {
|
|
25
19
|
if (!(0, index_1.IsPlainObject)(current)) {
|
|
26
20
|
index_2.ValuePointer.Set(root, path, (0, index_3.Clone)(next));
|
|
@@ -96,9 +90,9 @@ function IsMismatchedValue(current, next) {
|
|
|
96
90
|
/** `[Mutable]` Performs a deep mutable value assignment while retaining internal references */
|
|
97
91
|
function Mutate(current, next) {
|
|
98
92
|
if (IsNonMutableValue(current) || IsNonMutableValue(next))
|
|
99
|
-
throw new
|
|
93
|
+
throw new ValueMutateError('Only object and array types can be mutated at the root level');
|
|
100
94
|
if (IsMismatchedValue(current, next))
|
|
101
|
-
throw new
|
|
95
|
+
throw new ValueMutateError('Cannot assign due type mismatch of assignable values');
|
|
102
96
|
Visit(current, '', current, next);
|
|
103
97
|
}
|
|
104
98
|
exports.Mutate = Mutate;
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -53,7 +53,7 @@ type T = Static<typeof T> // type T = {
|
|
|
53
53
|
|
|
54
54
|
TypeBox is a runtime type builder that creates in-memory Json Schema objects that infer as TypeScript types. The schematics produced by this library are designed to match the static type checking rules of the TypeScript compiler. TypeBox offers a unified type that can be statically checked by TypeScript and runtime asserted using standard Json Schema validation.
|
|
55
55
|
|
|
56
|
-
This library is
|
|
56
|
+
This library is built to be a runtime type system offering similar capabilities to TypeScript's static type system. It can be used as a simple tool to build up complex schematics or integrated into REST and RPC services to help validate data received over the wire.
|
|
57
57
|
|
|
58
58
|
License MIT
|
|
59
59
|
|
|
@@ -605,9 +605,10 @@ TypeBox provides an extended type set that can be used to create schematics for
|
|
|
605
605
|
│ │ │ } │
|
|
606
606
|
│ │ │ │
|
|
607
607
|
├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
|
|
608
|
-
│ const T = Type.RegExp(/abc/)
|
|
609
|
-
│ │ │ type: '
|
|
610
|
-
│ │ │
|
|
608
|
+
│ const T = Type.RegExp(/abc/i) │ type T = string │ const T = { │
|
|
609
|
+
│ │ │ type: 'RegExp' │
|
|
610
|
+
│ │ │ source: 'abc' │
|
|
611
|
+
│ │ │ flags: 'i' │
|
|
611
612
|
│ │ │ } │
|
|
612
613
|
│ │ │ │
|
|
613
614
|
├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
|
|
@@ -1709,35 +1710,35 @@ This benchmark measures compilation performance for varying types.
|
|
|
1709
1710
|
┌────────────────────────────┬────────────┬──────────────┬──────────────┬──────────────┐
|
|
1710
1711
|
│ (index) │ Iterations │ Ajv │ TypeCompiler │ Performance │
|
|
1711
1712
|
├────────────────────────────┼────────────┼──────────────┼──────────────┼──────────────┤
|
|
1712
|
-
│ Literal_String │ 1000 │ '
|
|
1713
|
-
│ Literal_Number │ 1000 │ '
|
|
1714
|
-
│ Literal_Boolean │ 1000 │ ' 168 ms' │ '
|
|
1715
|
-
│ Primitive_Number │ 1000 │ '
|
|
1716
|
-
│ Primitive_String │ 1000 │ '
|
|
1717
|
-
│ Primitive_String_Pattern │ 1000 │ '
|
|
1718
|
-
│ Primitive_Boolean │ 1000 │ '
|
|
1719
|
-
│ Primitive_Null │ 1000 │ '
|
|
1720
|
-
│ Object_Unconstrained │ 1000 │ '
|
|
1721
|
-
│ Object_Constrained │ 1000 │ '
|
|
1722
|
-
│ Object_Vector3 │ 1000 │ '
|
|
1723
|
-
│ Object_Box3D │ 1000 │ '
|
|
1724
|
-
│ Tuple_Primitive │ 1000 │ '
|
|
1725
|
-
│ Tuple_Object │ 1000 │ '
|
|
1726
|
-
│ Composite_Intersect │ 1000 │ '
|
|
1727
|
-
│ Composite_Union │ 1000 │ '
|
|
1728
|
-
│ Math_Vector4 │ 1000 │ '
|
|
1729
|
-
│ Math_Matrix4 │ 1000 │ '
|
|
1730
|
-
│ Array_Primitive_Number │ 1000 │ '
|
|
1731
|
-
│ Array_Primitive_String │ 1000 │ '
|
|
1732
|
-
│ Array_Primitive_Boolean │ 1000 │ '
|
|
1733
|
-
│ Array_Object_Unconstrained │ 1000 │ '
|
|
1734
|
-
│ Array_Object_Constrained │ 1000 │ '
|
|
1735
|
-
│ Array_Tuple_Primitive │ 1000 │ '
|
|
1736
|
-
│ Array_Tuple_Object │ 1000 │ '
|
|
1737
|
-
│ Array_Composite_Intersect │ 1000 │ '
|
|
1738
|
-
│ Array_Composite_Union │ 1000 │ '
|
|
1739
|
-
│ Array_Math_Vector4 │ 1000 │ '
|
|
1740
|
-
│ Array_Math_Matrix4 │ 1000 │ '
|
|
1713
|
+
│ Literal_String │ 1000 │ ' 242 ms' │ ' 10 ms' │ ' 24.20 x' │
|
|
1714
|
+
│ Literal_Number │ 1000 │ ' 200 ms' │ ' 8 ms' │ ' 25.00 x' │
|
|
1715
|
+
│ Literal_Boolean │ 1000 │ ' 168 ms' │ ' 6 ms' │ ' 28.00 x' │
|
|
1716
|
+
│ Primitive_Number │ 1000 │ ' 165 ms' │ ' 8 ms' │ ' 20.63 x' │
|
|
1717
|
+
│ Primitive_String │ 1000 │ ' 154 ms' │ ' 6 ms' │ ' 25.67 x' │
|
|
1718
|
+
│ Primitive_String_Pattern │ 1000 │ ' 208 ms' │ ' 14 ms' │ ' 14.86 x' │
|
|
1719
|
+
│ Primitive_Boolean │ 1000 │ ' 142 ms' │ ' 6 ms' │ ' 23.67 x' │
|
|
1720
|
+
│ Primitive_Null │ 1000 │ ' 143 ms' │ ' 6 ms' │ ' 23.83 x' │
|
|
1721
|
+
│ Object_Unconstrained │ 1000 │ ' 1217 ms' │ ' 31 ms' │ ' 39.26 x' │
|
|
1722
|
+
│ Object_Constrained │ 1000 │ ' 1275 ms' │ ' 26 ms' │ ' 49.04 x' │
|
|
1723
|
+
│ Object_Vector3 │ 1000 │ ' 405 ms' │ ' 12 ms' │ ' 33.75 x' │
|
|
1724
|
+
│ Object_Box3D │ 1000 │ ' 1833 ms' │ ' 27 ms' │ ' 67.89 x' │
|
|
1725
|
+
│ Tuple_Primitive │ 1000 │ ' 475 ms' │ ' 13 ms' │ ' 36.54 x' │
|
|
1726
|
+
│ Tuple_Object │ 1000 │ ' 1267 ms' │ ' 30 ms' │ ' 42.23 x' │
|
|
1727
|
+
│ Composite_Intersect │ 1000 │ ' 604 ms' │ ' 18 ms' │ ' 33.56 x' │
|
|
1728
|
+
│ Composite_Union │ 1000 │ ' 545 ms' │ ' 20 ms' │ ' 27.25 x' │
|
|
1729
|
+
│ Math_Vector4 │ 1000 │ ' 829 ms' │ ' 12 ms' │ ' 69.08 x' │
|
|
1730
|
+
│ Math_Matrix4 │ 1000 │ ' 405 ms' │ ' 10 ms' │ ' 40.50 x' │
|
|
1731
|
+
│ Array_Primitive_Number │ 1000 │ ' 372 ms' │ ' 12 ms' │ ' 31.00 x' │
|
|
1732
|
+
│ Array_Primitive_String │ 1000 │ ' 327 ms' │ ' 5 ms' │ ' 65.40 x' │
|
|
1733
|
+
│ Array_Primitive_Boolean │ 1000 │ ' 300 ms' │ ' 4 ms' │ ' 75.00 x' │
|
|
1734
|
+
│ Array_Object_Unconstrained │ 1000 │ ' 1755 ms' │ ' 21 ms' │ ' 83.57 x' │
|
|
1735
|
+
│ Array_Object_Constrained │ 1000 │ ' 1516 ms' │ ' 20 ms' │ ' 75.80 x' │
|
|
1736
|
+
│ Array_Tuple_Primitive │ 1000 │ ' 825 ms' │ ' 14 ms' │ ' 58.93 x' │
|
|
1737
|
+
│ Array_Tuple_Object │ 1000 │ ' 1616 ms' │ ' 16 ms' │ ' 101.00 x' │
|
|
1738
|
+
│ Array_Composite_Intersect │ 1000 │ ' 776 ms' │ ' 16 ms' │ ' 48.50 x' │
|
|
1739
|
+
│ Array_Composite_Union │ 1000 │ ' 820 ms' │ ' 14 ms' │ ' 58.57 x' │
|
|
1740
|
+
│ Array_Math_Vector4 │ 1000 │ ' 1166 ms' │ ' 15 ms' │ ' 77.73 x' │
|
|
1741
|
+
│ Array_Math_Matrix4 │ 1000 │ ' 695 ms' │ ' 8 ms' │ ' 86.88 x' │
|
|
1741
1742
|
└────────────────────────────┴────────────┴──────────────┴──────────────┴──────────────┘
|
|
1742
1743
|
```
|
|
1743
1744
|
|
|
@@ -1751,37 +1752,37 @@ This benchmark measures validation performance for varying types.
|
|
|
1751
1752
|
┌────────────────────────────┬────────────┬──────────────┬──────────────┬──────────────┬──────────────┐
|
|
1752
1753
|
│ (index) │ Iterations │ ValueCheck │ Ajv │ TypeCompiler │ Performance │
|
|
1753
1754
|
├────────────────────────────┼────────────┼──────────────┼──────────────┼──────────────┼──────────────┤
|
|
1754
|
-
│ Literal_String │ 1000000 │ '
|
|
1755
|
-
│ Literal_Number │ 1000000 │ '
|
|
1756
|
-
│ Literal_Boolean │ 1000000 │ '
|
|
1757
|
-
│ Primitive_Number │ 1000000 │ ' 21 ms' │ '
|
|
1758
|
-
│ Primitive_String │ 1000000 │ ' 22 ms' │ '
|
|
1759
|
-
│ Primitive_String_Pattern │ 1000000 │ '
|
|
1760
|
-
│ Primitive_Boolean │ 1000000 │ ' 18 ms' │ '
|
|
1755
|
+
│ Literal_String │ 1000000 │ ' 18 ms' │ ' 5 ms' │ ' 4 ms' │ ' 1.25 x' │
|
|
1756
|
+
│ Literal_Number │ 1000000 │ ' 16 ms' │ ' 18 ms' │ ' 10 ms' │ ' 1.80 x' │
|
|
1757
|
+
│ Literal_Boolean │ 1000000 │ ' 15 ms' │ ' 19 ms' │ ' 10 ms' │ ' 1.90 x' │
|
|
1758
|
+
│ Primitive_Number │ 1000000 │ ' 21 ms' │ ' 19 ms' │ ' 10 ms' │ ' 1.90 x' │
|
|
1759
|
+
│ Primitive_String │ 1000000 │ ' 22 ms' │ ' 18 ms' │ ' 9 ms' │ ' 2.00 x' │
|
|
1760
|
+
│ Primitive_String_Pattern │ 1000000 │ ' 155 ms' │ ' 41 ms' │ ' 34 ms' │ ' 1.21 x' │
|
|
1761
|
+
│ Primitive_Boolean │ 1000000 │ ' 18 ms' │ ' 17 ms' │ ' 9 ms' │ ' 1.89 x' │
|
|
1761
1762
|
│ Primitive_Null │ 1000000 │ ' 19 ms' │ ' 17 ms' │ ' 9 ms' │ ' 1.89 x' │
|
|
1762
|
-
│ Object_Unconstrained │ 1000000 │ '
|
|
1763
|
-
│ Object_Constrained │ 1000000 │ '
|
|
1764
|
-
│ Object_Vector3 │ 1000000 │ '
|
|
1765
|
-
│ Object_Box3D │ 1000000 │ '
|
|
1766
|
-
│ Object_Recursive │ 1000000 │ '
|
|
1767
|
-
│ Tuple_Primitive │ 1000000 │ '
|
|
1768
|
-
│ Tuple_Object │ 1000000 │ '
|
|
1769
|
-
│ Composite_Intersect │ 1000000 │ '
|
|
1770
|
-
│ Composite_Union │ 1000000 │ '
|
|
1771
|
-
│ Math_Vector4 │ 1000000 │ '
|
|
1772
|
-
│ Math_Matrix4 │ 1000000 │ '
|
|
1773
|
-
│ Array_Primitive_Number │ 1000000 │ '
|
|
1774
|
-
│ Array_Primitive_String │ 1000000 │ '
|
|
1775
|
-
│ Array_Primitive_Boolean │ 1000000 │ '
|
|
1776
|
-
│ Array_Object_Unconstrained │ 1000000 │ '
|
|
1777
|
-
│ Array_Object_Constrained │ 1000000 │ '
|
|
1778
|
-
│ Array_Object_Recursive │ 1000000 │ '
|
|
1779
|
-
│ Array_Tuple_Primitive │ 1000000 │ '
|
|
1780
|
-
│ Array_Tuple_Object │ 1000000 │ '
|
|
1781
|
-
│ Array_Composite_Intersect │ 1000000 │ '
|
|
1782
|
-
│ Array_Composite_Union │ 1000000 │ '
|
|
1783
|
-
│ Array_Math_Vector4 │ 1000000 │ '
|
|
1784
|
-
│ Array_Math_Matrix4 │ 1000000 │ '
|
|
1763
|
+
│ Object_Unconstrained │ 1000000 │ ' 1003 ms' │ ' 32 ms' │ ' 24 ms' │ ' 1.33 x' │
|
|
1764
|
+
│ Object_Constrained │ 1000000 │ ' 1265 ms' │ ' 49 ms' │ ' 38 ms' │ ' 1.29 x' │
|
|
1765
|
+
│ Object_Vector3 │ 1000000 │ ' 418 ms' │ ' 22 ms' │ ' 13 ms' │ ' 1.69 x' │
|
|
1766
|
+
│ Object_Box3D │ 1000000 │ ' 2035 ms' │ ' 56 ms' │ ' 49 ms' │ ' 1.14 x' │
|
|
1767
|
+
│ Object_Recursive │ 1000000 │ ' 5243 ms' │ ' 326 ms' │ ' 157 ms' │ ' 2.08 x' │
|
|
1768
|
+
│ Tuple_Primitive │ 1000000 │ ' 153 ms' │ ' 20 ms' │ ' 12 ms' │ ' 1.67 x' │
|
|
1769
|
+
│ Tuple_Object │ 1000000 │ ' 781 ms' │ ' 28 ms' │ ' 18 ms' │ ' 1.56 x' │
|
|
1770
|
+
│ Composite_Intersect │ 1000000 │ ' 742 ms' │ ' 25 ms' │ ' 14 ms' │ ' 1.79 x' │
|
|
1771
|
+
│ Composite_Union │ 1000000 │ ' 558 ms' │ ' 24 ms' │ ' 13 ms' │ ' 1.85 x' │
|
|
1772
|
+
│ Math_Vector4 │ 1000000 │ ' 246 ms' │ ' 22 ms' │ ' 11 ms' │ ' 2.00 x' │
|
|
1773
|
+
│ Math_Matrix4 │ 1000000 │ ' 1052 ms' │ ' 43 ms' │ ' 28 ms' │ ' 1.54 x' │
|
|
1774
|
+
│ Array_Primitive_Number │ 1000000 │ ' 272 ms' │ ' 22 ms' │ ' 12 ms' │ ' 1.83 x' │
|
|
1775
|
+
│ Array_Primitive_String │ 1000000 │ ' 235 ms' │ ' 24 ms' │ ' 14 ms' │ ' 1.71 x' │
|
|
1776
|
+
│ Array_Primitive_Boolean │ 1000000 │ ' 134 ms' │ ' 23 ms' │ ' 14 ms' │ ' 1.64 x' │
|
|
1777
|
+
│ Array_Object_Unconstrained │ 1000000 │ ' 6280 ms' │ ' 65 ms' │ ' 59 ms' │ ' 1.10 x' │
|
|
1778
|
+
│ Array_Object_Constrained │ 1000000 │ ' 6076 ms' │ ' 130 ms' │ ' 119 ms' │ ' 1.09 x' │
|
|
1779
|
+
│ Array_Object_Recursive │ 1000000 │ ' 22738 ms' │ ' 1730 ms' │ ' 635 ms' │ ' 2.72 x' │
|
|
1780
|
+
│ Array_Tuple_Primitive │ 1000000 │ ' 689 ms' │ ' 35 ms' │ ' 30 ms' │ ' 1.17 x' │
|
|
1781
|
+
│ Array_Tuple_Object │ 1000000 │ ' 3266 ms' │ ' 63 ms' │ ' 52 ms' │ ' 1.21 x' │
|
|
1782
|
+
│ Array_Composite_Intersect │ 1000000 │ ' 3310 ms' │ ' 44 ms' │ ' 36 ms' │ ' 1.22 x' │
|
|
1783
|
+
│ Array_Composite_Union │ 1000000 │ ' 2432 ms' │ ' 69 ms' │ ' 33 ms' │ ' 2.09 x' │
|
|
1784
|
+
│ Array_Math_Vector4 │ 1000000 │ ' 1158 ms' │ ' 37 ms' │ ' 24 ms' │ ' 1.54 x' │
|
|
1785
|
+
│ Array_Math_Matrix4 │ 1000000 │ ' 5435 ms' │ ' 132 ms' │ ' 92 ms' │ ' 1.43 x' │
|
|
1785
1786
|
└────────────────────────────┴────────────┴──────────────┴──────────────┴──────────────┴──────────────┘
|
|
1786
1787
|
```
|
|
1787
1788
|
|
|
@@ -1795,11 +1796,11 @@ The following table lists esbuild compiled and minified sizes for each TypeBox m
|
|
|
1795
1796
|
┌──────────────────────┬────────────┬────────────┬─────────────┐
|
|
1796
1797
|
│ (index) │ Compiled │ Minified │ Compression │
|
|
1797
1798
|
├──────────────────────┼────────────┼────────────┼─────────────┤
|
|
1798
|
-
│ typebox/compiler │ '120.
|
|
1799
|
-
│ typebox/errors │ ' 55.
|
|
1799
|
+
│ typebox/compiler │ '120.6 kb' │ ' 52.9 kb' │ '2.28 x' │
|
|
1800
|
+
│ typebox/errors │ ' 55.7 kb' │ ' 25.5 kb' │ '2.19 x' │
|
|
1800
1801
|
│ typebox/system │ ' 4.7 kb' │ ' 2.0 kb' │ '2.33 x' │
|
|
1801
|
-
│ typebox/value │ '
|
|
1802
|
-
│ typebox │ ' 91.
|
|
1802
|
+
│ typebox/value │ '146.2 kb' │ ' 62.0 kb' │ '2.36 x' │
|
|
1803
|
+
│ typebox │ ' 91.4 kb' │ ' 37.8 kb' │ '2.42 x' │
|
|
1803
1804
|
└──────────────────────┴────────────┴────────────┴─────────────┘
|
|
1804
1805
|
```
|
|
1805
1806
|
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './operators.mjs';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './operators.mjs';
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
export type TOperatorIncludes<T extends PropertyKey[], S extends PropertyKey> = (T extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? S extends L ? true : TOperatorIncludes<R, S> : false);
|
|
2
|
-
/** Returns true if element S is in the set of T */
|
|
3
|
-
export declare function OperatorIncludes<T extends PropertyKey[], S extends PropertyKey>(T: [...T], S: S): TOperatorIncludes<T, S>;
|
|
4
|
-
export type TOperatorSubset<T extends PropertyKey[], S extends PropertyKey[]> = (T extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? TOperatorIncludes<S, L> extends true ? TOperatorSubset<R, S> : false : true);
|
|
5
|
-
/** Returns true if T is a subset of S */
|
|
6
|
-
export declare function OperatorSubset<T extends PropertyKey[], S extends PropertyKey[]>(T: [...T], S: [...S]): TOperatorSubset<T, S>;
|
|
7
|
-
export type TOperatorDistinct<T extends PropertyKey[], Acc extends PropertyKey[] = []> = T extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? TOperatorIncludes<Acc, L> extends false ? TOperatorDistinct<R, [...Acc, L]> : TOperatorDistinct<R, [...Acc]> : Acc;
|
|
8
|
-
/** Returns a distinct set of elements */
|
|
9
|
-
export declare function OperatorDistinct<T extends PropertyKey[]>(T: [...T], Acc?: PropertyKey[]): TOperatorDistinct<T>;
|
|
10
|
-
export type TOperatorIntersect<T extends PropertyKey[], S extends PropertyKey[], Acc extends PropertyKey[] = []> = (T extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? TOperatorIncludes<S, L> extends true ? TOperatorIntersect<R, S, [L, ...Acc]> : TOperatorIntersect<R, S, [...Acc]> : Acc);
|
|
11
|
-
/** Returns the Intersect of the given sets */
|
|
12
|
-
export declare function OperatorIntersect<T extends PropertyKey[], S extends PropertyKey[]>(T: [...T], S: [...S]): TOperatorIntersect<T, S>;
|
|
13
|
-
export type TOperatorUnion<T extends PropertyKey[], S extends PropertyKey[], Acc extends PropertyKey[] = S> = (T extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? TOperatorUnion<R, S, [...Acc, L]> : Acc);
|
|
14
|
-
/** Returns the Union of the given sets */
|
|
15
|
-
export declare function OperatorUnion<T extends PropertyKey[], S extends PropertyKey[]>(T: [...T], S: [...S], Acc?: PropertyKey[]): TOperatorUnion<T, S>;
|
|
16
|
-
export type OperatorComplement<T extends PropertyKey[], S extends PropertyKey[], Acc extends PropertyKey[] = []> = (T extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? TOperatorIncludes<S, L> extends true ? OperatorComplement<R, S, [...Acc]> : OperatorComplement<R, S, [L, ...Acc]> : Acc);
|
|
17
|
-
/** Returns the Complement by omitting elements in T that are in S */
|
|
18
|
-
export declare function OperatorComplement<T extends PropertyKey[], S extends PropertyKey[]>(T: [...T], S: [...S], Acc?: PropertyKey[]): OperatorComplement<T, S>;
|
|
19
|
-
export type OperatorIntersectMany<T extends PropertyKey[][], Acc extends PropertyKey[] = []> = (T extends [infer L extends PropertyKey[]] ? L : T extends [infer L extends PropertyKey[], ...infer R extends PropertyKey[][]] ? OperatorIntersectMany<R, TOperatorIntersect<Acc, L>> : Acc);
|
|
20
|
-
/** Returns the Intersect of multiple sets */
|
|
21
|
-
export declare function OperatorIntersectMany<T extends PropertyKey[][]>(T: [...T], Acc?: PropertyKey[]): OperatorIntersectMany<T>;
|
|
22
|
-
export type OperatorUnionMany<T extends PropertyKey[][], Acc extends PropertyKey[] = []> = (T extends [infer L extends PropertyKey[], ...infer R extends PropertyKey[][]] ? OperatorUnionMany<R, TOperatorUnion<Acc, L>> : Acc);
|
|
23
|
-
/** Returns the Union of multiple sets */
|
|
24
|
-
export declare function OperatorUnionMany<T extends PropertyKey[][]>(T: [...T], Acc?: PropertyKey[]): OperatorUnionMany<T>;
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
/** Returns true if element S is in the set of T */
|
|
2
|
-
// prettier-ignore
|
|
3
|
-
export function OperatorIncludes(T, S) {
|
|
4
|
-
const [L, ...R] = T;
|
|
5
|
-
return (T.length > 0
|
|
6
|
-
? S === L
|
|
7
|
-
? true
|
|
8
|
-
: OperatorIncludes(R, S)
|
|
9
|
-
: false);
|
|
10
|
-
}
|
|
11
|
-
/** Returns true if T is a subset of S */
|
|
12
|
-
export function OperatorSubset(T, S) {
|
|
13
|
-
const [L, ...R] = T;
|
|
14
|
-
// prettier-ignore
|
|
15
|
-
return (T.length > 0
|
|
16
|
-
? OperatorIncludes(S, L) === true
|
|
17
|
-
? OperatorSubset(R, S)
|
|
18
|
-
: false
|
|
19
|
-
: true);
|
|
20
|
-
}
|
|
21
|
-
/** Returns a distinct set of elements */
|
|
22
|
-
export function OperatorDistinct(T, Acc = []) {
|
|
23
|
-
const [L, ...R] = T;
|
|
24
|
-
// prettier-ignore
|
|
25
|
-
return (T.length > 0 ?
|
|
26
|
-
(OperatorIncludes(Acc, L) === false
|
|
27
|
-
? OperatorDistinct(R, [...Acc, L])
|
|
28
|
-
: OperatorDistinct(R, [...Acc])) : Acc);
|
|
29
|
-
}
|
|
30
|
-
/** Returns the Intersect of the given sets */
|
|
31
|
-
export function OperatorIntersect(T, S) {
|
|
32
|
-
const [L, ...R] = T;
|
|
33
|
-
// prettier-ignore
|
|
34
|
-
return (T.length > 0
|
|
35
|
-
? OperatorIncludes(S, L) === true
|
|
36
|
-
? [L, ...OperatorIntersect(R, S)]
|
|
37
|
-
: [...OperatorIntersect(R, S)]
|
|
38
|
-
: []);
|
|
39
|
-
}
|
|
40
|
-
/** Returns the Union of the given sets */
|
|
41
|
-
export function OperatorUnion(T, S, Acc = S) {
|
|
42
|
-
const [L, ...R] = T;
|
|
43
|
-
// prettier-ignore
|
|
44
|
-
return (T.length > 0
|
|
45
|
-
? OperatorUnion(R, S, [...Acc, L])
|
|
46
|
-
: Acc);
|
|
47
|
-
}
|
|
48
|
-
/** Returns the Complement by omitting elements in T that are in S */
|
|
49
|
-
// prettier-ignore
|
|
50
|
-
export function OperatorComplement(T, S, Acc = []) {
|
|
51
|
-
const [L, ...R] = T;
|
|
52
|
-
return (T.length > 0
|
|
53
|
-
? OperatorIncludes(S, L) === true
|
|
54
|
-
? OperatorComplement(R, S, [...Acc])
|
|
55
|
-
: OperatorComplement(R, S, [L, ...Acc])
|
|
56
|
-
: Acc);
|
|
57
|
-
}
|
|
58
|
-
/** Returns the Intersect of multiple sets */
|
|
59
|
-
// prettier-ignore
|
|
60
|
-
export function OperatorIntersectMany(T, Acc = []) {
|
|
61
|
-
return (T.length === 1
|
|
62
|
-
? T[0]
|
|
63
|
-
: (() => {
|
|
64
|
-
const [L, ...R] = T;
|
|
65
|
-
return (L.length > 0
|
|
66
|
-
? OperatorIntersect(L, OperatorIntersectMany(R))
|
|
67
|
-
: []);
|
|
68
|
-
})());
|
|
69
|
-
}
|
|
70
|
-
/** Returns the Union of multiple sets */
|
|
71
|
-
export function OperatorUnionMany(T, Acc = []) {
|
|
72
|
-
const [L, ...R] = T;
|
|
73
|
-
// prettier-ignore
|
|
74
|
-
return (T.length > 0
|
|
75
|
-
? OperatorUnionMany(R, OperatorUnion(Acc, L))
|
|
76
|
-
: Acc);
|
|
77
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './operators';
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
export type TOperatorIncludes<T extends PropertyKey[], S extends PropertyKey> = (T extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? S extends L ? true : TOperatorIncludes<R, S> : false);
|
|
2
|
-
/** Returns true if element S is in the set of T */
|
|
3
|
-
export declare function OperatorIncludes<T extends PropertyKey[], S extends PropertyKey>(T: [...T], S: S): TOperatorIncludes<T, S>;
|
|
4
|
-
export type TOperatorSubset<T extends PropertyKey[], S extends PropertyKey[]> = (T extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? TOperatorIncludes<S, L> extends true ? TOperatorSubset<R, S> : false : true);
|
|
5
|
-
/** Returns true if T is a subset of S */
|
|
6
|
-
export declare function OperatorSubset<T extends PropertyKey[], S extends PropertyKey[]>(T: [...T], S: [...S]): TOperatorSubset<T, S>;
|
|
7
|
-
export type TOperatorDistinct<T extends PropertyKey[], Acc extends PropertyKey[] = []> = T extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? TOperatorIncludes<Acc, L> extends false ? TOperatorDistinct<R, [...Acc, L]> : TOperatorDistinct<R, [...Acc]> : Acc;
|
|
8
|
-
/** Returns a distinct set of elements */
|
|
9
|
-
export declare function OperatorDistinct<T extends PropertyKey[]>(T: [...T], Acc?: PropertyKey[]): TOperatorDistinct<T>;
|
|
10
|
-
export type TOperatorIntersect<T extends PropertyKey[], S extends PropertyKey[], Acc extends PropertyKey[] = []> = (T extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? TOperatorIncludes<S, L> extends true ? TOperatorIntersect<R, S, [L, ...Acc]> : TOperatorIntersect<R, S, [...Acc]> : Acc);
|
|
11
|
-
/** Returns the Intersect of the given sets */
|
|
12
|
-
export declare function OperatorIntersect<T extends PropertyKey[], S extends PropertyKey[]>(T: [...T], S: [...S]): TOperatorIntersect<T, S>;
|
|
13
|
-
export type TOperatorUnion<T extends PropertyKey[], S extends PropertyKey[], Acc extends PropertyKey[] = S> = (T extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? TOperatorUnion<R, S, [...Acc, L]> : Acc);
|
|
14
|
-
/** Returns the Union of the given sets */
|
|
15
|
-
export declare function OperatorUnion<T extends PropertyKey[], S extends PropertyKey[]>(T: [...T], S: [...S], Acc?: PropertyKey[]): TOperatorUnion<T, S>;
|
|
16
|
-
export type OperatorComplement<T extends PropertyKey[], S extends PropertyKey[], Acc extends PropertyKey[] = []> = (T extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? TOperatorIncludes<S, L> extends true ? OperatorComplement<R, S, [...Acc]> : OperatorComplement<R, S, [L, ...Acc]> : Acc);
|
|
17
|
-
/** Returns the Complement by omitting elements in T that are in S */
|
|
18
|
-
export declare function OperatorComplement<T extends PropertyKey[], S extends PropertyKey[]>(T: [...T], S: [...S], Acc?: PropertyKey[]): OperatorComplement<T, S>;
|
|
19
|
-
export type OperatorIntersectMany<T extends PropertyKey[][], Acc extends PropertyKey[] = []> = (T extends [infer L extends PropertyKey[]] ? L : T extends [infer L extends PropertyKey[], ...infer R extends PropertyKey[][]] ? OperatorIntersectMany<R, TOperatorIntersect<Acc, L>> : Acc);
|
|
20
|
-
/** Returns the Intersect of multiple sets */
|
|
21
|
-
export declare function OperatorIntersectMany<T extends PropertyKey[][]>(T: [...T], Acc?: PropertyKey[]): OperatorIntersectMany<T>;
|
|
22
|
-
export type OperatorUnionMany<T extends PropertyKey[][], Acc extends PropertyKey[] = []> = (T extends [infer L extends PropertyKey[], ...infer R extends PropertyKey[][]] ? OperatorUnionMany<R, TOperatorUnion<Acc, L>> : Acc);
|
|
23
|
-
/** Returns the Union of multiple sets */
|
|
24
|
-
export declare function OperatorUnionMany<T extends PropertyKey[][]>(T: [...T], Acc?: PropertyKey[]): OperatorUnionMany<T>;
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.OperatorUnionMany = exports.OperatorIntersectMany = exports.OperatorComplement = exports.OperatorUnion = exports.OperatorIntersect = exports.OperatorDistinct = exports.OperatorSubset = exports.OperatorIncludes = void 0;
|
|
5
|
-
/** Returns true if element S is in the set of T */
|
|
6
|
-
// prettier-ignore
|
|
7
|
-
function OperatorIncludes(T, S) {
|
|
8
|
-
const [L, ...R] = T;
|
|
9
|
-
return (T.length > 0
|
|
10
|
-
? S === L
|
|
11
|
-
? true
|
|
12
|
-
: OperatorIncludes(R, S)
|
|
13
|
-
: false);
|
|
14
|
-
}
|
|
15
|
-
exports.OperatorIncludes = OperatorIncludes;
|
|
16
|
-
/** Returns true if T is a subset of S */
|
|
17
|
-
function OperatorSubset(T, S) {
|
|
18
|
-
const [L, ...R] = T;
|
|
19
|
-
// prettier-ignore
|
|
20
|
-
return (T.length > 0
|
|
21
|
-
? OperatorIncludes(S, L) === true
|
|
22
|
-
? OperatorSubset(R, S)
|
|
23
|
-
: false
|
|
24
|
-
: true);
|
|
25
|
-
}
|
|
26
|
-
exports.OperatorSubset = OperatorSubset;
|
|
27
|
-
/** Returns a distinct set of elements */
|
|
28
|
-
function OperatorDistinct(T, Acc = []) {
|
|
29
|
-
const [L, ...R] = T;
|
|
30
|
-
// prettier-ignore
|
|
31
|
-
return (T.length > 0 ?
|
|
32
|
-
(OperatorIncludes(Acc, L) === false
|
|
33
|
-
? OperatorDistinct(R, [...Acc, L])
|
|
34
|
-
: OperatorDistinct(R, [...Acc])) : Acc);
|
|
35
|
-
}
|
|
36
|
-
exports.OperatorDistinct = OperatorDistinct;
|
|
37
|
-
/** Returns the Intersect of the given sets */
|
|
38
|
-
function OperatorIntersect(T, S) {
|
|
39
|
-
const [L, ...R] = T;
|
|
40
|
-
// prettier-ignore
|
|
41
|
-
return (T.length > 0
|
|
42
|
-
? OperatorIncludes(S, L) === true
|
|
43
|
-
? [L, ...OperatorIntersect(R, S)]
|
|
44
|
-
: [...OperatorIntersect(R, S)]
|
|
45
|
-
: []);
|
|
46
|
-
}
|
|
47
|
-
exports.OperatorIntersect = OperatorIntersect;
|
|
48
|
-
/** Returns the Union of the given sets */
|
|
49
|
-
function OperatorUnion(T, S, Acc = S) {
|
|
50
|
-
const [L, ...R] = T;
|
|
51
|
-
// prettier-ignore
|
|
52
|
-
return (T.length > 0
|
|
53
|
-
? OperatorUnion(R, S, [...Acc, L])
|
|
54
|
-
: Acc);
|
|
55
|
-
}
|
|
56
|
-
exports.OperatorUnion = OperatorUnion;
|
|
57
|
-
/** Returns the Complement by omitting elements in T that are in S */
|
|
58
|
-
// prettier-ignore
|
|
59
|
-
function OperatorComplement(T, S, Acc = []) {
|
|
60
|
-
const [L, ...R] = T;
|
|
61
|
-
return (T.length > 0
|
|
62
|
-
? OperatorIncludes(S, L) === true
|
|
63
|
-
? OperatorComplement(R, S, [...Acc])
|
|
64
|
-
: OperatorComplement(R, S, [L, ...Acc])
|
|
65
|
-
: Acc);
|
|
66
|
-
}
|
|
67
|
-
exports.OperatorComplement = OperatorComplement;
|
|
68
|
-
/** Returns the Intersect of multiple sets */
|
|
69
|
-
// prettier-ignore
|
|
70
|
-
function OperatorIntersectMany(T, Acc = []) {
|
|
71
|
-
return (T.length === 1
|
|
72
|
-
? T[0]
|
|
73
|
-
: (() => {
|
|
74
|
-
const [L, ...R] = T;
|
|
75
|
-
return (L.length > 0
|
|
76
|
-
? OperatorIntersect(L, OperatorIntersectMany(R))
|
|
77
|
-
: []);
|
|
78
|
-
})());
|
|
79
|
-
}
|
|
80
|
-
exports.OperatorIntersectMany = OperatorIntersectMany;
|
|
81
|
-
/** Returns the Union of multiple sets */
|
|
82
|
-
function OperatorUnionMany(T, Acc = []) {
|
|
83
|
-
const [L, ...R] = T;
|
|
84
|
-
// prettier-ignore
|
|
85
|
-
return (T.length > 0
|
|
86
|
-
? OperatorUnionMany(R, OperatorUnion(Acc, L))
|
|
87
|
-
: Acc);
|
|
88
|
-
}
|
|
89
|
-
exports.OperatorUnionMany = OperatorUnionMany;
|