@sinclair/typebox 0.25.9 → 0.25.11
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 +36 -27
- package/conditional/conditional.d.ts +1 -1
- package/conditional/structural.js +2 -2
- package/custom/custom.d.ts +8 -8
- package/custom/custom.js +5 -5
- package/errors/errors.js +14 -4
- package/format/format.d.ts +6 -6
- package/format/format.js +5 -5
- package/guard/guard.d.ts +2 -2
- package/guard/guard.js +4 -4
- package/hash/hash.d.ts +8 -0
- package/hash/hash.js +183 -0
- package/hash/index.d.ts +1 -0
- package/hash/index.js +44 -0
- package/package.json +5 -4
- package/readme.md +82 -64
- package/typebox.d.ts +36 -36
- package/value/cast.js +2 -2
- package/value/check.js +15 -5
- package/value/create.js +3 -3
- package/value/delta.d.ts +4 -4
- package/value/index.d.ts +1 -0
- package/value/index.js +6 -1
- package/value/is.d.ts +4 -4
- package/value/value.d.ts +4 -3
- package/value/value.js +12 -11
package/value/value.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as Types from '../typebox';
|
|
2
2
|
import { ValueError } from '../errors/index';
|
|
3
3
|
import { Edit } from './delta';
|
|
4
|
-
export { Edit, Insert, Update, Delete } from './delta';
|
|
5
4
|
/** Provides functions to perform structural updates to JavaScript values */
|
|
6
5
|
export declare namespace Value {
|
|
7
6
|
/** Casts a value into a given type. The return value will retain as much information of the original value as possible. Cast will convert string, number and boolean values if a reasonable conversion is possible. */
|
|
@@ -16,16 +15,18 @@ export declare namespace Value {
|
|
|
16
15
|
function Check<T extends Types.TSchema, R extends Types.TSchema[]>(schema: T, references: [...R], value: unknown): value is Types.Static<T>;
|
|
17
16
|
/** Returns true if the value matches the given type. */
|
|
18
17
|
function Check<T extends Types.TSchema>(schema: T, value: unknown): value is Types.Static<T>;
|
|
18
|
+
/** Returns a structural clone of the given value */
|
|
19
|
+
function Clone<T>(value: T): T;
|
|
19
20
|
/** Returns an iterator for each error in this value. */
|
|
20
21
|
function Errors<T extends Types.TSchema, R extends Types.TSchema[]>(schema: T, references: [...R], value: unknown): IterableIterator<ValueError>;
|
|
21
22
|
/** Returns an iterator for each error in this value. */
|
|
22
23
|
function Errors<T extends Types.TSchema>(schema: T, value: unknown): IterableIterator<ValueError>;
|
|
23
24
|
/** Returns true if left and right values are structurally equal */
|
|
24
25
|
function Equal<T>(left: T, right: unknown): right is T;
|
|
25
|
-
/** Returns a structural clone of the given value */
|
|
26
|
-
function Clone<T>(value: T): T;
|
|
27
26
|
/** Returns edits to transform the current value into the next value */
|
|
28
27
|
function Diff(current: unknown, next: unknown): Edit[];
|
|
28
|
+
/** Returns a FNV1A-64 non cryptographic hash of the given value */
|
|
29
|
+
function Hash(value: unknown): bigint;
|
|
29
30
|
/** Returns a new value with edits applied to the given value */
|
|
30
31
|
function Patch<T = any>(current: unknown, edits: Edit[]): T;
|
|
31
32
|
}
|
package/value/value.js
CHANGED
|
@@ -27,19 +27,15 @@ THE SOFTWARE.
|
|
|
27
27
|
|
|
28
28
|
---------------------------------------------------------------------------*/
|
|
29
29
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
-
exports.Value =
|
|
30
|
+
exports.Value = void 0;
|
|
31
31
|
const index_1 = require("../errors/index");
|
|
32
|
+
const index_2 = require("../hash/index");
|
|
32
33
|
const equal_1 = require("./equal");
|
|
33
34
|
const cast_1 = require("./cast");
|
|
34
35
|
const clone_1 = require("./clone");
|
|
35
36
|
const create_1 = require("./create");
|
|
36
37
|
const check_1 = require("./check");
|
|
37
38
|
const delta_1 = require("./delta");
|
|
38
|
-
var delta_2 = require("./delta");
|
|
39
|
-
Object.defineProperty(exports, "Edit", { enumerable: true, get: function () { return delta_2.Edit; } });
|
|
40
|
-
Object.defineProperty(exports, "Insert", { enumerable: true, get: function () { return delta_2.Insert; } });
|
|
41
|
-
Object.defineProperty(exports, "Update", { enumerable: true, get: function () { return delta_2.Update; } });
|
|
42
|
-
Object.defineProperty(exports, "Delete", { enumerable: true, get: function () { return delta_2.Delete; } });
|
|
43
39
|
/** Provides functions to perform structural updates to JavaScript values */
|
|
44
40
|
var Value;
|
|
45
41
|
(function (Value) {
|
|
@@ -58,6 +54,11 @@ var Value;
|
|
|
58
54
|
return check_1.ValueCheck.Check(schema, references, value);
|
|
59
55
|
}
|
|
60
56
|
Value.Check = Check;
|
|
57
|
+
/** Returns a structural clone of the given value */
|
|
58
|
+
function Clone(value) {
|
|
59
|
+
return clone_1.ValueClone.Clone(value);
|
|
60
|
+
}
|
|
61
|
+
Value.Clone = Clone;
|
|
61
62
|
function* Errors(...args) {
|
|
62
63
|
const [schema, references, value] = args.length === 3 ? [args[0], args[1], args[2]] : [args[0], [], args[1]];
|
|
63
64
|
yield* index_1.ValueErrors.Errors(schema, references, value);
|
|
@@ -68,16 +69,16 @@ var Value;
|
|
|
68
69
|
return equal_1.ValueEqual.Equal(left, right);
|
|
69
70
|
}
|
|
70
71
|
Value.Equal = Equal;
|
|
71
|
-
/** Returns a structural clone of the given value */
|
|
72
|
-
function Clone(value) {
|
|
73
|
-
return clone_1.ValueClone.Clone(value);
|
|
74
|
-
}
|
|
75
|
-
Value.Clone = Clone;
|
|
76
72
|
/** Returns edits to transform the current value into the next value */
|
|
77
73
|
function Diff(current, next) {
|
|
78
74
|
return delta_1.ValueDelta.Diff(current, next);
|
|
79
75
|
}
|
|
80
76
|
Value.Diff = Diff;
|
|
77
|
+
/** Returns a FNV1A-64 non cryptographic hash of the given value */
|
|
78
|
+
function Hash(value) {
|
|
79
|
+
return index_2.ValueHash.Create(value);
|
|
80
|
+
}
|
|
81
|
+
Value.Hash = Hash;
|
|
81
82
|
/** Returns a new value with edits applied to the given value */
|
|
82
83
|
function Patch(current, edits) {
|
|
83
84
|
return delta_1.ValueDelta.Patch(current, edits);
|