seroval 1.7.9 → 1.8.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/dist/dev/index.cjs +58 -3804
- package/dist/dev/index.d.cts +5 -834
- package/dist/dev/index.d.ts +5 -834
- package/dist/dev/index.js +4 -3758
- package/dist/dev/read-Bn_ffmiS.d.ts +14 -0
- package/dist/dev/read-CfSVIjp6.js +455 -0
- package/dist/dev/read-CgzYPh_Q.d.cts +14 -0
- package/dist/dev/read-DvIuZ2yx.cjs +478 -0
- package/dist/dev/read.cjs +45 -0
- package/dist/dev/read.d.cts +17 -0
- package/dist/dev/read.d.ts +17 -0
- package/dist/dev/read.js +3 -0
- package/dist/dev/shared-Cf-Bmoy-.js +1010 -0
- package/dist/dev/shared-DTMVoS-y.d.ts +749 -0
- package/dist/dev/shared-DWx3Bwb6.cjs +1410 -0
- package/dist/dev/shared-Dju99SLx.d.cts +749 -0
- package/dist/dev/shared.cjs +40 -0
- package/dist/dev/shared.d.cts +2 -0
- package/dist/dev/shared.d.ts +2 -0
- package/dist/dev/shared.js +1 -0
- package/dist/dev/typed-array-C3haUQv_.js +72 -0
- package/dist/dev/typed-array-DUH_YsNc.cjs +101 -0
- package/dist/dev/validator-CxDhXc0k.d.cts +28 -0
- package/dist/dev/validator-CxDhXc0k.d.ts +28 -0
- package/dist/dev/validator.cjs +54 -0
- package/dist/dev/validator.d.cts +2 -0
- package/dist/dev/validator.d.ts +2 -0
- package/dist/dev/validator.js +45 -0
- package/dist/dev/write-BKJsV31u.js +2354 -0
- package/dist/dev/write-C0KqlAXN.d.ts +86 -0
- package/dist/dev/write-DGOp2jqo.cjs +2425 -0
- package/dist/dev/write-KxJKA4_p.d.cts +86 -0
- package/dist/dev/write.cjs +54 -0
- package/dist/dev/write.d.cts +4 -0
- package/dist/dev/write.d.ts +4 -0
- package/dist/dev/write.js +3 -0
- package/dist/index.cjs +58 -3788
- package/dist/index.d.cts +5 -834
- package/dist/index.d.ts +5 -834
- package/dist/index.js +4 -3742
- package/dist/read-Bn_ffmiS.d.ts +14 -0
- package/dist/read-CD88YElZ.cjs +478 -0
- package/dist/read-CSKXLr9t.js +455 -0
- package/dist/read-CgzYPh_Q.d.cts +14 -0
- package/dist/read.cjs +45 -0
- package/dist/read.d.cts +17 -0
- package/dist/read.d.ts +17 -0
- package/dist/read.js +3 -0
- package/dist/shared-DJIVyqa9.js +994 -0
- package/dist/shared-DTMVoS-y.d.ts +749 -0
- package/dist/shared-Dju99SLx.d.cts +749 -0
- package/dist/shared-u-KYXAax.cjs +1394 -0
- package/dist/shared.cjs +40 -0
- package/dist/shared.d.cts +2 -0
- package/dist/shared.d.ts +2 -0
- package/dist/shared.js +1 -0
- package/dist/typed-array-BWH0IKxT.js +72 -0
- package/dist/typed-array-BkSwWNFI.cjs +101 -0
- package/dist/validator-CxDhXc0k.d.cts +28 -0
- package/dist/validator-CxDhXc0k.d.ts +28 -0
- package/dist/validator.cjs +54 -0
- package/dist/validator.d.cts +2 -0
- package/dist/validator.d.ts +2 -0
- package/dist/validator.js +45 -0
- package/dist/write-B_hZaAwC.js +2354 -0
- package/dist/write-C0KqlAXN.d.ts +86 -0
- package/dist/write-CMi0CxOu.cjs +2425 -0
- package/dist/write-KxJKA4_p.d.cts +86 -0
- package/dist/write.cjs +54 -0
- package/dist/write.d.cts +4 -0
- package/dist/write.d.ts +4 -0
- package/dist/write.js +3 -0
- package/package.json +97 -1
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_shared = require("./shared-DWx3Bwb6.cjs");
|
|
3
|
+
let src_core_validator = require("./validator.cjs");
|
|
4
|
+
exports.Feature = require_shared.Feature;
|
|
5
|
+
exports.LiveStream = require_shared.LiveStream;
|
|
6
|
+
exports.OpaqueReference = require_shared.OpaqueReference;
|
|
7
|
+
exports.Sequence = require_shared.Sequence;
|
|
8
|
+
exports.SerovalAbortedError = require_shared.SerovalAbortedError;
|
|
9
|
+
exports.SerovalConflictedNodeIdError = require_shared.SerovalConflictedNodeIdError;
|
|
10
|
+
exports.SerovalDepthLimitError = require_shared.SerovalDepthLimitError;
|
|
11
|
+
exports.SerovalDeserializationError = require_shared.SerovalDeserializationError;
|
|
12
|
+
exports.SerovalError = require_shared.SerovalError;
|
|
13
|
+
exports.SerovalLiveStreamError = require_shared.SerovalLiveStreamError;
|
|
14
|
+
exports.SerovalMalformedNodeError = require_shared.SerovalMalformedNodeError;
|
|
15
|
+
exports.SerovalMissingInstanceError = require_shared.SerovalMissingInstanceError;
|
|
16
|
+
exports.SerovalMissingPluginError = require_shared.SerovalMissingPluginError;
|
|
17
|
+
exports.SerovalMissingReferenceError = require_shared.SerovalMissingReferenceError;
|
|
18
|
+
exports.SerovalMissingReferenceForIdError = require_shared.SerovalMissingReferenceForIdError;
|
|
19
|
+
exports.SerovalMode = require_shared.SerovalMode;
|
|
20
|
+
exports.SerovalParserError = require_shared.SerovalParserError;
|
|
21
|
+
exports.SerovalPluginValidationError = require_shared.SerovalPluginValidationError;
|
|
22
|
+
exports.SerovalSerializationError = require_shared.SerovalSerializationError;
|
|
23
|
+
exports.SerovalUnknownTypedArrayError = require_shared.SerovalUnknownTypedArrayError;
|
|
24
|
+
exports.SerovalUnsupportedNodeError = require_shared.SerovalUnsupportedNodeError;
|
|
25
|
+
exports.SerovalUnsupportedTypeError = require_shared.SerovalUnsupportedTypeError;
|
|
26
|
+
exports.Stream = require_shared.Stream;
|
|
27
|
+
exports.createLiveStream = require_shared.createLiveStream;
|
|
28
|
+
exports.createPlugin = require_shared.createPlugin;
|
|
29
|
+
exports.createReference = require_shared.createReference;
|
|
30
|
+
exports.createStream = require_shared.createStream;
|
|
31
|
+
exports.getPlainObjectPlugins = require_shared.getPlainObjectPlugins;
|
|
32
|
+
exports.isLiveStream = require_shared.isLiveStream;
|
|
33
|
+
exports.isStream = require_shared.isStream;
|
|
34
|
+
exports.resolvePlugins = require_shared.resolvePlugins;
|
|
35
|
+
Object.defineProperty(exports, "v", {
|
|
36
|
+
enumerable: true,
|
|
37
|
+
get: function() {
|
|
38
|
+
return src_core_validator;
|
|
39
|
+
}
|
|
40
|
+
});
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { A as PluginAccessOptions, C as SerovalUnsupportedTypeError, D as DeserializePluginContext, F as getPlainObjectPlugins, G as LiveStreamOptions, H as LiveStreamConsumer, I as resolvePlugins, J as isLiveStream, K as LiveStreamProducer, L as StreamParsePluginContext, M as PluginInfo, N as SerovalMode, P as createPlugin, Q as isStream, S as SerovalUnsupportedNodeError, U as LiveStreamDelivery, V as LiveStream, W as LiveStreamEvent, X as StreamListener, Y as Stream, Z as createStream, _ as SerovalMissingReferenceForIdError, a as OpaqueReference, b as SerovalSerializationError, c as SerovalConflictedNodeIdError, d as SerovalError, f as SerovalLiveStreamError, g as SerovalMissingReferenceError, h as SerovalMissingPluginError, i as createReference, it as AsyncParsePluginContext, j as PluginData, k as Plugin, l as SerovalDepthLimitError, m as SerovalMissingInstanceError, n as v, nt as SerializePluginContext, o as LiveStreamErrorReason, p as SerovalMalformedNodeError, q as createLiveStream, r as Sequence, s as SerovalAbortedError, st as SerovalNode, t as Validator, u as SerovalDeserializationError, v as SerovalParserError, w as Feature, x as SerovalUnknownTypedArrayError, y as SerovalPluginValidationError, z as SyncParsePluginContext } from "./shared-Dju99SLx.cjs";
|
|
2
|
+
export { type AsyncParsePluginContext, type DeserializePluginContext, Feature, LiveStream, type LiveStreamConsumer, type LiveStreamDelivery, LiveStreamErrorReason, type LiveStreamEvent, type LiveStreamOptions, type LiveStreamProducer, OpaqueReference, Plugin, PluginAccessOptions, PluginData, PluginInfo, Sequence, type SerializePluginContext, SerovalAbortedError, SerovalConflictedNodeIdError, SerovalDepthLimitError, SerovalDeserializationError, SerovalError, SerovalLiveStreamError, SerovalMalformedNodeError, SerovalMissingInstanceError, SerovalMissingPluginError, SerovalMissingReferenceError, SerovalMissingReferenceForIdError, SerovalMode, type SerovalNode, SerovalParserError, SerovalPluginValidationError, SerovalSerializationError, SerovalUnknownTypedArrayError, SerovalUnsupportedNodeError, SerovalUnsupportedTypeError, Stream, type StreamListener, type StreamParsePluginContext, type SyncParsePluginContext, type Validator, createLiveStream, createPlugin, createReference, createStream, getPlainObjectPlugins, isLiveStream, isStream, resolvePlugins, v };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { A as PluginAccessOptions, C as SerovalUnsupportedTypeError, D as DeserializePluginContext, F as getPlainObjectPlugins, G as LiveStreamOptions, H as LiveStreamConsumer, I as resolvePlugins, J as isLiveStream, K as LiveStreamProducer, L as StreamParsePluginContext, M as PluginInfo, N as SerovalMode, P as createPlugin, Q as isStream, S as SerovalUnsupportedNodeError, U as LiveStreamDelivery, V as LiveStream, W as LiveStreamEvent, X as StreamListener, Y as Stream, Z as createStream, _ as SerovalMissingReferenceForIdError, a as OpaqueReference, b as SerovalSerializationError, c as SerovalConflictedNodeIdError, d as SerovalError, f as SerovalLiveStreamError, g as SerovalMissingReferenceError, h as SerovalMissingPluginError, i as createReference, it as AsyncParsePluginContext, j as PluginData, k as Plugin, l as SerovalDepthLimitError, m as SerovalMissingInstanceError, n as v, nt as SerializePluginContext, o as LiveStreamErrorReason, p as SerovalMalformedNodeError, q as createLiveStream, r as Sequence, s as SerovalAbortedError, st as SerovalNode, t as Validator, u as SerovalDeserializationError, v as SerovalParserError, w as Feature, x as SerovalUnknownTypedArrayError, y as SerovalPluginValidationError, z as SyncParsePluginContext } from "./shared-DTMVoS-y.js";
|
|
2
|
+
export { type AsyncParsePluginContext, type DeserializePluginContext, Feature, LiveStream, type LiveStreamConsumer, type LiveStreamDelivery, LiveStreamErrorReason, type LiveStreamEvent, type LiveStreamOptions, type LiveStreamProducer, OpaqueReference, Plugin, PluginAccessOptions, PluginData, PluginInfo, Sequence, type SerializePluginContext, SerovalAbortedError, SerovalConflictedNodeIdError, SerovalDepthLimitError, SerovalDeserializationError, SerovalError, SerovalLiveStreamError, SerovalMalformedNodeError, SerovalMissingInstanceError, SerovalMissingPluginError, SerovalMissingReferenceError, SerovalMissingReferenceForIdError, SerovalMode, type SerovalNode, SerovalParserError, SerovalPluginValidationError, SerovalSerializationError, SerovalUnknownTypedArrayError, SerovalUnsupportedNodeError, SerovalUnsupportedTypeError, Stream, type StreamListener, type StreamParsePluginContext, type SyncParsePluginContext, type Validator, createLiveStream, createPlugin, createReference, createStream, getPlainObjectPlugins, isLiveStream, isStream, resolvePlugins, v };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { tt as Feature, d as LiveStream, n as OpaqueReference, m as Sequence, w as SerovalAbortedError, T as SerovalConflictedNodeIdError, E as SerovalDepthLimitError, D as SerovalDeserializationError, O as SerovalError, k as SerovalLiveStreamError, A as SerovalMalformedNodeError, j as SerovalMissingInstanceError, M as SerovalMissingPluginError, N as SerovalMissingReferenceError, P as SerovalMissingReferenceForIdError, r as SerovalMode, F as SerovalParserError, I as SerovalPluginValidationError, L as SerovalSerializationError, R as SerovalUnknownTypedArrayError, z as SerovalUnsupportedNodeError, B as SerovalUnsupportedTypeError, s as Stream, f as createLiveStream, i as createPlugin, y as createReference, c as createStream, a as getPlainObjectPlugins, p as isLiveStream, l as isStream, o as resolvePlugins, t as v } from "./shared-Cf-Bmoy-.js";
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { R as SerovalUnknownTypedArrayError, nt as ARRAY_BUFFER_CONSTRUCTOR } from "./shared-Cf-Bmoy-.js";
|
|
2
|
+
//#region src/core/binary-browser.ts
|
|
3
|
+
function encodeArrayBuffer$1(current) {
|
|
4
|
+
const bytes = new Uint8Array(current);
|
|
5
|
+
if (typeof bytes.toBase64 === "function") return bytes.toBase64();
|
|
6
|
+
let result = "";
|
|
7
|
+
for (let i = 0, len = bytes.length; i < len; i++) result += String.fromCharCode(bytes[i]);
|
|
8
|
+
return btoa(result);
|
|
9
|
+
}
|
|
10
|
+
//#endregion
|
|
11
|
+
//#region src/core/binary-neutral.ts
|
|
12
|
+
const MIN_NATIVE_BASE64_LENGTH = 512;
|
|
13
|
+
function encodeArrayBuffer(current) {
|
|
14
|
+
if (typeof Buffer !== "undefined") return Buffer.from(current).toString("base64");
|
|
15
|
+
return encodeArrayBuffer$1(current);
|
|
16
|
+
}
|
|
17
|
+
function decodeArrayBuffer(source) {
|
|
18
|
+
if (source.length < MIN_NATIVE_BASE64_LENGTH || typeof Buffer === "undefined") return ARRAY_BUFFER_CONSTRUCTOR(source);
|
|
19
|
+
const decoded = atob(source);
|
|
20
|
+
const buffer = new ArrayBuffer(decoded.length);
|
|
21
|
+
Buffer.from(buffer).write(decoded, "latin1");
|
|
22
|
+
return buffer;
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
//#region src/core/utils/typed-array.ts
|
|
26
|
+
function getTypedArrayConstructor(name) {
|
|
27
|
+
switch (name) {
|
|
28
|
+
case "Int8Array": return Int8Array;
|
|
29
|
+
case "Int16Array": return Int16Array;
|
|
30
|
+
case "Int32Array": return Int32Array;
|
|
31
|
+
case "Uint8Array": return Uint8Array;
|
|
32
|
+
case "Uint16Array": return Uint16Array;
|
|
33
|
+
case "Uint32Array": return Uint32Array;
|
|
34
|
+
case "Uint8ClampedArray": return Uint8ClampedArray;
|
|
35
|
+
case "Float32Array": return Float32Array;
|
|
36
|
+
case "Float64Array": return Float64Array;
|
|
37
|
+
case "BigInt64Array": return BigInt64Array;
|
|
38
|
+
case "BigUint64Array": return BigUint64Array;
|
|
39
|
+
default: throw new SerovalUnknownTypedArrayError(name);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
let typedArrayNameGetter;
|
|
43
|
+
function getTypedArrayName(value) {
|
|
44
|
+
if (!typedArrayNameGetter) typedArrayNameGetter = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Int8Array.prototype), Symbol.toStringTag).get;
|
|
45
|
+
return typedArrayNameGetter.call(value);
|
|
46
|
+
}
|
|
47
|
+
let typedArrayGetters;
|
|
48
|
+
let dataViewGetters;
|
|
49
|
+
function getAccessor(proto, key) {
|
|
50
|
+
return Object.getOwnPropertyDescriptor(proto, key).get;
|
|
51
|
+
}
|
|
52
|
+
function getViewGetters(proto, lengthKey) {
|
|
53
|
+
return {
|
|
54
|
+
buffer: getAccessor(proto, "buffer"),
|
|
55
|
+
byteOffset: getAccessor(proto, "byteOffset"),
|
|
56
|
+
byteLength: getAccessor(proto, "byteLength"),
|
|
57
|
+
length: getAccessor(proto, lengthKey)
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
function readArrayBufferView(value, isDataView) {
|
|
61
|
+
let getters;
|
|
62
|
+
if (isDataView) getters = dataViewGetters ?? (dataViewGetters = getViewGetters(DataView.prototype, "byteLength"));
|
|
63
|
+
else getters = typedArrayGetters ?? (typedArrayGetters = getViewGetters(Object.getPrototypeOf(Int8Array.prototype), "length"));
|
|
64
|
+
return {
|
|
65
|
+
buffer: getters.buffer.call(value),
|
|
66
|
+
byteOffset: getters.byteOffset.call(value),
|
|
67
|
+
byteLength: getters.byteLength.call(value),
|
|
68
|
+
length: getters.length.call(value)
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
//#endregion
|
|
72
|
+
export { encodeArrayBuffer as a, decodeArrayBuffer as i, getTypedArrayName as n, readArrayBufferView as r, getTypedArrayConstructor as t };
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
const require_shared = require("./shared-DWx3Bwb6.cjs");
|
|
2
|
+
//#region src/core/binary-browser.ts
|
|
3
|
+
function encodeArrayBuffer$1(current) {
|
|
4
|
+
const bytes = new Uint8Array(current);
|
|
5
|
+
if (typeof bytes.toBase64 === "function") return bytes.toBase64();
|
|
6
|
+
let result = "";
|
|
7
|
+
for (let i = 0, len = bytes.length; i < len; i++) result += String.fromCharCode(bytes[i]);
|
|
8
|
+
return btoa(result);
|
|
9
|
+
}
|
|
10
|
+
//#endregion
|
|
11
|
+
//#region src/core/binary-neutral.ts
|
|
12
|
+
const MIN_NATIVE_BASE64_LENGTH = 512;
|
|
13
|
+
function encodeArrayBuffer(current) {
|
|
14
|
+
if (typeof Buffer !== "undefined") return Buffer.from(current).toString("base64");
|
|
15
|
+
return encodeArrayBuffer$1(current);
|
|
16
|
+
}
|
|
17
|
+
function decodeArrayBuffer(source) {
|
|
18
|
+
if (source.length < MIN_NATIVE_BASE64_LENGTH || typeof Buffer === "undefined") return require_shared.ARRAY_BUFFER_CONSTRUCTOR(source);
|
|
19
|
+
const decoded = atob(source);
|
|
20
|
+
const buffer = new ArrayBuffer(decoded.length);
|
|
21
|
+
Buffer.from(buffer).write(decoded, "latin1");
|
|
22
|
+
return buffer;
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
//#region src/core/utils/typed-array.ts
|
|
26
|
+
function getTypedArrayConstructor(name) {
|
|
27
|
+
switch (name) {
|
|
28
|
+
case "Int8Array": return Int8Array;
|
|
29
|
+
case "Int16Array": return Int16Array;
|
|
30
|
+
case "Int32Array": return Int32Array;
|
|
31
|
+
case "Uint8Array": return Uint8Array;
|
|
32
|
+
case "Uint16Array": return Uint16Array;
|
|
33
|
+
case "Uint32Array": return Uint32Array;
|
|
34
|
+
case "Uint8ClampedArray": return Uint8ClampedArray;
|
|
35
|
+
case "Float32Array": return Float32Array;
|
|
36
|
+
case "Float64Array": return Float64Array;
|
|
37
|
+
case "BigInt64Array": return BigInt64Array;
|
|
38
|
+
case "BigUint64Array": return BigUint64Array;
|
|
39
|
+
default: throw new require_shared.SerovalUnknownTypedArrayError(name);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
let typedArrayNameGetter;
|
|
43
|
+
function getTypedArrayName(value) {
|
|
44
|
+
if (!typedArrayNameGetter) typedArrayNameGetter = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Int8Array.prototype), Symbol.toStringTag).get;
|
|
45
|
+
return typedArrayNameGetter.call(value);
|
|
46
|
+
}
|
|
47
|
+
let typedArrayGetters;
|
|
48
|
+
let dataViewGetters;
|
|
49
|
+
function getAccessor(proto, key) {
|
|
50
|
+
return Object.getOwnPropertyDescriptor(proto, key).get;
|
|
51
|
+
}
|
|
52
|
+
function getViewGetters(proto, lengthKey) {
|
|
53
|
+
return {
|
|
54
|
+
buffer: getAccessor(proto, "buffer"),
|
|
55
|
+
byteOffset: getAccessor(proto, "byteOffset"),
|
|
56
|
+
byteLength: getAccessor(proto, "byteLength"),
|
|
57
|
+
length: getAccessor(proto, lengthKey)
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
function readArrayBufferView(value, isDataView) {
|
|
61
|
+
let getters;
|
|
62
|
+
if (isDataView) getters = dataViewGetters ?? (dataViewGetters = getViewGetters(DataView.prototype, "byteLength"));
|
|
63
|
+
else getters = typedArrayGetters ?? (typedArrayGetters = getViewGetters(Object.getPrototypeOf(Int8Array.prototype), "length"));
|
|
64
|
+
return {
|
|
65
|
+
buffer: getters.buffer.call(value),
|
|
66
|
+
byteOffset: getters.byteOffset.call(value),
|
|
67
|
+
byteLength: getters.byteLength.call(value),
|
|
68
|
+
length: getters.length.call(value)
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
//#endregion
|
|
72
|
+
Object.defineProperty(exports, "decodeArrayBuffer", {
|
|
73
|
+
enumerable: true,
|
|
74
|
+
get: function() {
|
|
75
|
+
return decodeArrayBuffer;
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
Object.defineProperty(exports, "encodeArrayBuffer", {
|
|
79
|
+
enumerable: true,
|
|
80
|
+
get: function() {
|
|
81
|
+
return encodeArrayBuffer;
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
Object.defineProperty(exports, "getTypedArrayConstructor", {
|
|
85
|
+
enumerable: true,
|
|
86
|
+
get: function() {
|
|
87
|
+
return getTypedArrayConstructor;
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
Object.defineProperty(exports, "getTypedArrayName", {
|
|
91
|
+
enumerable: true,
|
|
92
|
+
get: function() {
|
|
93
|
+
return getTypedArrayName;
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
Object.defineProperty(exports, "readArrayBufferView", {
|
|
97
|
+
enumerable: true,
|
|
98
|
+
get: function() {
|
|
99
|
+
return readArrayBufferView;
|
|
100
|
+
}
|
|
101
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
//#region src/core/validator.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Type guards for a plugin's `validate` field. A validator is a plain
|
|
4
|
+
* type-guard function, so a plugin can also use a hand-written one.
|
|
5
|
+
*/
|
|
6
|
+
type Validator<T> = (value: unknown) => value is T;
|
|
7
|
+
declare const string: Validator<string>;
|
|
8
|
+
declare const number: Validator<number>;
|
|
9
|
+
declare const boolean: Validator<boolean>;
|
|
10
|
+
declare const bigint: Validator<bigint>;
|
|
11
|
+
/** Matches an instance of the given constructor. */
|
|
12
|
+
declare function instanceOf<T>(ctor: abstract new (...args: never[]) => T): Validator<T>;
|
|
13
|
+
type Guarded<V> = V extends Validator<infer T> ? T : never;
|
|
14
|
+
/** Matches when any of the given validators match. */
|
|
15
|
+
declare function union<V extends Validator<unknown>[]>(...validators: V): Validator<Guarded<V[number]>>;
|
|
16
|
+
/** Matches the given validator or `undefined`. */
|
|
17
|
+
declare function optional<T>(validator: Validator<T>): Validator<T | undefined>;
|
|
18
|
+
/** Matches an array whose items each match `item`. */
|
|
19
|
+
declare function array<T>(item: Validator<T>): Validator<T[]>;
|
|
20
|
+
type Shape = Record<string, Validator<unknown>>;
|
|
21
|
+
type Infer<S extends Shape> = { [K in keyof S]: Guarded<S[K]>; };
|
|
22
|
+
/**
|
|
23
|
+
* Matches an object whose declared keys each pass their validator. Extra keys
|
|
24
|
+
* are not checked.
|
|
25
|
+
*/
|
|
26
|
+
declare function object<S extends Shape>(shape: S): Validator<Infer<S>>;
|
|
27
|
+
//#endregion
|
|
28
|
+
export { instanceOf as a, optional as c, boolean as i, string as l, array as n, number as o, bigint as r, object as s, Validator as t, union as u };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
//#region src/core/validator.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Type guards for a plugin's `validate` field. A validator is a plain
|
|
4
|
+
* type-guard function, so a plugin can also use a hand-written one.
|
|
5
|
+
*/
|
|
6
|
+
type Validator<T> = (value: unknown) => value is T;
|
|
7
|
+
declare const string: Validator<string>;
|
|
8
|
+
declare const number: Validator<number>;
|
|
9
|
+
declare const boolean: Validator<boolean>;
|
|
10
|
+
declare const bigint: Validator<bigint>;
|
|
11
|
+
/** Matches an instance of the given constructor. */
|
|
12
|
+
declare function instanceOf<T>(ctor: abstract new (...args: never[]) => T): Validator<T>;
|
|
13
|
+
type Guarded<V> = V extends Validator<infer T> ? T : never;
|
|
14
|
+
/** Matches when any of the given validators match. */
|
|
15
|
+
declare function union<V extends Validator<unknown>[]>(...validators: V): Validator<Guarded<V[number]>>;
|
|
16
|
+
/** Matches the given validator or `undefined`. */
|
|
17
|
+
declare function optional<T>(validator: Validator<T>): Validator<T | undefined>;
|
|
18
|
+
/** Matches an array whose items each match `item`. */
|
|
19
|
+
declare function array<T>(item: Validator<T>): Validator<T[]>;
|
|
20
|
+
type Shape = Record<string, Validator<unknown>>;
|
|
21
|
+
type Infer<S extends Shape> = { [K in keyof S]: Guarded<S[K]>; };
|
|
22
|
+
/**
|
|
23
|
+
* Matches an object whose declared keys each pass their validator. Extra keys
|
|
24
|
+
* are not checked.
|
|
25
|
+
*/
|
|
26
|
+
declare function object<S extends Shape>(shape: S): Validator<Infer<S>>;
|
|
27
|
+
//#endregion
|
|
28
|
+
export { instanceOf as a, optional as c, boolean as i, string as l, array as n, number as o, bigint as r, object as s, Validator as t, union as u };
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
//#region src/core/validator.ts
|
|
3
|
+
const string = (value) => typeof value === "string";
|
|
4
|
+
const number = (value) => typeof value === "number";
|
|
5
|
+
const boolean = (value) => typeof value === "boolean";
|
|
6
|
+
const bigint = (value) => typeof value === "bigint";
|
|
7
|
+
/** Matches an instance of the given constructor. */
|
|
8
|
+
function instanceOf(ctor) {
|
|
9
|
+
return (value) => value instanceof ctor;
|
|
10
|
+
}
|
|
11
|
+
/** Matches when any of the given validators match. */
|
|
12
|
+
function union(...validators) {
|
|
13
|
+
return (value) => {
|
|
14
|
+
for (let i = 0, len = validators.length; i < len; i++) if (validators[i](value)) return true;
|
|
15
|
+
return false;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
/** Matches the given validator or `undefined`. */
|
|
19
|
+
function optional(validator) {
|
|
20
|
+
return (value) => value === void 0 || validator(value);
|
|
21
|
+
}
|
|
22
|
+
/** Matches an array whose items each match `item`. */
|
|
23
|
+
function array(item) {
|
|
24
|
+
return (value) => {
|
|
25
|
+
if (!Array.isArray(value)) return false;
|
|
26
|
+
for (let i = 0, len = value.length; i < len; i++) if (!item(value[i])) return false;
|
|
27
|
+
return true;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Matches an object whose declared keys each pass their validator. Extra keys
|
|
32
|
+
* are not checked.
|
|
33
|
+
*/
|
|
34
|
+
function object(shape) {
|
|
35
|
+
const keys = Object.keys(shape);
|
|
36
|
+
return (value) => {
|
|
37
|
+
if (value == null || typeof value !== "object") return false;
|
|
38
|
+
for (let i = 0, len = keys.length; i < len; i++) {
|
|
39
|
+
const key = keys[i];
|
|
40
|
+
if (!shape[key](Reflect.get(value, key))) return false;
|
|
41
|
+
}
|
|
42
|
+
return true;
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
//#endregion
|
|
46
|
+
exports.array = array;
|
|
47
|
+
exports.bigint = bigint;
|
|
48
|
+
exports.boolean = boolean;
|
|
49
|
+
exports.instanceOf = instanceOf;
|
|
50
|
+
exports.number = number;
|
|
51
|
+
exports.object = object;
|
|
52
|
+
exports.optional = optional;
|
|
53
|
+
exports.string = string;
|
|
54
|
+
exports.union = union;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as instanceOf, c as optional, i as boolean, l as string, n as array, o as number, r as bigint, s as object, t as Validator, u as union } from "./validator-CxDhXc0k.cjs";
|
|
2
|
+
export { Validator, array, bigint, boolean, instanceOf, number, object, optional, string, union };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as instanceOf, c as optional, i as boolean, l as string, n as array, o as number, r as bigint, s as object, t as Validator, u as union } from "./validator-CxDhXc0k.js";
|
|
2
|
+
export { Validator, array, bigint, boolean, instanceOf, number, object, optional, string, union };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
//#region src/core/validator.ts
|
|
2
|
+
const string = (value) => typeof value === "string";
|
|
3
|
+
const number = (value) => typeof value === "number";
|
|
4
|
+
const boolean = (value) => typeof value === "boolean";
|
|
5
|
+
const bigint = (value) => typeof value === "bigint";
|
|
6
|
+
/** Matches an instance of the given constructor. */
|
|
7
|
+
function instanceOf(ctor) {
|
|
8
|
+
return (value) => value instanceof ctor;
|
|
9
|
+
}
|
|
10
|
+
/** Matches when any of the given validators match. */
|
|
11
|
+
function union(...validators) {
|
|
12
|
+
return (value) => {
|
|
13
|
+
for (let i = 0, len = validators.length; i < len; i++) if (validators[i](value)) return true;
|
|
14
|
+
return false;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
/** Matches the given validator or `undefined`. */
|
|
18
|
+
function optional(validator) {
|
|
19
|
+
return (value) => value === void 0 || validator(value);
|
|
20
|
+
}
|
|
21
|
+
/** Matches an array whose items each match `item`. */
|
|
22
|
+
function array(item) {
|
|
23
|
+
return (value) => {
|
|
24
|
+
if (!Array.isArray(value)) return false;
|
|
25
|
+
for (let i = 0, len = value.length; i < len; i++) if (!item(value[i])) return false;
|
|
26
|
+
return true;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Matches an object whose declared keys each pass their validator. Extra keys
|
|
31
|
+
* are not checked.
|
|
32
|
+
*/
|
|
33
|
+
function object(shape) {
|
|
34
|
+
const keys = Object.keys(shape);
|
|
35
|
+
return (value) => {
|
|
36
|
+
if (value == null || typeof value !== "object") return false;
|
|
37
|
+
for (let i = 0, len = keys.length; i < len; i++) {
|
|
38
|
+
const key = keys[i];
|
|
39
|
+
if (!shape[key](Reflect.get(value, key))) return false;
|
|
40
|
+
}
|
|
41
|
+
return true;
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
//#endregion
|
|
45
|
+
export { array, bigint, boolean, instanceOf, number, object, optional, string, union };
|