@sinclair/typebox 0.24.32 → 0.24.35

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/value/value.js CHANGED
@@ -29,12 +29,20 @@ THE SOFTWARE.
29
29
  Object.defineProperty(exports, "__esModule", { value: true });
30
30
  exports.Value = void 0;
31
31
  const index_1 = require("../errors/index");
32
+ const equal_1 = require("./equal");
32
33
  const cast_1 = require("./cast");
34
+ const clone_1 = require("./clone");
33
35
  const create_1 = require("./create");
34
36
  const check_1 = require("./check");
35
- /** Creates Values from TypeBox Types */
37
+ const delta_1 = require("./delta");
38
+ /** The Value namespace provides type operations on values */
36
39
  var Value;
37
40
  (function (Value) {
41
+ function Cast(...args) {
42
+ const [schema, references, value] = args.length === 3 ? [args[0], args[1], args[2]] : [args[0], [], args[1]];
43
+ return cast_1.ValueCast.Cast(schema, references, value);
44
+ }
45
+ Value.Cast = Cast;
38
46
  function Create(...args) {
39
47
  const [schema, references] = args.length === 2 ? [args[0], args[1]] : [args[0], []];
40
48
  return create_1.ValueCreate.Create(schema, references);
@@ -45,14 +53,29 @@ var Value;
45
53
  return check_1.ValueCheck.Check(schema, references, value);
46
54
  }
47
55
  Value.Check = Check;
48
- function Cast(...args) {
49
- const [schema, references, value] = args.length === 3 ? [args[0], args[1], args[2]] : [args[0], [], args[1]];
50
- return cast_1.ValueCast.Cast(schema, references, value);
51
- }
52
- Value.Cast = Cast;
53
56
  function* Errors(...args) {
54
57
  const [schema, references, value] = args.length === 3 ? [args[0], args[1], args[2]] : [args[0], [], args[1]];
55
58
  yield* index_1.ValueErrors.Errors(schema, references, value);
56
59
  }
57
60
  Value.Errors = Errors;
61
+ /** Returns true if left and right values are structurally equal */
62
+ function Equal(left, right) {
63
+ return equal_1.ValueEqual.Equal(left, right);
64
+ }
65
+ Value.Equal = Equal;
66
+ /** Returns a structural clone of the given value */
67
+ function Clone(value) {
68
+ return clone_1.ValueClone.Clone(value);
69
+ }
70
+ Value.Clone = Clone;
71
+ /** Returns edits to transform the current value into the next value */
72
+ function Diff(current, next) {
73
+ return delta_1.ValueDelta.Diff(current, next);
74
+ }
75
+ Value.Diff = Diff;
76
+ /** Returns a new value with edits applied to the given value */
77
+ function Patch(current, edits) {
78
+ return delta_1.ValueDelta.Patch(current, edits);
79
+ }
80
+ Value.Patch = Patch;
58
81
  })(Value = exports.Value || (exports.Value = {}));