@sinclair/typebox 0.32.13 → 0.32.15
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/index.d.mts +1 -1
- package/build/import/compiler/index.mjs +1 -1
- package/build/import/errors/index.d.mts +2 -2
- package/build/import/errors/index.mjs +2 -2
- package/build/import/index.d.mts +69 -69
- package/build/import/index.mjs +69 -76
- package/build/import/system/index.d.mts +2 -2
- package/build/import/system/index.mjs +2 -2
- package/build/import/type/clone/index.d.mts +2 -2
- package/build/import/type/clone/index.mjs +2 -2
- package/build/import/type/const/const.mjs +2 -2
- package/build/import/type/object/object.d.mts +1 -1
- package/build/import/type/object/object.mjs +1 -1
- package/build/import/value/cast/cast.mjs +2 -2
- package/build/import/value/clone/clone.mjs +2 -2
- package/build/import/value/delta/delta.mjs +3 -3
- package/build/import/value/equal/equal.mjs +3 -3
- package/build/import/value/guard/guard.d.mts +34 -6
- package/build/import/value/guard/guard.mjs +71 -12
- package/build/import/value/hash/hash.mjs +2 -2
- package/build/import/value/index.d.mts +14 -14
- package/build/import/value/index.mjs +18 -18
- package/build/import/value/mutate/mutate.mjs +5 -5
- package/build/import/value/transform/decode.mjs +4 -4
- package/build/import/value/transform/encode.mjs +4 -4
- package/build/require/compiler/index.d.ts +1 -1
- package/build/require/compiler/index.js +16 -6
- package/build/require/errors/index.d.ts +2 -2
- package/build/require/errors/index.js +16 -10
- package/build/require/index.d.ts +69 -69
- package/build/require/index.js +83 -202
- package/build/require/system/index.d.ts +2 -2
- package/build/require/system/index.js +16 -7
- package/build/require/type/clone/index.d.ts +2 -2
- package/build/require/type/clone/index.js +16 -3
- package/build/require/type/const/const.js +1 -1
- package/build/require/type/object/object.d.ts +1 -1
- package/build/require/type/object/object.js +1 -2
- package/build/require/value/cast/cast.js +1 -1
- package/build/require/value/clone/clone.js +1 -1
- package/build/require/value/delta/delta.js +2 -2
- package/build/require/value/equal/equal.js +2 -2
- package/build/require/value/guard/guard.d.ts +34 -6
- package/build/require/value/guard/guard.js +89 -16
- package/build/require/value/hash/hash.js +1 -1
- package/build/require/value/index.d.ts +14 -14
- package/build/require/value/index.js +35 -71
- package/build/require/value/mutate/mutate.js +4 -4
- package/build/require/value/transform/decode.js +3 -3
- package/build/require/value/transform/encode.js +3 -3
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { ValueError, ValueErrorType, ValueErrorIterator } from '../errors/index.mjs';
|
|
2
|
-
export
|
|
2
|
+
export * from './compiler.mjs';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { ValueErrorType, ValueErrorIterator } from '../errors/index.mjs';
|
|
2
|
-
export
|
|
2
|
+
export * from './compiler.mjs';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
1
|
+
export * from './errors.mjs';
|
|
2
|
+
export * from './function.mjs';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
1
|
+
export * from './errors.mjs';
|
|
2
|
+
export * from './function.mjs';
|
package/build/import/index.d.mts
CHANGED
|
@@ -1,69 +1,69 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export
|
|
8
|
-
export
|
|
9
|
-
export
|
|
10
|
-
export
|
|
11
|
-
export
|
|
12
|
-
export
|
|
13
|
-
export
|
|
14
|
-
export
|
|
15
|
-
export
|
|
16
|
-
export
|
|
17
|
-
export
|
|
18
|
-
export
|
|
19
|
-
export
|
|
20
|
-
export
|
|
21
|
-
export
|
|
22
|
-
export
|
|
23
|
-
export
|
|
24
|
-
export
|
|
25
|
-
export
|
|
26
|
-
export
|
|
27
|
-
export
|
|
28
|
-
export
|
|
29
|
-
export
|
|
30
|
-
export
|
|
31
|
-
export
|
|
32
|
-
export
|
|
33
|
-
export
|
|
34
|
-
export
|
|
35
|
-
export
|
|
36
|
-
export
|
|
37
|
-
export
|
|
38
|
-
export
|
|
39
|
-
export
|
|
40
|
-
export
|
|
41
|
-
export
|
|
42
|
-
export
|
|
43
|
-
export
|
|
44
|
-
export
|
|
45
|
-
export
|
|
46
|
-
export
|
|
47
|
-
export
|
|
48
|
-
export
|
|
49
|
-
export
|
|
50
|
-
export
|
|
51
|
-
export
|
|
52
|
-
export
|
|
53
|
-
export
|
|
54
|
-
export
|
|
55
|
-
export
|
|
56
|
-
export
|
|
57
|
-
export
|
|
58
|
-
export
|
|
59
|
-
export
|
|
60
|
-
export
|
|
61
|
-
export
|
|
62
|
-
export
|
|
63
|
-
export
|
|
64
|
-
export
|
|
65
|
-
export
|
|
66
|
-
export
|
|
67
|
-
export
|
|
68
|
-
export
|
|
69
|
-
export
|
|
1
|
+
export * from './type/clone/index.mjs';
|
|
2
|
+
export * from './type/error/index.mjs';
|
|
3
|
+
export * from './type/guard/index.mjs';
|
|
4
|
+
export * from './type/helpers/index.mjs';
|
|
5
|
+
export * from './type/patterns/index.mjs';
|
|
6
|
+
export * from './type/registry/index.mjs';
|
|
7
|
+
export * from './type/sets/index.mjs';
|
|
8
|
+
export * from './type/symbols/index.mjs';
|
|
9
|
+
export * from './type/any/index.mjs';
|
|
10
|
+
export * from './type/array/index.mjs';
|
|
11
|
+
export * from './type/async-iterator/index.mjs';
|
|
12
|
+
export * from './type/awaited/index.mjs';
|
|
13
|
+
export * from './type/bigint/index.mjs';
|
|
14
|
+
export * from './type/boolean/index.mjs';
|
|
15
|
+
export * from './type/composite/index.mjs';
|
|
16
|
+
export * from './type/const/index.mjs';
|
|
17
|
+
export * from './type/constructor/index.mjs';
|
|
18
|
+
export * from './type/constructor-parameters/index.mjs';
|
|
19
|
+
export * from './type/date/index.mjs';
|
|
20
|
+
export * from './type/deref/index.mjs';
|
|
21
|
+
export * from './type/enum/index.mjs';
|
|
22
|
+
export * from './type/exclude/index.mjs';
|
|
23
|
+
export * from './type/extends/index.mjs';
|
|
24
|
+
export * from './type/extract/index.mjs';
|
|
25
|
+
export * from './type/function/index.mjs';
|
|
26
|
+
export * from './type/indexed/index.mjs';
|
|
27
|
+
export * from './type/instance-type/index.mjs';
|
|
28
|
+
export * from './type/integer/index.mjs';
|
|
29
|
+
export * from './type/intersect/index.mjs';
|
|
30
|
+
export * from './type/iterator/index.mjs';
|
|
31
|
+
export * from './type/intrinsic/index.mjs';
|
|
32
|
+
export * from './type/keyof/index.mjs';
|
|
33
|
+
export * from './type/literal/index.mjs';
|
|
34
|
+
export * from './type/mapped/index.mjs';
|
|
35
|
+
export * from './type/never/index.mjs';
|
|
36
|
+
export * from './type/not/index.mjs';
|
|
37
|
+
export * from './type/null/index.mjs';
|
|
38
|
+
export * from './type/number/index.mjs';
|
|
39
|
+
export * from './type/object/index.mjs';
|
|
40
|
+
export * from './type/omit/index.mjs';
|
|
41
|
+
export * from './type/optional/index.mjs';
|
|
42
|
+
export * from './type/parameters/index.mjs';
|
|
43
|
+
export * from './type/partial/index.mjs';
|
|
44
|
+
export * from './type/pick/index.mjs';
|
|
45
|
+
export * from './type/promise/index.mjs';
|
|
46
|
+
export * from './type/readonly/index.mjs';
|
|
47
|
+
export * from './type/readonly-optional/index.mjs';
|
|
48
|
+
export * from './type/record/index.mjs';
|
|
49
|
+
export * from './type/recursive/index.mjs';
|
|
50
|
+
export * from './type/ref/index.mjs';
|
|
51
|
+
export * from './type/regexp/index.mjs';
|
|
52
|
+
export * from './type/required/index.mjs';
|
|
53
|
+
export * from './type/rest/index.mjs';
|
|
54
|
+
export * from './type/return-type/index.mjs';
|
|
55
|
+
export * from './type/schema/index.mjs';
|
|
56
|
+
export * from './type/static/index.mjs';
|
|
57
|
+
export * from './type/strict/index.mjs';
|
|
58
|
+
export * from './type/string/index.mjs';
|
|
59
|
+
export * from './type/symbol/index.mjs';
|
|
60
|
+
export * from './type/template-literal/index.mjs';
|
|
61
|
+
export * from './type/transform/index.mjs';
|
|
62
|
+
export * from './type/tuple/index.mjs';
|
|
63
|
+
export * from './type/uint8array/index.mjs';
|
|
64
|
+
export * from './type/undefined/index.mjs';
|
|
65
|
+
export * from './type/union/index.mjs';
|
|
66
|
+
export * from './type/unknown/index.mjs';
|
|
67
|
+
export * from './type/unsafe/index.mjs';
|
|
68
|
+
export * from './type/void/index.mjs';
|
|
69
|
+
export * from './type/type/index.mjs';
|
package/build/import/index.mjs
CHANGED
|
@@ -1,85 +1,78 @@
|
|
|
1
1
|
// ------------------------------------------------------------------
|
|
2
2
|
// Infrastructure
|
|
3
3
|
// ------------------------------------------------------------------
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export
|
|
8
|
-
export
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
export { TypeBoxError } from './type/error/index.mjs';
|
|
13
|
-
// ------------------------------------------------------------------
|
|
14
|
-
// Sets
|
|
15
|
-
// ------------------------------------------------------------------
|
|
16
|
-
export { SetComplement, SetDistinct, SetIncludes, SetIntersect, SetIntersectMany, SetIsSubset, SetUnion, SetUnionMany, } from './type/sets/index.mjs';
|
|
17
|
-
// ------------------------------------------------------------------
|
|
18
|
-
// Helpers
|
|
19
|
-
// ------------------------------------------------------------------
|
|
20
|
-
export { Increment } from './type/helpers/index.mjs';
|
|
4
|
+
export * from './type/clone/index.mjs';
|
|
5
|
+
export * from './type/error/index.mjs';
|
|
6
|
+
export * from './type/guard/index.mjs';
|
|
7
|
+
export * from './type/helpers/index.mjs';
|
|
8
|
+
export * from './type/patterns/index.mjs';
|
|
9
|
+
export * from './type/registry/index.mjs';
|
|
10
|
+
export * from './type/sets/index.mjs';
|
|
11
|
+
export * from './type/symbols/index.mjs';
|
|
21
12
|
// ------------------------------------------------------------------
|
|
22
13
|
// Types
|
|
23
14
|
// ------------------------------------------------------------------
|
|
24
|
-
export
|
|
25
|
-
export
|
|
26
|
-
export
|
|
27
|
-
export
|
|
28
|
-
export
|
|
29
|
-
export
|
|
30
|
-
export
|
|
31
|
-
export
|
|
32
|
-
export
|
|
33
|
-
export
|
|
34
|
-
export
|
|
35
|
-
export
|
|
36
|
-
export
|
|
37
|
-
export
|
|
38
|
-
export
|
|
39
|
-
export
|
|
40
|
-
export
|
|
41
|
-
export
|
|
42
|
-
export
|
|
43
|
-
export
|
|
44
|
-
export
|
|
45
|
-
export
|
|
46
|
-
export
|
|
47
|
-
export
|
|
48
|
-
export
|
|
49
|
-
export
|
|
50
|
-
export
|
|
51
|
-
export
|
|
52
|
-
export
|
|
53
|
-
export
|
|
54
|
-
export
|
|
55
|
-
export
|
|
56
|
-
export
|
|
57
|
-
export
|
|
58
|
-
export
|
|
59
|
-
export
|
|
60
|
-
export
|
|
61
|
-
export
|
|
62
|
-
export
|
|
63
|
-
export
|
|
64
|
-
export
|
|
65
|
-
export
|
|
66
|
-
export
|
|
67
|
-
export
|
|
68
|
-
export
|
|
69
|
-
export
|
|
70
|
-
export
|
|
71
|
-
export
|
|
72
|
-
export
|
|
73
|
-
export
|
|
74
|
-
export
|
|
75
|
-
export
|
|
76
|
-
export
|
|
77
|
-
export
|
|
78
|
-
export
|
|
79
|
-
export
|
|
80
|
-
export
|
|
81
|
-
export
|
|
15
|
+
export * from './type/any/index.mjs';
|
|
16
|
+
export * from './type/array/index.mjs';
|
|
17
|
+
export * from './type/async-iterator/index.mjs';
|
|
18
|
+
export * from './type/awaited/index.mjs';
|
|
19
|
+
export * from './type/bigint/index.mjs';
|
|
20
|
+
export * from './type/boolean/index.mjs';
|
|
21
|
+
export * from './type/composite/index.mjs';
|
|
22
|
+
export * from './type/const/index.mjs';
|
|
23
|
+
export * from './type/constructor/index.mjs';
|
|
24
|
+
export * from './type/constructor-parameters/index.mjs';
|
|
25
|
+
export * from './type/date/index.mjs';
|
|
26
|
+
export * from './type/deref/index.mjs';
|
|
27
|
+
export * from './type/enum/index.mjs';
|
|
28
|
+
export * from './type/exclude/index.mjs';
|
|
29
|
+
export * from './type/extends/index.mjs';
|
|
30
|
+
export * from './type/extract/index.mjs';
|
|
31
|
+
export * from './type/function/index.mjs';
|
|
32
|
+
export * from './type/indexed/index.mjs';
|
|
33
|
+
export * from './type/instance-type/index.mjs';
|
|
34
|
+
export * from './type/integer/index.mjs';
|
|
35
|
+
export * from './type/intersect/index.mjs';
|
|
36
|
+
export * from './type/iterator/index.mjs';
|
|
37
|
+
export * from './type/intrinsic/index.mjs';
|
|
38
|
+
export * from './type/keyof/index.mjs';
|
|
39
|
+
export * from './type/literal/index.mjs';
|
|
40
|
+
export * from './type/mapped/index.mjs';
|
|
41
|
+
export * from './type/never/index.mjs';
|
|
42
|
+
export * from './type/not/index.mjs';
|
|
43
|
+
export * from './type/null/index.mjs';
|
|
44
|
+
export * from './type/number/index.mjs';
|
|
45
|
+
export * from './type/object/index.mjs';
|
|
46
|
+
export * from './type/omit/index.mjs';
|
|
47
|
+
export * from './type/optional/index.mjs';
|
|
48
|
+
export * from './type/parameters/index.mjs';
|
|
49
|
+
export * from './type/partial/index.mjs';
|
|
50
|
+
export * from './type/pick/index.mjs';
|
|
51
|
+
export * from './type/promise/index.mjs';
|
|
52
|
+
export * from './type/readonly/index.mjs';
|
|
53
|
+
export * from './type/readonly-optional/index.mjs';
|
|
54
|
+
export * from './type/record/index.mjs';
|
|
55
|
+
export * from './type/recursive/index.mjs';
|
|
56
|
+
export * from './type/ref/index.mjs';
|
|
57
|
+
export * from './type/regexp/index.mjs';
|
|
58
|
+
export * from './type/required/index.mjs';
|
|
59
|
+
export * from './type/rest/index.mjs';
|
|
60
|
+
export * from './type/return-type/index.mjs';
|
|
61
|
+
export * from './type/schema/index.mjs';
|
|
62
|
+
export * from './type/static/index.mjs';
|
|
63
|
+
export * from './type/strict/index.mjs';
|
|
64
|
+
export * from './type/string/index.mjs';
|
|
65
|
+
export * from './type/symbol/index.mjs';
|
|
66
|
+
export * from './type/template-literal/index.mjs';
|
|
67
|
+
export * from './type/transform/index.mjs';
|
|
68
|
+
export * from './type/tuple/index.mjs';
|
|
69
|
+
export * from './type/uint8array/index.mjs';
|
|
70
|
+
export * from './type/undefined/index.mjs';
|
|
71
|
+
export * from './type/union/index.mjs';
|
|
72
|
+
export * from './type/unknown/index.mjs';
|
|
73
|
+
export * from './type/unsafe/index.mjs';
|
|
74
|
+
export * from './type/void/index.mjs';
|
|
82
75
|
// ------------------------------------------------------------------
|
|
83
76
|
// Namespace
|
|
84
77
|
// ------------------------------------------------------------------
|
|
85
|
-
export
|
|
78
|
+
export * from './type/type/index.mjs';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
1
|
+
export * from './policy.mjs';
|
|
2
|
+
export * from './system.mjs';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
1
|
+
export * from './policy.mjs';
|
|
2
|
+
export * from './system.mjs';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export *
|
|
2
|
-
export *
|
|
1
|
+
export * from './type.mjs';
|
|
2
|
+
export * from './value.mjs';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export *
|
|
2
|
-
export *
|
|
1
|
+
export * from './type.mjs';
|
|
2
|
+
export * from './value.mjs';
|
|
@@ -11,7 +11,7 @@ import { Readonly } from '../readonly/index.mjs';
|
|
|
11
11
|
import { Undefined } from '../undefined/index.mjs';
|
|
12
12
|
import { Uint8Array } from '../uint8array/index.mjs';
|
|
13
13
|
import { Unknown } from '../unknown/index.mjs';
|
|
14
|
-
import {
|
|
14
|
+
import { CloneType } from '../clone/index.mjs';
|
|
15
15
|
// ------------------------------------------------------------------
|
|
16
16
|
// ValueGuard
|
|
17
17
|
// ------------------------------------------------------------------
|
|
@@ -49,5 +49,5 @@ function FromValue(value, root) {
|
|
|
49
49
|
}
|
|
50
50
|
/** `[JavaScript]` Creates a readonly const type from the given value. */
|
|
51
51
|
export function Const(T, options = {}) {
|
|
52
|
-
return
|
|
52
|
+
return CloneType(FromValue(T, true), options);
|
|
53
53
|
}
|
|
@@ -38,7 +38,7 @@ export interface TObject<T extends TProperties = TProperties> extends TSchema, O
|
|
|
38
38
|
required?: string[];
|
|
39
39
|
}
|
|
40
40
|
/** `[Json]` Creates an Object type */
|
|
41
|
-
|
|
41
|
+
declare function _Object<T extends TProperties>(properties: T, options?: ObjectOptions): TObject<T>;
|
|
42
42
|
/** `[Json]` Creates an Object type */
|
|
43
43
|
export declare const Object: typeof _Object;
|
|
44
44
|
export {};
|
|
@@ -5,7 +5,7 @@ import { Kind } from '../symbols/index.mjs';
|
|
|
5
5
|
// ------------------------------------------------------------------
|
|
6
6
|
import { IsOptional, IsSchema } from '../guard/type.mjs';
|
|
7
7
|
/** `[Json]` Creates an Object type */
|
|
8
|
-
|
|
8
|
+
function _Object(properties, options = {}) {
|
|
9
9
|
const propertyKeys = globalThis.Object.getOwnPropertyNames(properties);
|
|
10
10
|
const optionalKeys = propertyKeys.filter((key) => IsOptional(properties[key]));
|
|
11
11
|
const requiredKeys = propertyKeys.filter((name) => !optionalKeys.includes(name));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IsStandardObject, IsArray, IsString, IsNumber, IsNull } from '../guard/index.mjs';
|
|
2
2
|
import { TypeBoxError } from '../../type/error/index.mjs';
|
|
3
3
|
import { Kind } from '../../type/symbols/index.mjs';
|
|
4
4
|
import { Create } from '../create/index.mjs';
|
|
@@ -100,7 +100,7 @@ function FromConstructor(schema, references, value) {
|
|
|
100
100
|
}
|
|
101
101
|
function FromIntersect(schema, references, value) {
|
|
102
102
|
const created = Create(schema, references);
|
|
103
|
-
const mapped =
|
|
103
|
+
const mapped = IsStandardObject(created) && IsStandardObject(value) ? { ...created, ...value } : value;
|
|
104
104
|
return Check(schema, references, mapped) ? mapped : Create(schema, references);
|
|
105
105
|
}
|
|
106
106
|
function FromNever(schema, references, value) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// ------------------------------------------------------------------
|
|
2
2
|
// ValueGuard
|
|
3
3
|
// ------------------------------------------------------------------
|
|
4
|
-
import { IsArray, IsDate,
|
|
4
|
+
import { IsArray, IsDate, IsStandardObject, IsTypedArray, IsValueType } from '../guard/index.mjs';
|
|
5
5
|
// ------------------------------------------------------------------
|
|
6
6
|
// Clonable
|
|
7
7
|
// ------------------------------------------------------------------
|
|
@@ -30,7 +30,7 @@ export function Clone(value) {
|
|
|
30
30
|
return ArrayType(value);
|
|
31
31
|
if (IsDate(value))
|
|
32
32
|
return DateType(value);
|
|
33
|
-
if (
|
|
33
|
+
if (IsStandardObject(value))
|
|
34
34
|
return ObjectType(value);
|
|
35
35
|
if (IsTypedArray(value))
|
|
36
36
|
return TypedArrayType(value);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IsStandardObject, IsArray, IsTypedArray, IsValueType, IsSymbol, IsUndefined } from '../guard/index.mjs';
|
|
2
2
|
import { ValuePointer } from '../pointer/index.mjs';
|
|
3
3
|
import { Clone } from '../clone/index.mjs';
|
|
4
4
|
import { TypeBoxError } from '../../type/error/index.mjs';
|
|
@@ -55,7 +55,7 @@ function CreateDelete(path) {
|
|
|
55
55
|
// Diffing Generators
|
|
56
56
|
// ------------------------------------------------------------------
|
|
57
57
|
function* ObjectType(path, current, next) {
|
|
58
|
-
if (!
|
|
58
|
+
if (!IsStandardObject(next))
|
|
59
59
|
return yield CreateUpdate(path, next);
|
|
60
60
|
const currentKeys = [...globalThis.Object.keys(current), ...globalThis.Object.getOwnPropertySymbols(current)];
|
|
61
61
|
const nextKeys = [...globalThis.Object.keys(next), ...globalThis.Object.getOwnPropertySymbols(next)];
|
|
@@ -115,7 +115,7 @@ function* ValueType(path, current, next) {
|
|
|
115
115
|
yield CreateUpdate(path, next);
|
|
116
116
|
}
|
|
117
117
|
function* Visit(path, current, next) {
|
|
118
|
-
if (
|
|
118
|
+
if (IsStandardObject(current))
|
|
119
119
|
return yield* ObjectType(path, current, next);
|
|
120
120
|
if (IsArray(current))
|
|
121
121
|
return yield* ArrayType(path, current, next);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IsStandardObject, IsDate, IsArray, IsTypedArray, IsValueType } from '../guard/index.mjs';
|
|
2
2
|
// ------------------------------------------------------------------
|
|
3
3
|
// Equality Checks
|
|
4
4
|
// ------------------------------------------------------------------
|
|
5
5
|
function ObjectType(left, right) {
|
|
6
|
-
if (!
|
|
6
|
+
if (!IsStandardObject(right))
|
|
7
7
|
return false;
|
|
8
8
|
const leftKeys = [...Object.keys(left), ...Object.getOwnPropertySymbols(left)];
|
|
9
9
|
const rightKeys = [...Object.keys(right), ...Object.getOwnPropertySymbols(right)];
|
|
@@ -32,7 +32,7 @@ function ValueType(left, right) {
|
|
|
32
32
|
// ------------------------------------------------------------------
|
|
33
33
|
/** Returns true if the left value deep-equals the right */
|
|
34
34
|
export function Equal(left, right) {
|
|
35
|
-
if (
|
|
35
|
+
if (IsStandardObject(left))
|
|
36
36
|
return ObjectType(left, right);
|
|
37
37
|
if (IsDate(left))
|
|
38
38
|
return DateType(left, right);
|
|
@@ -6,18 +6,46 @@ export type TypedArrayType = Int8Array | Uint8Array | Uint8ClampedArray | Int16A
|
|
|
6
6
|
export declare function IsAsyncIterator(value: unknown): value is AsyncIterableIterator<any>;
|
|
7
7
|
/** Returns true if this value is an iterator */
|
|
8
8
|
export declare function IsIterator(value: unknown): value is IterableIterator<any>;
|
|
9
|
-
/** Returns true if this value is a
|
|
10
|
-
export declare function
|
|
9
|
+
/** Returns true if this value is not an instance of a class */
|
|
10
|
+
export declare function IsStandardObject(value: unknown): value is ObjectType;
|
|
11
|
+
/** Returns true if this value is an instance of a class */
|
|
12
|
+
export declare function IsInstanceObject(value: unknown): value is ObjectType;
|
|
11
13
|
/** Returns true if this value is a Promise */
|
|
12
14
|
export declare function IsPromise(value: unknown): value is Promise<unknown>;
|
|
13
|
-
/** Returns true if the value is a Uint8Array */
|
|
14
|
-
export declare function IsUint8Array(value: unknown): value is Uint8Array;
|
|
15
15
|
/** Returns true if this value is a Date */
|
|
16
16
|
export declare function IsDate(value: unknown): value is Date;
|
|
17
|
+
/** Returns true if this value is an instance of Map<K, T> */
|
|
18
|
+
export declare function IsMap(value: unknown): value is Map<unknown, unknown>;
|
|
19
|
+
/** Returns true if this value is an instance of Set<T> */
|
|
20
|
+
export declare function IsSet(value: unknown): value is Set<unknown>;
|
|
21
|
+
/** Returns true if this value is RegExp */
|
|
22
|
+
export declare function IsRegExp(value: unknown): value is RegExp;
|
|
23
|
+
/** Returns true if this value is a typed array */
|
|
24
|
+
export declare function IsTypedArray(value: unknown): value is TypedArrayType;
|
|
25
|
+
/** Returns true if the value is a Int8Array */
|
|
26
|
+
export declare function IsInt8Array(value: unknown): value is Int8Array;
|
|
27
|
+
/** Returns true if the value is a Uint8Array */
|
|
28
|
+
export declare function IsUint8Array(value: unknown): value is Uint8Array;
|
|
29
|
+
/** Returns true if the value is a Uint8ClampedArray */
|
|
30
|
+
export declare function IsUint8ClampedArray(value: unknown): value is Uint8ClampedArray;
|
|
31
|
+
/** Returns true if the value is a Int16Array */
|
|
32
|
+
export declare function IsInt16Array(value: unknown): value is Int16Array;
|
|
33
|
+
/** Returns true if the value is a Uint16Array */
|
|
34
|
+
export declare function IsUint16Array(value: unknown): value is Uint16Array;
|
|
35
|
+
/** Returns true if the value is a Int32Array */
|
|
36
|
+
export declare function IsInt32Array(value: unknown): value is Int32Array;
|
|
37
|
+
/** Returns true if the value is a Uint32Array */
|
|
38
|
+
export declare function IsUint32Array(value: unknown): value is Uint32Array;
|
|
39
|
+
/** Returns true if the value is a Float32Array */
|
|
40
|
+
export declare function IsFloat32Array(value: unknown): value is Float32Array;
|
|
41
|
+
/** Returns true if the value is a Float64Array */
|
|
42
|
+
export declare function IsFloat64Array(value: unknown): value is Float64Array;
|
|
43
|
+
/** Returns true if the value is a BigInt64Array */
|
|
44
|
+
export declare function IsBigInt64Array(value: unknown): value is BigInt64Array;
|
|
45
|
+
/** Returns true if the value is a BigUint64Array */
|
|
46
|
+
export declare function IsBigUint64Array(value: unknown): value is BigUint64Array;
|
|
17
47
|
/** Returns true if this value has this property key */
|
|
18
48
|
export declare function HasPropertyKey<K extends PropertyKey>(value: Record<any, unknown>, key: K): value is ObjectType & Record<K, unknown>;
|
|
19
|
-
/** Returns true if this object is not an instance of any other type */
|
|
20
|
-
export declare function IsPlainObject(value: unknown): value is ObjectType;
|
|
21
49
|
/** Returns true of this value is an object type */
|
|
22
50
|
export declare function IsObject(value: unknown): value is ObjectType;
|
|
23
51
|
/** Returns true if this value is an array, but not a typed array */
|