@sinclair/typebox 0.23.3 → 0.24.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 +31 -0
- package/compiler/compiler.js +349 -0
- package/compiler/index.d.ts +1 -0
- package/compiler/index.js +40 -0
- package/license +1 -1
- package/package.json +14 -14
- package/readme.md +377 -361
- package/typebox.d.ts +315 -294
- package/typebox.js +247 -260
- package/value/check.d.ts +5 -0
- package/value/check.js +232 -0
- package/value/clone.d.ts +3 -0
- package/value/clone.js +94 -0
- package/value/create.d.ts +7 -0
- package/value/create.js +337 -0
- package/value/delta.d.ts +13 -0
- package/value/delta.js +191 -0
- package/value/index.d.ts +1 -0
- package/value/index.js +40 -0
- package/value/pointer.d.ts +12 -0
- package/value/pointer.js +110 -0
- package/value/reflect.d.ts +2 -0
- package/value/reflect.js +42 -0
- package/value/upcast.d.ts +4 -0
- package/value/upcast.js +247 -0
- package/value/value.d.ts +17 -0
- package/value/value.js +70 -0
package/value/value.js
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*--------------------------------------------------------------------------
|
|
3
|
+
|
|
4
|
+
@sinclair/typebox
|
|
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.Value = exports.EditType = void 0;
|
|
31
|
+
const create_1 = require("./create");
|
|
32
|
+
const check_1 = require("./check");
|
|
33
|
+
const clone_1 = require("./clone");
|
|
34
|
+
const delta_1 = require("./delta");
|
|
35
|
+
const upcast_1 = require("./upcast");
|
|
36
|
+
var delta_2 = require("./delta");
|
|
37
|
+
Object.defineProperty(exports, "EditType", { enumerable: true, get: function () { return delta_2.EditType; } });
|
|
38
|
+
var Value;
|
|
39
|
+
(function (Value) {
|
|
40
|
+
/** Returns true if the value conforms to the given schema */
|
|
41
|
+
function Check(schema, value) {
|
|
42
|
+
return check_1.CheckValue.Check(schema, value);
|
|
43
|
+
}
|
|
44
|
+
Value.Check = Check;
|
|
45
|
+
/** Returns a deep clone of the given value */
|
|
46
|
+
function Clone(value) {
|
|
47
|
+
return clone_1.CloneValue.Create(value);
|
|
48
|
+
}
|
|
49
|
+
Value.Clone = Clone;
|
|
50
|
+
/** Creates a value from the given schema type */
|
|
51
|
+
function Create(schema) {
|
|
52
|
+
return create_1.CreateValue.Create(schema);
|
|
53
|
+
}
|
|
54
|
+
Value.Create = Create;
|
|
55
|
+
/** Diffs the value and produces edits to transform the value into the next value */
|
|
56
|
+
function Diff(value, next) {
|
|
57
|
+
return delta_1.DeltaValue.Diff(value, next);
|
|
58
|
+
}
|
|
59
|
+
Value.Diff = Diff;
|
|
60
|
+
/** Patches a value by applying a series of edits */
|
|
61
|
+
function Patch(value, edits) {
|
|
62
|
+
return delta_1.DeltaValue.Edit(value, edits);
|
|
63
|
+
}
|
|
64
|
+
Value.Patch = Patch;
|
|
65
|
+
/** Upcasts a value to match a schema while preserving as much information from the original value as possible. */
|
|
66
|
+
function Upcast(schema, value) {
|
|
67
|
+
return upcast_1.UpcastValue.Create(schema, value);
|
|
68
|
+
}
|
|
69
|
+
Value.Upcast = Upcast;
|
|
70
|
+
})(Value = exports.Value || (exports.Value = {}));
|