@sinclair/typebox 0.24.50 → 0.25.0
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/compiler/compiler.d.ts +1 -1
- package/compiler/compiler.js +15 -2
- package/conditional/structural.js +23 -0
- package/errors/errors.d.ts +43 -38
- package/errors/errors.js +62 -38
- package/guard/guard.d.ts +2 -0
- package/guard/guard.js +96 -14
- package/package.json +1 -1
- package/readme.md +245 -161
- package/typebox.d.ts +68 -49
- package/typebox.js +48 -43
- package/value/cast.js +6 -1
- package/value/check.js +21 -1
- package/value/clone.js +10 -4
- package/value/create.js +13 -0
- package/value/delta.js +8 -0
- package/value/equal.js +6 -0
- package/value/is.d.ts +1 -0
- package/value/is.js +5 -1
package/value/equal.js
CHANGED
|
@@ -40,6 +40,9 @@ var ValueEqual;
|
|
|
40
40
|
return false;
|
|
41
41
|
return leftKeys.every((key) => Equal(left[key], right[key]));
|
|
42
42
|
}
|
|
43
|
+
function Date(left, right) {
|
|
44
|
+
return is_1.Is.Date(right) && left.getTime() === right.getTime();
|
|
45
|
+
}
|
|
43
46
|
function Array(left, right) {
|
|
44
47
|
if (!is_1.Is.Array(right) || left.length !== right.length)
|
|
45
48
|
return false;
|
|
@@ -57,6 +60,9 @@ var ValueEqual;
|
|
|
57
60
|
if (is_1.Is.Object(left)) {
|
|
58
61
|
return Object(left, right);
|
|
59
62
|
}
|
|
63
|
+
else if (is_1.Is.Date(left)) {
|
|
64
|
+
return Date(left, right);
|
|
65
|
+
}
|
|
60
66
|
else if (is_1.Is.TypedArray(left)) {
|
|
61
67
|
return TypedArray(left, right);
|
|
62
68
|
}
|
package/value/is.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export declare type TypedArrayType = Int8Array | Uint8Array | Uint8ClampedArray
|
|
|
4
4
|
export declare type ArrayType = unknown[];
|
|
5
5
|
export declare namespace Is {
|
|
6
6
|
function Object(value: unknown): value is ObjectType;
|
|
7
|
+
function Date(value: unknown): value is Date;
|
|
7
8
|
function Array(value: unknown): value is ArrayType;
|
|
8
9
|
function Value(value: unknown): value is ValueType;
|
|
9
10
|
function TypedArray(value: unknown): value is TypedArrayType;
|
package/value/is.js
CHANGED
|
@@ -31,9 +31,13 @@ exports.Is = void 0;
|
|
|
31
31
|
var Is;
|
|
32
32
|
(function (Is) {
|
|
33
33
|
function Object(value) {
|
|
34
|
-
return value !== null && typeof value === 'object' && !globalThis.Array.isArray(value) && !ArrayBuffer.isView(value);
|
|
34
|
+
return value !== null && typeof value === 'object' && !globalThis.Array.isArray(value) && !ArrayBuffer.isView(value) && !(value instanceof globalThis.Date);
|
|
35
35
|
}
|
|
36
36
|
Is.Object = Object;
|
|
37
|
+
function Date(value) {
|
|
38
|
+
return value instanceof globalThis.Date;
|
|
39
|
+
}
|
|
40
|
+
Is.Date = Date;
|
|
37
41
|
function Array(value) {
|
|
38
42
|
return globalThis.Array.isArray(value) && !ArrayBuffer.isView(value);
|
|
39
43
|
}
|