@sinclair/typebox 0.24.50 → 0.24.52

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.
Files changed (47) hide show
  1. package/compiler/compiler.d.ts +25 -28
  2. package/compiler/compiler.js +408 -409
  3. package/compiler/index.d.ts +2 -2
  4. package/compiler/index.js +47 -47
  5. package/conditional/conditional.d.ts +17 -17
  6. package/conditional/conditional.js +91 -91
  7. package/conditional/index.d.ts +2 -2
  8. package/conditional/index.js +45 -45
  9. package/conditional/structural.d.ts +11 -11
  10. package/conditional/structural.js +657 -657
  11. package/errors/errors.d.ts +60 -60
  12. package/errors/errors.js +398 -398
  13. package/errors/index.d.ts +1 -1
  14. package/errors/index.js +44 -44
  15. package/format/format.d.ts +12 -12
  16. package/format/format.js +55 -55
  17. package/format/index.d.ts +1 -1
  18. package/format/index.js +44 -44
  19. package/guard/guard.d.ts +56 -56
  20. package/guard/guard.js +351 -351
  21. package/guard/index.d.ts +1 -1
  22. package/guard/index.js +44 -44
  23. package/license +22 -22
  24. package/package.json +43 -40
  25. package/readme.md +1152 -1152
  26. package/typebox.d.ts +408 -408
  27. package/typebox.js +383 -383
  28. package/value/cast.d.ts +26 -26
  29. package/value/cast.js +364 -364
  30. package/value/check.d.ts +8 -8
  31. package/value/check.js +331 -331
  32. package/value/clone.d.ts +3 -3
  33. package/value/clone.js +65 -65
  34. package/value/create.d.ts +14 -14
  35. package/value/create.js +357 -357
  36. package/value/delta.d.ts +22 -22
  37. package/value/delta.js +168 -168
  38. package/value/equal.d.ts +3 -3
  39. package/value/equal.js +74 -74
  40. package/value/index.d.ts +3 -3
  41. package/value/index.js +48 -48
  42. package/value/is.d.ts +10 -10
  43. package/value/is.js +49 -49
  44. package/value/pointer.d.ts +24 -24
  45. package/value/pointer.js +142 -142
  46. package/value/value.d.ts +31 -31
  47. package/value/value.js +81 -81
package/value/delta.d.ts CHANGED
@@ -1,22 +1,22 @@
1
- export declare type Edit<T = unknown> = Insert<T> | Update<T> | Delete<T>;
2
- export interface Insert<T> {
3
- brand: T;
4
- type: 'insert';
5
- path: string;
6
- value: any;
7
- }
8
- export interface Update<T> {
9
- brand: T;
10
- type: 'update';
11
- path: string;
12
- value: any;
13
- }
14
- export interface Delete<T> {
15
- brand: T;
16
- type: 'delete';
17
- path: string;
18
- }
19
- export declare namespace ValueDelta {
20
- function Diff<T>(current: T, next: T): Edit<T>[];
21
- function Patch<T>(current: T, edits: Edit<T>[]): T;
22
- }
1
+ export declare type Edit<T = unknown> = Insert<T> | Update<T> | Delete<T>;
2
+ export interface Insert<T> {
3
+ brand: T;
4
+ type: 'insert';
5
+ path: string;
6
+ value: any;
7
+ }
8
+ export interface Update<T> {
9
+ brand: T;
10
+ type: 'update';
11
+ path: string;
12
+ value: any;
13
+ }
14
+ export interface Delete<T> {
15
+ brand: T;
16
+ type: 'delete';
17
+ path: string;
18
+ }
19
+ export declare namespace ValueDelta {
20
+ function Diff<T>(current: T, next: T): Edit<T>[];
21
+ function Patch<T>(current: T, edits: Edit<T>[]): T;
22
+ }
package/value/delta.js CHANGED
@@ -1,168 +1,168 @@
1
- "use strict";
2
- /*--------------------------------------------------------------------------
3
-
4
- @sinclair/typebox/value
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.ValueDelta = void 0;
31
- const is_1 = require("./is");
32
- const clone_1 = require("./clone");
33
- const pointer_1 = require("./pointer");
34
- var ValueDelta;
35
- (function (ValueDelta) {
36
- // ---------------------------------------------------------------------
37
- // Edits
38
- // ---------------------------------------------------------------------
39
- function Update(path, value) {
40
- return { type: 'update', path, value };
41
- }
42
- function Insert(path, value) {
43
- return { type: 'insert', path, value };
44
- }
45
- function Delete(path) {
46
- return { type: 'delete', path };
47
- }
48
- // ---------------------------------------------------------------------
49
- // Diff
50
- // ---------------------------------------------------------------------
51
- function* Object(path, current, next) {
52
- if (!is_1.Is.Object(next))
53
- return yield Update(path, next);
54
- const currentKeys = [...globalThis.Object.keys(current), ...globalThis.Object.getOwnPropertySymbols(current)];
55
- const nextKeys = [...globalThis.Object.keys(next), ...globalThis.Object.getOwnPropertySymbols(next)];
56
- for (const key of currentKeys) {
57
- if (typeof key === 'symbol')
58
- throw Error('ValueDelta: Cannot produce diff symbol keys');
59
- if (next[key] === undefined && nextKeys.includes(key))
60
- yield Update(`${path}/${String(key)}`, undefined);
61
- }
62
- for (const key of nextKeys) {
63
- if (current[key] === undefined || next[key] === undefined)
64
- continue;
65
- if (typeof key === 'symbol')
66
- throw Error('ValueDelta: Cannot produce diff symbol keys');
67
- yield* Visit(`${path}/${String(key)}`, current[key], next[key]);
68
- }
69
- for (const key of nextKeys) {
70
- if (typeof key === 'symbol')
71
- throw Error('ValueDelta: Cannot produce diff symbol keys');
72
- if (current[key] === undefined)
73
- yield Insert(`${path}/${String(key)}`, next[key]);
74
- }
75
- for (const key of currentKeys.reverse()) {
76
- if (typeof key === 'symbol')
77
- throw Error('ValueDelta: Cannot produce diff symbol keys');
78
- if (next[key] === undefined && !nextKeys.includes(key))
79
- yield Delete(`${path}/${String(key)}`);
80
- }
81
- }
82
- function* Array(path, current, next) {
83
- if (!is_1.Is.Array(next))
84
- return yield Update(path, next);
85
- for (let i = 0; i < Math.min(current.length, next.length); i++) {
86
- yield* Visit(`${path}/${i}`, current[i], next[i]);
87
- }
88
- for (let i = 0; i < next.length; i++) {
89
- if (i < current.length)
90
- continue;
91
- yield Insert(`${path}/${i}`, next[i]);
92
- }
93
- for (let i = current.length - 1; i >= 0; i--) {
94
- if (i < next.length)
95
- continue;
96
- yield Delete(`${path}/${i}`);
97
- }
98
- }
99
- function* TypedArray(path, current, next) {
100
- if (!is_1.Is.TypedArray(next) || current.length !== next.length || globalThis.Object.getPrototypeOf(current).constructor.name !== globalThis.Object.getPrototypeOf(next).constructor.name)
101
- return yield Update(path, next);
102
- for (let i = 0; i < Math.min(current.length, next.length); i++) {
103
- yield* Visit(`${path}/${i}`, current[i], next[i]);
104
- }
105
- }
106
- function* Value(path, current, next) {
107
- if (current === next)
108
- return;
109
- yield Update(path, next);
110
- }
111
- function* Visit(path, current, next) {
112
- if (is_1.Is.Object(current)) {
113
- return yield* Object(path, current, next);
114
- }
115
- else if (is_1.Is.Array(current)) {
116
- return yield* Array(path, current, next);
117
- }
118
- else if (is_1.Is.TypedArray(current)) {
119
- return yield* TypedArray(path, current, next);
120
- }
121
- else if (is_1.Is.Value(current)) {
122
- return yield* Value(path, current, next);
123
- }
124
- else {
125
- throw new Error('ValueDelta: Cannot produce edits for value');
126
- }
127
- }
128
- function Diff(current, next) {
129
- return [...Visit('', current, next)];
130
- }
131
- ValueDelta.Diff = Diff;
132
- // ---------------------------------------------------------------------
133
- // Patch
134
- // ---------------------------------------------------------------------
135
- function IsRootUpdate(edits) {
136
- return edits.length > 0 && edits[0].path === '' && edits[0].type === 'update';
137
- }
138
- function IsIdentity(edits) {
139
- return edits.length === 0;
140
- }
141
- function Patch(current, edits) {
142
- if (IsRootUpdate(edits)) {
143
- return clone_1.ValueClone.Clone(edits[0].value);
144
- }
145
- if (IsIdentity(edits)) {
146
- return clone_1.ValueClone.Clone(current);
147
- }
148
- const clone = clone_1.ValueClone.Clone(current);
149
- for (const edit of edits) {
150
- switch (edit.type) {
151
- case 'insert': {
152
- pointer_1.ValuePointer.Set(clone, edit.path, edit.value);
153
- break;
154
- }
155
- case 'update': {
156
- pointer_1.ValuePointer.Set(clone, edit.path, edit.value);
157
- break;
158
- }
159
- case 'delete': {
160
- pointer_1.ValuePointer.Delete(clone, edit.path);
161
- break;
162
- }
163
- }
164
- }
165
- return clone;
166
- }
167
- ValueDelta.Patch = Patch;
168
- })(ValueDelta = exports.ValueDelta || (exports.ValueDelta = {}));
1
+ "use strict";
2
+ /*--------------------------------------------------------------------------
3
+
4
+ @sinclair/typebox/value
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.ValueDelta = void 0;
31
+ const is_1 = require("./is");
32
+ const clone_1 = require("./clone");
33
+ const pointer_1 = require("./pointer");
34
+ var ValueDelta;
35
+ (function (ValueDelta) {
36
+ // ---------------------------------------------------------------------
37
+ // Edits
38
+ // ---------------------------------------------------------------------
39
+ function Update(path, value) {
40
+ return { type: 'update', path, value };
41
+ }
42
+ function Insert(path, value) {
43
+ return { type: 'insert', path, value };
44
+ }
45
+ function Delete(path) {
46
+ return { type: 'delete', path };
47
+ }
48
+ // ---------------------------------------------------------------------
49
+ // Diff
50
+ // ---------------------------------------------------------------------
51
+ function* Object(path, current, next) {
52
+ if (!is_1.Is.Object(next))
53
+ return yield Update(path, next);
54
+ const currentKeys = [...globalThis.Object.keys(current), ...globalThis.Object.getOwnPropertySymbols(current)];
55
+ const nextKeys = [...globalThis.Object.keys(next), ...globalThis.Object.getOwnPropertySymbols(next)];
56
+ for (const key of currentKeys) {
57
+ if (typeof key === 'symbol')
58
+ throw Error('ValueDelta: Cannot produce diff symbol keys');
59
+ if (next[key] === undefined && nextKeys.includes(key))
60
+ yield Update(`${path}/${String(key)}`, undefined);
61
+ }
62
+ for (const key of nextKeys) {
63
+ if (current[key] === undefined || next[key] === undefined)
64
+ continue;
65
+ if (typeof key === 'symbol')
66
+ throw Error('ValueDelta: Cannot produce diff symbol keys');
67
+ yield* Visit(`${path}/${String(key)}`, current[key], next[key]);
68
+ }
69
+ for (const key of nextKeys) {
70
+ if (typeof key === 'symbol')
71
+ throw Error('ValueDelta: Cannot produce diff symbol keys');
72
+ if (current[key] === undefined)
73
+ yield Insert(`${path}/${String(key)}`, next[key]);
74
+ }
75
+ for (const key of currentKeys.reverse()) {
76
+ if (typeof key === 'symbol')
77
+ throw Error('ValueDelta: Cannot produce diff symbol keys');
78
+ if (next[key] === undefined && !nextKeys.includes(key))
79
+ yield Delete(`${path}/${String(key)}`);
80
+ }
81
+ }
82
+ function* Array(path, current, next) {
83
+ if (!is_1.Is.Array(next))
84
+ return yield Update(path, next);
85
+ for (let i = 0; i < Math.min(current.length, next.length); i++) {
86
+ yield* Visit(`${path}/${i}`, current[i], next[i]);
87
+ }
88
+ for (let i = 0; i < next.length; i++) {
89
+ if (i < current.length)
90
+ continue;
91
+ yield Insert(`${path}/${i}`, next[i]);
92
+ }
93
+ for (let i = current.length - 1; i >= 0; i--) {
94
+ if (i < next.length)
95
+ continue;
96
+ yield Delete(`${path}/${i}`);
97
+ }
98
+ }
99
+ function* TypedArray(path, current, next) {
100
+ if (!is_1.Is.TypedArray(next) || current.length !== next.length || globalThis.Object.getPrototypeOf(current).constructor.name !== globalThis.Object.getPrototypeOf(next).constructor.name)
101
+ return yield Update(path, next);
102
+ for (let i = 0; i < Math.min(current.length, next.length); i++) {
103
+ yield* Visit(`${path}/${i}`, current[i], next[i]);
104
+ }
105
+ }
106
+ function* Value(path, current, next) {
107
+ if (current === next)
108
+ return;
109
+ yield Update(path, next);
110
+ }
111
+ function* Visit(path, current, next) {
112
+ if (is_1.Is.Object(current)) {
113
+ return yield* Object(path, current, next);
114
+ }
115
+ else if (is_1.Is.Array(current)) {
116
+ return yield* Array(path, current, next);
117
+ }
118
+ else if (is_1.Is.TypedArray(current)) {
119
+ return yield* TypedArray(path, current, next);
120
+ }
121
+ else if (is_1.Is.Value(current)) {
122
+ return yield* Value(path, current, next);
123
+ }
124
+ else {
125
+ throw new Error('ValueDelta: Cannot produce edits for value');
126
+ }
127
+ }
128
+ function Diff(current, next) {
129
+ return [...Visit('', current, next)];
130
+ }
131
+ ValueDelta.Diff = Diff;
132
+ // ---------------------------------------------------------------------
133
+ // Patch
134
+ // ---------------------------------------------------------------------
135
+ function IsRootUpdate(edits) {
136
+ return edits.length > 0 && edits[0].path === '' && edits[0].type === 'update';
137
+ }
138
+ function IsIdentity(edits) {
139
+ return edits.length === 0;
140
+ }
141
+ function Patch(current, edits) {
142
+ if (IsRootUpdate(edits)) {
143
+ return clone_1.ValueClone.Clone(edits[0].value);
144
+ }
145
+ if (IsIdentity(edits)) {
146
+ return clone_1.ValueClone.Clone(current);
147
+ }
148
+ const clone = clone_1.ValueClone.Clone(current);
149
+ for (const edit of edits) {
150
+ switch (edit.type) {
151
+ case 'insert': {
152
+ pointer_1.ValuePointer.Set(clone, edit.path, edit.value);
153
+ break;
154
+ }
155
+ case 'update': {
156
+ pointer_1.ValuePointer.Set(clone, edit.path, edit.value);
157
+ break;
158
+ }
159
+ case 'delete': {
160
+ pointer_1.ValuePointer.Delete(clone, edit.path);
161
+ break;
162
+ }
163
+ }
164
+ }
165
+ return clone;
166
+ }
167
+ ValueDelta.Patch = Patch;
168
+ })(ValueDelta = exports.ValueDelta || (exports.ValueDelta = {}));
package/value/equal.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export declare namespace ValueEqual {
2
- function Equal<T>(left: T, right: unknown): right is T;
3
- }
1
+ export declare namespace ValueEqual {
2
+ function Equal<T>(left: T, right: unknown): right is T;
3
+ }
package/value/equal.js CHANGED
@@ -1,74 +1,74 @@
1
- "use strict";
2
- /*--------------------------------------------------------------------------
3
-
4
- @sinclair/typebox/value
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.ValueEqual = void 0;
31
- const is_1 = require("./is");
32
- var ValueEqual;
33
- (function (ValueEqual) {
34
- function Object(left, right) {
35
- if (!is_1.Is.Object(right))
36
- return false;
37
- const leftKeys = [...globalThis.Object.keys(left), ...globalThis.Object.getOwnPropertySymbols(left)];
38
- const rightKeys = [...globalThis.Object.keys(right), ...globalThis.Object.getOwnPropertySymbols(right)];
39
- if (leftKeys.length !== rightKeys.length)
40
- return false;
41
- return leftKeys.every((key) => Equal(left[key], right[key]));
42
- }
43
- function Array(left, right) {
44
- if (!is_1.Is.Array(right) || left.length !== right.length)
45
- return false;
46
- return left.every((value, index) => Equal(value, right[index]));
47
- }
48
- function TypedArray(left, right) {
49
- if (!is_1.Is.TypedArray(right) || left.length !== right.length || globalThis.Object.getPrototypeOf(left).constructor.name !== globalThis.Object.getPrototypeOf(right).constructor.name)
50
- return false;
51
- return left.every((value, index) => Equal(value, right[index]));
52
- }
53
- function Value(left, right) {
54
- return left === right;
55
- }
56
- function Equal(left, right) {
57
- if (is_1.Is.Object(left)) {
58
- return Object(left, right);
59
- }
60
- else if (is_1.Is.TypedArray(left)) {
61
- return TypedArray(left, right);
62
- }
63
- else if (is_1.Is.Array(left)) {
64
- return Array(left, right);
65
- }
66
- else if (is_1.Is.Value(left)) {
67
- return Value(left, right);
68
- }
69
- else {
70
- throw new Error('ValueEquals: Unable to compare value');
71
- }
72
- }
73
- ValueEqual.Equal = Equal;
74
- })(ValueEqual = exports.ValueEqual || (exports.ValueEqual = {}));
1
+ "use strict";
2
+ /*--------------------------------------------------------------------------
3
+
4
+ @sinclair/typebox/value
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.ValueEqual = void 0;
31
+ const is_1 = require("./is");
32
+ var ValueEqual;
33
+ (function (ValueEqual) {
34
+ function Object(left, right) {
35
+ if (!is_1.Is.Object(right))
36
+ return false;
37
+ const leftKeys = [...globalThis.Object.keys(left), ...globalThis.Object.getOwnPropertySymbols(left)];
38
+ const rightKeys = [...globalThis.Object.keys(right), ...globalThis.Object.getOwnPropertySymbols(right)];
39
+ if (leftKeys.length !== rightKeys.length)
40
+ return false;
41
+ return leftKeys.every((key) => Equal(left[key], right[key]));
42
+ }
43
+ function Array(left, right) {
44
+ if (!is_1.Is.Array(right) || left.length !== right.length)
45
+ return false;
46
+ return left.every((value, index) => Equal(value, right[index]));
47
+ }
48
+ function TypedArray(left, right) {
49
+ if (!is_1.Is.TypedArray(right) || left.length !== right.length || globalThis.Object.getPrototypeOf(left).constructor.name !== globalThis.Object.getPrototypeOf(right).constructor.name)
50
+ return false;
51
+ return left.every((value, index) => Equal(value, right[index]));
52
+ }
53
+ function Value(left, right) {
54
+ return left === right;
55
+ }
56
+ function Equal(left, right) {
57
+ if (is_1.Is.Object(left)) {
58
+ return Object(left, right);
59
+ }
60
+ else if (is_1.Is.TypedArray(left)) {
61
+ return TypedArray(left, right);
62
+ }
63
+ else if (is_1.Is.Array(left)) {
64
+ return Array(left, right);
65
+ }
66
+ else if (is_1.Is.Value(left)) {
67
+ return Value(left, right);
68
+ }
69
+ else {
70
+ throw new Error('ValueEquals: Unable to compare value');
71
+ }
72
+ }
73
+ ValueEqual.Equal = Equal;
74
+ })(ValueEqual = exports.ValueEqual || (exports.ValueEqual = {}));
package/value/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export { ValueError, ValueErrorType } from '../errors/index';
2
- export * from './pointer';
3
- export * from './value';
1
+ export { ValueError, ValueErrorType } from '../errors/index';
2
+ export * from './pointer';
3
+ export * from './value';
package/value/index.js CHANGED
@@ -1,48 +1,48 @@
1
- "use strict";
2
- /*--------------------------------------------------------------------------
3
-
4
- @sinclair/typebox/value
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
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
30
- if (k2 === undefined) k2 = k;
31
- var desc = Object.getOwnPropertyDescriptor(m, k);
32
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
33
- desc = { enumerable: true, get: function() { return m[k]; } };
34
- }
35
- Object.defineProperty(o, k2, desc);
36
- }) : (function(o, m, k, k2) {
37
- if (k2 === undefined) k2 = k;
38
- o[k2] = m[k];
39
- }));
40
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
41
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
42
- };
43
- Object.defineProperty(exports, "__esModule", { value: true });
44
- exports.ValueErrorType = void 0;
45
- var index_1 = require("../errors/index");
46
- Object.defineProperty(exports, "ValueErrorType", { enumerable: true, get: function () { return index_1.ValueErrorType; } });
47
- __exportStar(require("./pointer"), exports);
48
- __exportStar(require("./value"), exports);
1
+ "use strict";
2
+ /*--------------------------------------------------------------------------
3
+
4
+ @sinclair/typebox/value
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
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
30
+ if (k2 === undefined) k2 = k;
31
+ var desc = Object.getOwnPropertyDescriptor(m, k);
32
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
33
+ desc = { enumerable: true, get: function() { return m[k]; } };
34
+ }
35
+ Object.defineProperty(o, k2, desc);
36
+ }) : (function(o, m, k, k2) {
37
+ if (k2 === undefined) k2 = k;
38
+ o[k2] = m[k];
39
+ }));
40
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
41
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
42
+ };
43
+ Object.defineProperty(exports, "__esModule", { value: true });
44
+ exports.ValueErrorType = void 0;
45
+ var index_1 = require("../errors/index");
46
+ Object.defineProperty(exports, "ValueErrorType", { enumerable: true, get: function () { return index_1.ValueErrorType; } });
47
+ __exportStar(require("./pointer"), exports);
48
+ __exportStar(require("./value"), exports);