@stryke/json 0.9.44 → 0.11.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/CHANGELOG.md +22 -0
- package/dist/code-frames-BUtrssZ5.d.cts +17 -0
- package/dist/code-frames-BUtrssZ5.d.cts.map +1 -0
- package/dist/code-frames-BmUvlJ0w.cjs +82 -0
- package/dist/code-frames-CrTAYYSE.d.mts +17 -0
- package/dist/code-frames-CrTAYYSE.d.mts.map +1 -0
- package/dist/code-frames-DuBfTMu4.mjs +77 -0
- package/dist/code-frames-DuBfTMu4.mjs.map +1 -0
- package/dist/find-reference-B8xshNXL.d.mts +52 -0
- package/dist/find-reference-B8xshNXL.d.mts.map +1 -0
- package/dist/find-reference-C-YleCds.d.cts +52 -0
- package/dist/find-reference-C-YleCds.d.cts.map +1 -0
- package/dist/find-reference-DMSYEaaI.mjs +64 -0
- package/dist/find-reference-DMSYEaaI.mjs.map +1 -0
- package/dist/find-reference-De5vBQV2.cjs +86 -0
- package/dist/index-B_e8BwCm.d.cts +1 -0
- package/dist/index-CCt0lwyI.d.mts +1 -0
- package/dist/index-CDAfh8Ew.d.cts +1 -0
- package/dist/index-DvuJXuAN.d.mts +1 -0
- package/dist/index.cjs +37 -14
- package/dist/index.d.cts +11 -8
- package/dist/index.d.mts +12 -9
- package/dist/index.mjs +13 -8
- package/dist/is-number-BIwzZzyi.mjs +31 -0
- package/dist/is-number-BIwzZzyi.mjs.map +1 -0
- package/dist/is-number-c5xguIbS.cjs +42 -0
- package/dist/{type-checks/src/is-plain-object.mjs → is-object-BpfmzHWa.mjs} +19 -3
- package/dist/is-object-BpfmzHWa.mjs.map +1 -0
- package/dist/{type-checks/src/is-plain-object.cjs → is-object-umGh91v1.cjs} +24 -3
- package/dist/is-set-object-BmHip9em.cjs +108 -0
- package/dist/is-set-object-C1Qnj1Q8.mjs +98 -0
- package/dist/is-set-object-C1Qnj1Q8.mjs.map +1 -0
- package/dist/{type-checks/src/is-string.mjs → is-string-C2RK4Gjs.cjs} +7 -2
- package/dist/{type-checks/src/is-string.cjs → is-string-CLiBUSKV.mjs} +2 -2
- package/dist/is-string-CLiBUSKV.mjs.map +1 -0
- package/dist/{type-checks/src/is-undefined.cjs → is-undefined-CmyJWYGD.mjs} +2 -2
- package/dist/is-undefined-CmyJWYGD.mjs.map +1 -0
- package/dist/{type-checks/src/is-undefined.mjs → is-undefined-CnI0qe-z.cjs} +7 -2
- package/dist/parse-BGlhbY16.d.cts +9 -0
- package/dist/parse-BGlhbY16.d.cts.map +1 -0
- package/dist/parse-Bp6kkcQ4.cjs +127 -0
- package/dist/parse-ByDxRup5.cjs +62 -0
- package/dist/parse-Cj-YfhrI.d.mts +51 -0
- package/dist/parse-Cj-YfhrI.d.mts.map +1 -0
- package/dist/parse-DZfi3d96.d.cts +51 -0
- package/dist/parse-DZfi3d96.d.cts.map +1 -0
- package/dist/parse-Dn43ZK9y.mjs +52 -0
- package/dist/parse-Dn43ZK9y.mjs.map +1 -0
- package/dist/parse-error-7K8s4vWf.d.cts +15 -0
- package/dist/parse-error-7K8s4vWf.d.cts.map +1 -0
- package/dist/parse-error-Af4zHUQ_.mjs +34 -0
- package/dist/parse-error-Af4zHUQ_.mjs.map +1 -0
- package/dist/parse-error-DpEv3vo_.d.mts +15 -0
- package/dist/parse-error-DpEv3vo_.d.mts.map +1 -0
- package/dist/parse-error-N7UE-HMh.cjs +39 -0
- package/dist/parse-fXy5pbmE.d.mts +9 -0
- package/dist/parse-fXy5pbmE.d.mts.map +1 -0
- package/dist/parse-vw_qRD3F.mjs +81 -0
- package/dist/parse-vw_qRD3F.mjs.map +1 -0
- package/dist/pointer/find-reference.cjs +5 -65
- package/dist/pointer/find-reference.d.cts +2 -52
- package/dist/pointer/find-reference.d.mts +2 -52
- package/dist/pointer/find-reference.mjs +2 -63
- package/dist/pointer/index.cjs +15 -14
- package/dist/pointer/index.d.cts +2 -2
- package/dist/pointer/index.d.mts +2 -2
- package/dist/pointer/index.mjs +3 -2
- package/dist/pointer/parse.cjs +9 -86
- package/dist/pointer/parse.d.cts +2 -44
- package/dist/pointer/parse.d.mts +2 -44
- package/dist/pointer/parse.mjs +2 -80
- package/dist/pointer-B3W_Sme3.cjs +0 -0
- package/dist/pointer-Dn__XOdY.mjs +0 -0
- package/dist/schema-BO1HCrxv.d.cts +55 -0
- package/dist/schema-BO1HCrxv.d.cts.map +1 -0
- package/dist/schema-CmH1V_uI.d.mts +55 -0
- package/dist/schema-CmH1V_uI.d.mts.map +1 -0
- package/dist/schema-DGmzxHja.mjs +72 -0
- package/dist/schema-DGmzxHja.mjs.map +1 -0
- package/dist/schema-Dl018Aq4.cjs +106 -0
- package/dist/schema.cjs +8 -0
- package/dist/schema.d.cts +2 -0
- package/dist/schema.d.mts +3 -0
- package/dist/schema.mjs +3 -0
- package/dist/storm-json-8F9CKpXu.d.mts +70 -0
- package/dist/storm-json-8F9CKpXu.d.mts.map +1 -0
- package/dist/storm-json-BD6WFbrI.cjs +154 -0
- package/dist/storm-json-DvIEWMEH.d.cts +70 -0
- package/dist/storm-json-DvIEWMEH.d.cts.map +1 -0
- package/dist/storm-json-nkhJgTz4.mjs +116 -0
- package/dist/storm-json-nkhJgTz4.mjs.map +1 -0
- package/dist/storm-json.cjs +3 -116
- package/dist/storm-json.d.cts +2 -70
- package/dist/storm-json.d.mts +3 -70
- package/dist/storm-json.mjs +3 -115
- package/dist/stringify-Bc8OkhIr.d.cts +13 -0
- package/dist/stringify-Bc8OkhIr.d.cts.map +1 -0
- package/dist/stringify-BehjrfhS.cjs +78 -0
- package/dist/stringify-CFT1K1LE.d.mts +13 -0
- package/dist/stringify-CFT1K1LE.d.mts.map +1 -0
- package/dist/stringify-CYHjAvWm.mjs +68 -0
- package/dist/stringify-CYHjAvWm.mjs.map +1 -0
- package/dist/strip-comments-BA8MS_Fs.d.mts +11 -0
- package/dist/strip-comments-BA8MS_Fs.d.mts.map +1 -0
- package/dist/strip-comments-CmEG_smS.cjs +94 -0
- package/dist/strip-comments-Cz_Wc25t.d.cts +11 -0
- package/dist/strip-comments-Cz_Wc25t.d.cts.map +1 -0
- package/dist/strip-comments-Dq00N_Sg.mjs +89 -0
- package/dist/strip-comments-Dq00N_Sg.mjs.map +1 -0
- package/dist/types-Bn8rC098.d.cts +222 -0
- package/dist/types-Bn8rC098.d.cts.map +1 -0
- package/dist/types-CPQlxauZ.d.mts +222 -0
- package/dist/types-CPQlxauZ.d.mts.map +1 -0
- package/dist/types.d.cts +2 -69
- package/dist/types.d.mts +2 -69
- package/dist/types.mjs +0 -1
- package/dist/utils/code-frames.cjs +2 -76
- package/dist/utils/code-frames.d.cts +2 -17
- package/dist/utils/code-frames.d.mts +2 -17
- package/dist/utils/code-frames.mjs +2 -76
- package/dist/utils/index.cjs +13 -12
- package/dist/utils/index.d.cts +5 -5
- package/dist/utils/index.d.mts +6 -5
- package/dist/utils/index.mjs +6 -5
- package/dist/utils/parse-error.cjs +2 -33
- package/dist/utils/parse-error.d.cts +2 -15
- package/dist/utils/parse-error.d.mts +2 -15
- package/dist/utils/parse-error.mjs +2 -33
- package/dist/utils/parse.cjs +3 -51
- package/dist/utils/parse.d.cts +2 -9
- package/dist/utils/parse.d.mts +2 -9
- package/dist/utils/parse.mjs +2 -51
- package/dist/utils/stringify.cjs +3 -67
- package/dist/utils/stringify.d.cts +2 -13
- package/dist/utils/stringify.d.mts +2 -13
- package/dist/utils/stringify.mjs +2 -67
- package/dist/utils/strip-comments.cjs +2 -85
- package/dist/utils/strip-comments.d.cts +2 -11
- package/dist/utils/strip-comments.d.mts +2 -11
- package/dist/utils/strip-comments.mjs +2 -86
- package/dist/utils-jN2UkvqB.cjs +0 -0
- package/dist/utils-mEkKIcgl.mjs +0 -0
- package/package.json +12 -3
- package/dist/_virtual/rolldown_runtime.cjs +0 -29
- package/dist/pointer/find-reference.d.cts.map +0 -1
- package/dist/pointer/find-reference.d.mts.map +0 -1
- package/dist/pointer/find-reference.mjs.map +0 -1
- package/dist/pointer/parse.d.cts.map +0 -1
- package/dist/pointer/parse.d.mts.map +0 -1
- package/dist/pointer/parse.mjs.map +0 -1
- package/dist/storm-json.d.cts.map +0 -1
- package/dist/storm-json.d.mts.map +0 -1
- package/dist/storm-json.mjs.map +0 -1
- package/dist/type-checks/src/get-object-tag.cjs +0 -15
- package/dist/type-checks/src/get-object-tag.mjs +0 -15
- package/dist/type-checks/src/get-object-tag.mjs.map +0 -1
- package/dist/type-checks/src/is-empty.cjs +0 -20
- package/dist/type-checks/src/is-empty.mjs +0 -21
- package/dist/type-checks/src/is-empty.mjs.map +0 -1
- package/dist/type-checks/src/is-non-null-object.cjs +0 -16
- package/dist/type-checks/src/is-non-null-object.mjs +0 -17
- package/dist/type-checks/src/is-non-null-object.mjs.map +0 -1
- package/dist/type-checks/src/is-null.cjs +0 -12
- package/dist/type-checks/src/is-null.mjs +0 -12
- package/dist/type-checks/src/is-null.mjs.map +0 -1
- package/dist/type-checks/src/is-number.cjs +0 -18
- package/dist/type-checks/src/is-number.mjs +0 -18
- package/dist/type-checks/src/is-number.mjs.map +0 -1
- package/dist/type-checks/src/is-object.cjs +0 -19
- package/dist/type-checks/src/is-object.mjs +0 -20
- package/dist/type-checks/src/is-object.mjs.map +0 -1
- package/dist/type-checks/src/is-plain-object.mjs.map +0 -1
- package/dist/type-checks/src/is-set-object.cjs +0 -19
- package/dist/type-checks/src/is-set-object.mjs +0 -20
- package/dist/type-checks/src/is-set-object.mjs.map +0 -1
- package/dist/type-checks/src/is-set.cjs +0 -19
- package/dist/type-checks/src/is-set.mjs +0 -20
- package/dist/type-checks/src/is-set.mjs.map +0 -1
- package/dist/type-checks/src/is-string.mjs.map +0 -1
- package/dist/type-checks/src/is-undefined.mjs.map +0 -1
- package/dist/types/src/base.cjs +0 -6
- package/dist/types/src/base.mjs +0 -6
- package/dist/types/src/base.mjs.map +0 -1
- package/dist/types/src/json.d.cts +0 -12
- package/dist/types/src/json.d.cts.map +0 -1
- package/dist/types/src/json.d.mts +0 -12
- package/dist/types/src/json.d.mts.map +0 -1
- package/dist/types.d.cts.map +0 -1
- package/dist/types.d.mts.map +0 -1
- package/dist/utils/code-frames.d.cts.map +0 -1
- package/dist/utils/code-frames.d.mts.map +0 -1
- package/dist/utils/code-frames.mjs.map +0 -1
- package/dist/utils/parse-error.d.cts.map +0 -1
- package/dist/utils/parse-error.d.mts.map +0 -1
- package/dist/utils/parse-error.mjs.map +0 -1
- package/dist/utils/parse.d.cts.map +0 -1
- package/dist/utils/parse.d.mts.map +0 -1
- package/dist/utils/parse.mjs.map +0 -1
- package/dist/utils/stringify.d.cts.map +0 -1
- package/dist/utils/stringify.d.mts.map +0 -1
- package/dist/utils/stringify.mjs.map +0 -1
- package/dist/utils/strip-comments.d.cts.map +0 -1
- package/dist/utils/strip-comments.d.mts.map +0 -1
- package/dist/utils/strip-comments.mjs.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stryke/json",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A package containing JSON parsing/stringify utilities used by Storm Software.",
|
|
6
6
|
"repository": {
|
|
@@ -25,6 +25,10 @@
|
|
|
25
25
|
"require": "./dist/pointer/parse.cjs",
|
|
26
26
|
"import": "./dist/pointer/parse.mjs"
|
|
27
27
|
},
|
|
28
|
+
"./schema": {
|
|
29
|
+
"require": "./dist/schema.cjs",
|
|
30
|
+
"import": "./dist/schema.mjs"
|
|
31
|
+
},
|
|
28
32
|
"./storm-json": {
|
|
29
33
|
"require": "./dist/storm-json.cjs",
|
|
30
34
|
"import": "./dist/storm-json.mjs"
|
|
@@ -59,10 +63,15 @@
|
|
|
59
63
|
"types": "./dist/index.d.cts",
|
|
60
64
|
"dependencies": {
|
|
61
65
|
"buffer": "6.0.3",
|
|
66
|
+
"jsonc-parser": "3.3.1",
|
|
62
67
|
"lines-and-columns": "2.0.4",
|
|
63
68
|
"superjson": "2.2.2"
|
|
64
69
|
},
|
|
65
|
-
"devDependencies": {
|
|
70
|
+
"devDependencies": {
|
|
71
|
+
"@standard-schema/spec": "^1.1.0",
|
|
72
|
+
"@types/node": "^24.11.0",
|
|
73
|
+
"tsdown": "^0.17.2"
|
|
74
|
+
},
|
|
66
75
|
"publishConfig": { "access": "public" },
|
|
67
|
-
"gitHead": "
|
|
76
|
+
"gitHead": "c19d9de45cecf6e0cc805e04358c9dc9d9e4eb6a"
|
|
68
77
|
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
//#region rolldown:runtime
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
-
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
-
key = keys[i];
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
13
|
-
__defProp(to, key, {
|
|
14
|
-
get: ((k) => from[k]).bind(null, key),
|
|
15
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
return to;
|
|
21
|
-
};
|
|
22
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
23
|
-
value: mod,
|
|
24
|
-
enumerable: true
|
|
25
|
-
}) : target, mod));
|
|
26
|
-
|
|
27
|
-
//#endregion
|
|
28
|
-
|
|
29
|
-
exports.__toESM = __toESM;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"find-reference.d.cts","names":[],"sources":["../../src/pointer/find-reference.ts"],"sourcesContent":[],"mappings":";UAqBiB,SAAA;EAAA;EAoCJ,SAyCZ,GAAA,EAAA,OAzCwC;EA2CxB;EAOJ,SAAA,GAAA,CAAA,EAAA,OAEiE,GAAA,MAAA,GAAA,OAAA,EAAA;EADvE;EACkB,SAAA,GAAA,CAAA,EAAA,MAAA,GAAA,MAAA;;;AAEzB;AAGA;;;;;AAMA;;;;;;;;;;;;;;;;;;cA/Da,2BAA4B,uBAAqB;UA2C7C;;4BAEW;gBACZ;;;cAIH,qCACN,qBACG,eAAe;cAEZ,kBAAmB;UAGf;gBACD;gBACA,eAAe;;;cAIlB,sCACN,qBACG,gBAAgB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"find-reference.d.mts","names":[],"sources":["../../src/pointer/find-reference.ts"],"sourcesContent":[],"mappings":";UAqBiB,SAAA;EAAA;EAoCJ,SAyCZ,GAAA,EAAA,OAzCwC;EA2CxB;EAOJ,SAAA,GAAA,CAAA,EAAA,OAEiE,GAAA,MAAA,GAAA,OAAA,EAAA;EADvE;EACkB,SAAA,GAAA,CAAA,EAAA,MAAA,GAAA,MAAA;;;AAEzB;AAGA;;;;;AAMA;;;;;;;;;;;;;;;;;;cA/Da,2BAA4B,uBAAqB;UA2C7C;;4BAEW;gBACZ;;;cAIH,qCACN,qBACG,eAAe;cAEZ,kBAAmB;UAGf;gBACD;gBACA,eAAe;;;cAIlB,sCACN,qBACG,gBAAgB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"find-reference.mjs","names":["obj: Reference[\"obj\"]","key: Reference[\"key\"]"],"sources":["../../src/pointer/find-reference.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isString } from \"@stryke/type-checks/is-string\";\n\nexport interface Reference {\n /** Target value where pointer is pointing. */\n readonly val: unknown;\n /** Object which contains the target value. */\n readonly obj?: unknown | object | unknown[];\n /** Key which targets the target value in the object. */\n readonly key?: string | number;\n}\n\nconst { isArray } = Array;\n\n/**\n * Finds a target in document specified by JSON Pointer. Also returns the\n * object containing the target and key used to reference that object.\n *\n * Throws Error('NOT_FOUND') if pointer does not result into a value in the middle\n * of the path. If the last element of the path does not result into a value, the\n * lookup succeeds with `val` set to `undefined`. It can be used to discriminate\n * missing values, because `undefined` is not a valid JSON value.\n *\n * If last element in array is targeted using \"-\", e.g. \"/arr/-\", use\n * `isArrayEnd` to verify that:\n *\n * ```js\n * const ref = find({arr: [1, 2, 3], ['arr', '-']});\n * if (isArrayReference(ref)) {\n * if (isArrayEnd(ref)) {\n * // ...\n * }\n * }\n * ```\n *\n * @param val - Document to search in.\n * @param path - JSON Pointer path.\n * @returns Reference to the target.\n */\nexport const find = (val: unknown, path: Reference[\"key\"][]): Reference => {\n const pathLength = path.length;\n if (!pathLength) {\n return { val };\n }\n\n let obj: Reference[\"obj\"];\n let key: Reference[\"key\"];\n for (let i = 0; i < pathLength; i++) {\n obj = val;\n key = path[i];\n if (isArray(obj)) {\n const length = obj.length;\n if (key === \"-\") {\n key = length;\n } else if (isString(key)) {\n const key2 = Math.trunc(Number.parseInt(key));\n if (String(key2) !== key) {\n throw new Error(\"INVALID_INDEX\");\n }\n\n key = key2;\n if (key < 0) {\n throw new Error(\"INVALID_INDEX\");\n }\n }\n\n if (key) {\n val = obj[key];\n }\n } else if (isSetObject(obj)) {\n val = key && key in obj ? (obj as any)[key] : undefined;\n } else throw new Error(\"NOT_FOUND\");\n }\n const ref: Reference = {\n val,\n obj,\n key\n };\n\n return ref;\n};\n\nexport interface ArrayReference<T = unknown> {\n /** `undefined` in case JSON Pointer points to last element, e.g. \"/foo/-\". */\n readonly val: undefined | T;\n readonly obj: T[];\n readonly key: number;\n}\n\nexport const isArrayReference = <T = unknown>(\n ref: Reference\n): ref is ArrayReference<T> => isArray(ref.obj) && typeof ref.key === \"number\";\n\nexport const isArrayEnd = (ref: ArrayReference): boolean =>\n ref.obj.length === ref.key;\n\nexport interface ObjectReference<T = unknown> {\n readonly val: T;\n readonly obj: Record<string, T>;\n readonly key: string;\n}\n\nexport const isObjectReference = <T = unknown>(\n ref: Reference\n): ref is ObjectReference<T> =>\n typeof ref.obj === \"object\" && typeof ref.key === \"string\";\n"],"mappings":";;;;AA8BA,MAAM,EAAE,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BpB,MAAa,QAAQ,KAAc,SAAwC;CACzE,MAAM,aAAa,KAAK;AACxB,KAAI,CAAC,WACH,QAAO,EAAE,KAAK;CAGhB,IAAIA;CACJ,IAAIC;AACJ,MAAK,IAAI,IAAI,GAAG,IAAI,YAAY,KAAK;AACnC,QAAM;AACN,QAAM,KAAK;AACX,MAAI,QAAQ,IAAI,EAAE;GAChB,MAAM,SAAS,IAAI;AACnB,OAAI,QAAQ,IACV,OAAM;YACG,SAAS,IAAI,EAAE;IACxB,MAAM,OAAO,KAAK,MAAM,OAAO,SAAS,IAAI,CAAC;AAC7C,QAAI,OAAO,KAAK,KAAK,IACnB,OAAM,IAAI,MAAM,gBAAgB;AAGlC,UAAM;AACN,QAAI,MAAM,EACR,OAAM,IAAI,MAAM,gBAAgB;;AAIpC,OAAI,IACF,OAAM,IAAI;aAEH,YAAY,IAAI,CACzB,OAAM,OAAO,OAAO,MAAO,IAAY,OAAO;MACzC,OAAM,IAAI,MAAM,YAAY;;AAQrC,QANuB;EACrB;EACA;EACA;EACD;;AAYH,MAAa,oBACX,QAC6B,QAAQ,IAAI,IAAI,IAAI,OAAO,IAAI,QAAQ;AAEtE,MAAa,cAAc,QACzB,IAAI,IAAI,WAAW,IAAI;AAQzB,MAAa,qBACX,QAEA,OAAO,IAAI,QAAQ,YAAY,OAAO,IAAI,QAAQ"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parse.d.cts","names":[],"sources":["../../src/pointer/parse.ts"],"sourcesContent":[],"mappings":";;;;;;AAiCA;AAcA;AAYA;AAaA;AAYa,iBAnDG,oBAAA,CAmD8C,OAAA,EAAA,MAAA,CAAA,EAAA,MAAA;AAU9D;AAWA;AAUA;;;;iBApEgB,sBAAA;;;;;iBAYA,gBAAA,mBAAmC;;;;;iBAanC,iBAAA,OAAwB;;;;cAY3B,iCAAkC;;;;iBAU/B,MAAA,OAAa,kBAAkB;;;;iBAW/B,YAAA;cAUH"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parse.d.mts","names":[],"sources":["../../src/pointer/parse.ts"],"sourcesContent":[],"mappings":";;;;;;AAiCA;AAcA;AAYA;AAaA;AAYa,iBAnDG,oBAAA,CAmD8C,OAAA,EAAA,MAAA,CAAA,EAAA,MAAA;AAU9D;AAWA;AAUA;;;;iBApEgB,sBAAA;;;;;iBAYA,gBAAA,mBAAmC;;;;;iBAanC,iBAAA,OAAwB;;;;cAY3B,iCAAkC;;;;iBAU/B,MAAA,OAAa,kBAAkB;;;;iBAW/B,YAAA;cAUH"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parse.mjs","names":["charCode: any"],"sources":["../../src/pointer/parse.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { isNumber } from \"@stryke/type-checks/is-number\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport type { JsonPointerPath } from \"@stryke/types/json\";\n\nconst TILDE_ONE = /~1/g;\nconst TILDE_ZERO = /~0/g;\nconst TILDE = /~/g;\nconst FORWARD_SLASH = /\\//g;\n\n/**\n * Escapes a JSON pointer path segment.\n *\n * @param segment - JSON pointer path segment.\n * @returns Escaped JSON pointer path segment.\n */\nexport function escapePointerSegment(segment: string): string {\n if (!segment.includes(\"/\") && !segment.includes(\"~\")) {\n return segment;\n }\n\n return segment.replace(TILDE, \"~0\").replace(FORWARD_SLASH, \"~1\");\n}\n\n/**\n * Unescapes a JSON pointer path segment.\n *\n * @param segment - JSON pointer path segment.\n * @returns Unescaped JSON pointer path segment.\n */\nexport function unescapePointerSegment(segment: string): string {\n if (!segment.includes(\"~\")) {\n return segment;\n }\n\n return segment.replace(TILDE_ONE, \"/\").replace(TILDE_ZERO, \"~\");\n}\n\n/**\n * Convert JSON pointer like \"/foo/bar\" to array like [\"\", \"foo\", \"bar\"], while\n * also un-escaping reserved characters.\n */\nexport function parseJsonPointer(pointer: string): JsonPointerPath {\n if (!pointer) return [];\n // TODO: Performance of this line can be improved: (1) don't use .split(); (2) don't use .map().\n return pointer\n .slice(1)\n .split(\"/\")\n .map(segment => unescapePointerSegment(segment));\n}\n\n/**\n * Escape and format a path array like [\"\", \"foo\", \"bar\"] to JSON pointer\n * like \"/foo/bar\".\n */\nexport function formatJsonPointer(path: JsonPointerPath): string {\n // eslint-disable-next-line ts/no-use-before-define\n if (isRoot(path)) {\n return \"\";\n }\n\n return `/${path.map(segment => escapePointerSegment(String(segment))).join(\"/\")}`;\n}\n\n/**\n * Returns true if JSON Pointer points to root value, false otherwise.\n */\nexport const isRoot = (path: string | number | JsonPointerPath): boolean =>\n isString(path)\n ? path === \"\"\n : isNumber(path)\n ? path === 0\n : Array.isArray(path) && path.length === 0;\n\n/**\n * Returns parent path, e.g. for ['foo', 'bar', 'baz'] returns ['foo', 'bar'].\n */\nexport function parent(path: JsonPointerPath): JsonPointerPath {\n if (path.length === 0) {\n throw new Error(\"NO_PARENT\");\n }\n\n return path.slice(0, -1);\n}\n\n/**\n * Check if path component can be a valid array index.\n */\nexport function isValidIndex(index: string | number): boolean {\n if (isNumber(index)) {\n return true;\n }\n\n const n = Number.parseInt(index, 10);\n\n return String(n) === index && n >= 0;\n}\n\nexport const isInteger = (str: string): boolean => {\n const len = str.length;\n let i = 0;\n let charCode: any;\n while (i < len) {\n charCode = str.codePointAt(i);\n if (charCode >= 48 && charCode <= 57) {\n i++;\n continue;\n }\n return false;\n }\n return true;\n};\n"],"mappings":";;;;AAsBA,MAAM,YAAY;AAClB,MAAM,aAAa;AACnB,MAAM,QAAQ;AACd,MAAM,gBAAgB;;;;;;;AAQtB,SAAgB,qBAAqB,SAAyB;AAC5D,KAAI,CAAC,QAAQ,SAAS,IAAI,IAAI,CAAC,QAAQ,SAAS,IAAI,CAClD,QAAO;AAGT,QAAO,QAAQ,QAAQ,OAAO,KAAK,CAAC,QAAQ,eAAe,KAAK;;;;;;;;AASlE,SAAgB,uBAAuB,SAAyB;AAC9D,KAAI,CAAC,QAAQ,SAAS,IAAI,CACxB,QAAO;AAGT,QAAO,QAAQ,QAAQ,WAAW,IAAI,CAAC,QAAQ,YAAY,IAAI;;;;;;AAOjE,SAAgB,iBAAiB,SAAkC;AACjE,KAAI,CAAC,QAAS,QAAO,EAAE;AAEvB,QAAO,QACJ,MAAM,EAAE,CACR,MAAM,IAAI,CACV,KAAI,YAAW,uBAAuB,QAAQ,CAAC;;;;;;AAOpD,SAAgB,kBAAkB,MAA+B;AAE/D,KAAI,OAAO,KAAK,CACd,QAAO;AAGT,QAAO,IAAI,KAAK,KAAI,YAAW,qBAAqB,OAAO,QAAQ,CAAC,CAAC,CAAC,KAAK,IAAI;;;;;AAMjF,MAAa,UAAU,SACrB,SAAS,KAAK,GACV,SAAS,KACT,SAAS,KAAK,GACZ,SAAS,IACT,MAAM,QAAQ,KAAK,IAAI,KAAK,WAAW;;;;AAK/C,SAAgB,OAAO,MAAwC;AAC7D,KAAI,KAAK,WAAW,EAClB,OAAM,IAAI,MAAM,YAAY;AAG9B,QAAO,KAAK,MAAM,GAAG,GAAG;;;;;AAM1B,SAAgB,aAAa,OAAiC;AAC5D,KAAI,SAAS,MAAM,CACjB,QAAO;CAGT,MAAM,IAAI,OAAO,SAAS,OAAO,GAAG;AAEpC,QAAO,OAAO,EAAE,KAAK,SAAS,KAAK;;AAGrC,MAAa,aAAa,QAAyB;CACjD,MAAM,MAAM,IAAI;CAChB,IAAI,IAAI;CACR,IAAIA;AACJ,QAAO,IAAI,KAAK;AACd,aAAW,IAAI,YAAY,EAAE;AAC7B,MAAI,YAAY,MAAM,YAAY,IAAI;AACpC;AACA;;AAEF,SAAO;;AAET,QAAO"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"storm-json.d.cts","names":[],"sources":["../src/storm-json.ts"],"sourcesContent":[],"mappings":";;;;;;;AA0CA;;;;AAuB2C,cAvB9B,SAAA,SAAkB,SAAA,CAuBY;EAAY,CAAA,OAAA;EAUS,WAAA,QAAA,CAAA,CAAA,EA9BhC,SA8BgC;EAarD;;;EAyBN,OAAA,WAAA,CAAA,QAAA,OAAA,CAAA,CAAA,OAAA,EAxDQ,gBAwDR,CAAA,EAvDA,KAuDA;EAiCmB;;;EAGQ,OAAA,SAAA,CAAA,MAAA,EApFW,SAoFX,CAAA,EApFuB,gBAoFvB;EACR;;;;;;gDA3EwC;;;;;;;;;6BAarD,cACI;;;;;;;;;+DAuBD,mBACT;;;;;;;;;mDAiCmB,YAAY,2CAGd,UAAU,iCACR,gBAAgB,4CACC;;;;;;yCAkBnB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"storm-json.d.mts","names":[],"sources":["../src/storm-json.ts"],"sourcesContent":[],"mappings":";;;;;;;AA0CA;;;;AAuB2C,cAvB9B,SAAA,SAAkB,SAAA,CAuBY;EAAY,CAAA,OAAA;EAUS,WAAA,QAAA,CAAA,CAAA,EA9BhC,SA8BgC;EAarD;;;EAyBN,OAAA,WAAA,CAAA,QAAA,OAAA,CAAA,CAAA,OAAA,EAxDQ,gBAwDR,CAAA,EAvDA,KAuDA;EAiCmB;;;EAGQ,OAAA,SAAA,CAAA,MAAA,EApFW,SAoFX,CAAA,EApFuB,gBAoFvB;EACR;;;;;;gDA3EwC;;;;;;;;;6BAarD,cACI;;;;;;;;;+DAuBD,mBACT;;;;;;;;;mDAiCmB,YAAY,2CAGd,UAAU,iCACR,gBAAgB,4CACC;;;;;;yCAkBnB"}
|
package/dist/storm-json.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"storm-json.mjs","names":["#instance","parseValue","stringifyValue","errors: ParseError[]"],"sources":["../src/storm-json.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { ParseError } from \"jsonc-parser\";\nimport type {\n Class,\n JsonParseOptions,\n JsonParserResult,\n JsonSerializeOptions,\n JsonValue\n} from \"./types\";\n// import { Decimal } from \"decimal.js\";\nimport { isObject } from \"@stryke/type-checks/is-object\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport { parse } from \"jsonc-parser\";\nimport { Buffer } from \"node:buffer\";\nimport SuperJSON from \"superjson\";\nimport { parse as parseValue } from \"./utils/parse\";\nimport { formatParseError } from \"./utils/parse-error\";\nimport { stringify as stringifyValue } from \"./utils/stringify\";\n\n/**\n * A static JSON parser class used by Storm Software to serialize and deserialize JSON data\n *\n * @remarks\n * This class uses the [SuperJSON](https://github.com/blitz-js/superjson) library under the hood.\n */\nexport class StormJSON extends SuperJSON {\n static #instance: StormJSON;\n\n public static get instance(): StormJSON {\n if (!StormJSON.#instance) {\n StormJSON.#instance = new StormJSON();\n }\n\n return StormJSON.#instance;\n }\n\n /**\n * Deserialize the given value with superjson using the given metadata\n */\n public static override deserialize<TData = unknown>(\n payload: JsonParserResult\n ): TData {\n return StormJSON.instance.deserialize(payload);\n }\n\n /**\n * Serialize the given value with superjson\n */\n public static override serialize(object: JsonValue): JsonParserResult {\n return StormJSON.instance.serialize(object);\n }\n\n /**\n * Parse the given string value with superjson using the given metadata\n *\n * @param value - The string value to parse\n * @returns The parsed data\n */\n public static override parse<TData = unknown>(value: string): TData {\n return parseValue(value);\n }\n\n /**\n * Serializes the given data to a JSON string.\n * By default the JSON string is formatted with a 2 space indentation to be easy readable.\n *\n * @param value - Object which should be serialized to JSON\n * @param _options - JSON serialize options\n * @returns the formatted JSON representation of the object\n */\n public static override stringify<T>(\n value: T,\n _options?: JsonSerializeOptions\n ): string {\n const customTransformer =\n StormJSON.instance.customTransformerRegistry.findApplicable(value);\n\n let result = value;\n if (customTransformer && customTransformer.isApplicable(value)) {\n result = customTransformer.serialize(result) as T;\n }\n\n return stringifyValue(result);\n }\n\n /**\n * Parses the given JSON string and returns the object the JSON content represents.\n * By default javascript-style comments and trailing commas are allowed.\n *\n * @param strData - JSON content as string\n * @param options - JSON parse options\n * @returns Object the JSON content represents\n */\n public static parseJson<TData = unknown>(\n strData: string,\n options?: JsonParseOptions\n ): TData {\n try {\n if (options?.expectComments === false) {\n return StormJSON.instance.parse(strData);\n }\n } catch {\n // Do nothing\n }\n\n const errors: ParseError[] = [];\n const opts = {\n allowTrailingComma: true,\n ...options\n };\n const result = parse(strData, errors, opts) as TData;\n\n if (errors.length > 0 && errors[0]) {\n throw new Error(formatParseError(strData, errors[0]));\n }\n\n return result;\n }\n\n /**\n * Register a custom schema with superjson\n *\n * @param name - The name of the schema\n * @param serialize - The function to serialize the schema\n * @param deserialize - The function to deserialize the schema\n * @param isApplicable - The function to check if the schema is applicable\n */\n public static register<\n TData = any,\n TJsonObject extends JsonValue = JsonValue\n >(\n name: string,\n serialize: (data: TData) => TJsonObject,\n deserialize: (json: TJsonObject) => TData,\n isApplicable: (data: any) => data is TData\n ) {\n StormJSON.instance.registerCustom<TData, TJsonObject>(\n {\n isApplicable,\n serialize,\n deserialize\n },\n name\n );\n }\n\n /**\n * Register a class with superjson\n *\n * @param classConstructor - The class constructor to register\n */\n public static override registerClass(\n classConstructor: Class,\n options?: { identifier?: string; allowProps?: string[] } | string\n ) {\n StormJSON.instance.registerClass(classConstructor, {\n identifier: isString(options)\n ? options\n : options?.identifier || classConstructor.name,\n allowProps:\n options &&\n isObject(options) &&\n options?.allowProps &&\n Array.isArray(options.allowProps)\n ? options.allowProps\n : [\"__typename\"]\n });\n }\n\n private constructor() {\n super({ dedupe: true });\n }\n}\n\nStormJSON.instance.registerCustom<Buffer, string>(\n {\n isApplicable: (v): v is Buffer => Buffer.isBuffer(v),\n serialize: v => v.toString(\"base64\"),\n deserialize: v => Buffer.from(v, \"base64\")\n },\n \"Bytes\"\n);\n"],"mappings":";;;;;;;;;;;;;;;;AA0CA,IAAa,YAAb,MAAa,kBAAkB,UAAU;CACvC,QAAOA;CAEP,WAAkB,WAAsB;AACtC,MAAI,CAAC,WAAUA,SACb,YAAUA,WAAY,IAAI,WAAW;AAGvC,SAAO,WAAUA;;;;;CAMnB,OAAuB,YACrB,SACO;AACP,SAAO,UAAU,SAAS,YAAY,QAAQ;;;;;CAMhD,OAAuB,UAAU,QAAqC;AACpE,SAAO,UAAU,SAAS,UAAU,OAAO;;;;;;;;CAS7C,OAAuB,MAAuB,OAAsB;AAClE,SAAOC,QAAW,MAAM;;;;;;;;;;CAW1B,OAAuB,UACrB,OACA,UACQ;EACR,MAAM,oBACJ,UAAU,SAAS,0BAA0B,eAAe,MAAM;EAEpE,IAAI,SAAS;AACb,MAAI,qBAAqB,kBAAkB,aAAa,MAAM,CAC5D,UAAS,kBAAkB,UAAU,OAAO;AAG9C,SAAOC,UAAe,OAAO;;;;;;;;;;CAW/B,OAAc,UACZ,SACA,SACO;AACP,MAAI;AACF,OAAI,SAAS,mBAAmB,MAC9B,QAAO,UAAU,SAAS,MAAM,QAAQ;UAEpC;EAIR,MAAMC,SAAuB,EAAE;EAK/B,MAAM,SAAS,MAAM,SAAS,QAJjB;GACX,oBAAoB;GACpB,GAAG;GACJ,CAC0C;AAE3C,MAAI,OAAO,SAAS,KAAK,OAAO,GAC9B,OAAM,IAAI,MAAM,iBAAiB,SAAS,OAAO,GAAG,CAAC;AAGvD,SAAO;;;;;;;;;;CAWT,OAAc,SAIZ,MACA,WACA,aACA,cACA;AACA,YAAU,SAAS,eACjB;GACE;GACA;GACA;GACD,EACD,KACD;;;;;;;CAQH,OAAuB,cACrB,kBACA,SACA;AACA,YAAU,SAAS,cAAc,kBAAkB;GACjD,YAAY,SAAS,QAAQ,GACzB,UACA,SAAS,cAAc,iBAAiB;GAC5C,YACE,WACA,SAAS,QAAQ,IACjB,SAAS,cACT,MAAM,QAAQ,QAAQ,WAAW,GAC7B,QAAQ,aACR,CAAC,aAAa;GACrB,CAAC;;CAGJ,AAAQ,cAAc;AACpB,QAAM,EAAE,QAAQ,MAAM,CAAC;;;AAI3B,UAAU,SAAS,eACjB;CACE,eAAe,MAAmB,OAAO,SAAS,EAAE;CACpD,YAAW,MAAK,EAAE,SAAS,SAAS;CACpC,cAAa,MAAK,OAAO,KAAK,GAAG,SAAS;CAC3C,EACD,QACD"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
//#region ../type-checks/src/get-object-tag.ts
|
|
3
|
-
/**
|
|
4
|
-
* Gets the `toStringTag` of `obj`.
|
|
5
|
-
*
|
|
6
|
-
* @param value - The obj to query.
|
|
7
|
-
* @returns Returns the `toStringTag`.
|
|
8
|
-
*/
|
|
9
|
-
const getObjectTag = (value) => {
|
|
10
|
-
if (value == null) return value === void 0 ? "[object Undefined]" : "[object Null]";
|
|
11
|
-
return Object.prototype.toString.call(value);
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
//#endregion
|
|
15
|
-
exports.getObjectTag = getObjectTag;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
//#region ../type-checks/src/get-object-tag.ts
|
|
2
|
-
/**
|
|
3
|
-
* Gets the `toStringTag` of `obj`.
|
|
4
|
-
*
|
|
5
|
-
* @param value - The obj to query.
|
|
6
|
-
* @returns Returns the `toStringTag`.
|
|
7
|
-
*/
|
|
8
|
-
const getObjectTag = (value) => {
|
|
9
|
-
if (value == null) return value === void 0 ? "[object Undefined]" : "[object Null]";
|
|
10
|
-
return Object.prototype.toString.call(value);
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
//#endregion
|
|
14
|
-
export { getObjectTag };
|
|
15
|
-
//# sourceMappingURL=get-object-tag.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-object-tag.mjs","names":[],"sources":["../../../../type-checks/src/get-object-tag.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\n/**\n * Gets the `toStringTag` of `obj`.\n *\n * @param value - The obj to query.\n * @returns Returns the `toStringTag`.\n */\nexport const getObjectTag = (value: unknown): string => {\n if (value == null) {\n return value === undefined ? \"[object Undefined]\" : \"[object Null]\";\n }\n return Object.prototype.toString.call(value);\n};\n"],"mappings":";;;;;;;AAwBA,MAAa,gBAAgB,UAA2B;AACtD,KAAI,SAAS,KACX,QAAO,UAAU,SAAY,uBAAuB;AAEtD,QAAO,OAAO,UAAU,SAAS,KAAK,MAAM"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
const require_is_undefined = require('./is-undefined.cjs');
|
|
2
|
-
const require_is_null = require('./is-null.cjs');
|
|
3
|
-
|
|
4
|
-
//#region ../type-checks/src/is-empty.ts
|
|
5
|
-
/**
|
|
6
|
-
* Check if the provided value's type is `null` or `undefined`
|
|
7
|
-
*
|
|
8
|
-
* @param value - The value to type check
|
|
9
|
-
* @returns An indicator specifying if the value provided is of type `null` or `undefined`
|
|
10
|
-
*/
|
|
11
|
-
const isEmpty = (value) => {
|
|
12
|
-
try {
|
|
13
|
-
return require_is_undefined.isUndefined(value) || require_is_null.isNull(value);
|
|
14
|
-
} catch {
|
|
15
|
-
return false;
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
//#endregion
|
|
20
|
-
exports.isEmpty = isEmpty;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { isUndefined } from "./is-undefined.mjs";
|
|
2
|
-
import { isNull } from "./is-null.mjs";
|
|
3
|
-
|
|
4
|
-
//#region ../type-checks/src/is-empty.ts
|
|
5
|
-
/**
|
|
6
|
-
* Check if the provided value's type is `null` or `undefined`
|
|
7
|
-
*
|
|
8
|
-
* @param value - The value to type check
|
|
9
|
-
* @returns An indicator specifying if the value provided is of type `null` or `undefined`
|
|
10
|
-
*/
|
|
11
|
-
const isEmpty = (value) => {
|
|
12
|
-
try {
|
|
13
|
-
return isUndefined(value) || isNull(value);
|
|
14
|
-
} catch {
|
|
15
|
-
return false;
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
//#endregion
|
|
20
|
-
export { isEmpty };
|
|
21
|
-
//# sourceMappingURL=is-empty.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"is-empty.mjs","names":[],"sources":["../../../../type-checks/src/is-empty.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { isDate } from \"./is-date\";\nimport { isFunction } from \"./is-function\";\nimport { isNull } from \"./is-null\";\nimport { isNumber } from \"./is-number\";\nimport { isSymbol } from \"./is-symbol\";\nimport { isUndefined } from \"./is-undefined\";\n\n/**\n * Check if the provided value's type is `null` or `undefined`\n *\n * @param value - The value to type check\n * @returns An indicator specifying if the value provided is of type `null` or `undefined`\n */\nexport const isEmpty = (value: unknown) => {\n try {\n return isUndefined(value) || isNull(value);\n } catch {\n return false;\n }\n};\n\nexport const isEmptyAnything = (value: any) => {\n if (value === true || value === false) return true;\n if (value === null || value === undefined) return true;\n if (isNumber(value)) return value === 0;\n if (isDate(value)) return Number.isNaN(value.getTime());\n if (isFunction(value)) return false;\n if (isSymbol(value)) return false;\n const { length } = value;\n if (isNumber(length)) return length === 0;\n const { size } = value;\n if (isNumber(size)) return size === 0;\n const keys = Object.keys(value).length;\n\n return keys === 0;\n};\n"],"mappings":";;;;;;;;;;AA+BA,MAAa,WAAW,UAAmB;AACzC,KAAI;AACF,SAAO,YAAY,MAAM,IAAI,OAAO,MAAM;SACpC;AACN,SAAO"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
const require_is_object = require('./is-object.cjs');
|
|
2
|
-
const require_is_set = require('./is-set.cjs');
|
|
3
|
-
|
|
4
|
-
//#region ../type-checks/src/is-non-null-object.ts
|
|
5
|
-
/**
|
|
6
|
-
* Check if the provided value's type is `Object` and is not `null` or `undefined`
|
|
7
|
-
*
|
|
8
|
-
* @param value - The value to type check
|
|
9
|
-
* @returns An indicator specifying if the value provided is of type `Object` and is not `null` or `undefined`
|
|
10
|
-
*/
|
|
11
|
-
const isNonNullObject = (value) => {
|
|
12
|
-
return require_is_set.isSet(value) && require_is_object.isObject(value);
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
//#endregion
|
|
16
|
-
exports.isNonNullObject = isNonNullObject;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { isObject } from "./is-object.mjs";
|
|
2
|
-
import { isSet } from "./is-set.mjs";
|
|
3
|
-
|
|
4
|
-
//#region ../type-checks/src/is-non-null-object.ts
|
|
5
|
-
/**
|
|
6
|
-
* Check if the provided value's type is `Object` and is not `null` or `undefined`
|
|
7
|
-
*
|
|
8
|
-
* @param value - The value to type check
|
|
9
|
-
* @returns An indicator specifying if the value provided is of type `Object` and is not `null` or `undefined`
|
|
10
|
-
*/
|
|
11
|
-
const isNonNullObject = (value) => {
|
|
12
|
-
return isSet(value) && isObject(value);
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
//#endregion
|
|
16
|
-
export { isNonNullObject };
|
|
17
|
-
//# sourceMappingURL=is-non-null-object.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"is-non-null-object.mjs","names":[],"sources":["../../../../type-checks/src/is-non-null-object.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { isObject } from \"./is-object\";\nimport { isSet } from \"./is-set\";\n\n/**\n * Check if the provided value's type is `Object` and is not `null` or `undefined`\n *\n * @param value - The value to type check\n * @returns An indicator specifying if the value provided is of type `Object` and is not `null` or `undefined`\n */\nexport const isNonNullObject = (value: any): value is NonNullable<object> => {\n return isSet(value) && isObject(value);\n};\n"],"mappings":";;;;;;;;;;AA2BA,MAAa,mBAAmB,UAA6C;AAC3E,QAAO,MAAM,MAAM,IAAI,SAAS,MAAM"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"is-null.mjs","names":[],"sources":["../../../../type-checks/src/is-null.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nexport const isNull = (value: unknown): value is null => {\n try {\n return value === null;\n } catch {\n return false;\n }\n};\n"],"mappings":";AAkBA,MAAa,UAAU,UAAkC;AACvD,KAAI;AACF,SAAO,UAAU;SACX;AACN,SAAO"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
//#region ../type-checks/src/is-number.ts
|
|
3
|
-
/**
|
|
4
|
-
* Check if the provided value's type is `number`
|
|
5
|
-
*
|
|
6
|
-
* @param value - The value to type check
|
|
7
|
-
* @returns An indicator specifying if the value provided is of type `number`
|
|
8
|
-
*/
|
|
9
|
-
const isNumber = (value) => {
|
|
10
|
-
try {
|
|
11
|
-
return value instanceof Number || typeof value === "number" || Number(value) === value;
|
|
12
|
-
} catch {
|
|
13
|
-
return false;
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
//#endregion
|
|
18
|
-
exports.isNumber = isNumber;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
//#region ../type-checks/src/is-number.ts
|
|
2
|
-
/**
|
|
3
|
-
* Check if the provided value's type is `number`
|
|
4
|
-
*
|
|
5
|
-
* @param value - The value to type check
|
|
6
|
-
* @returns An indicator specifying if the value provided is of type `number`
|
|
7
|
-
*/
|
|
8
|
-
const isNumber = (value) => {
|
|
9
|
-
try {
|
|
10
|
-
return value instanceof Number || typeof value === "number" || Number(value) === value;
|
|
11
|
-
} catch {
|
|
12
|
-
return false;
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
//#endregion
|
|
17
|
-
export { isNumber };
|
|
18
|
-
//# sourceMappingURL=is-number.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"is-number.mjs","names":[],"sources":["../../../../type-checks/src/is-number.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { AnyNumber } from \"@stryke/types/base\";\nimport { getObjectTag } from \"./get-object-tag\";\n\n/**\n * Check if the provided value's type is `number`\n *\n * @param value - The value to type check\n * @returns An indicator specifying if the value provided is of type `number`\n */\nexport const isNumber = (value: unknown): value is number => {\n try {\n return (\n value instanceof Number ||\n typeof value === \"number\" ||\n Number(value) === value\n );\n } catch {\n return false;\n }\n};\n\n/**\n * Check if the provided value's type is `AnyNumber`\n *\n * @param value - The value to type check\n * @returns An indicator specifying if the value provided is of type `AnyNumber`\n */\nexport function isAnyNumber(value?: any): value is AnyNumber {\n return isNumber(value) || getObjectTag(value) === \"[object Number]\";\n}\n"],"mappings":";;;;;;;AA2BA,MAAa,YAAY,UAAoC;AAC3D,KAAI;AACF,SACE,iBAAiB,UACjB,OAAO,UAAU,YACjB,OAAO,MAAM,KAAK;SAEd;AACN,SAAO"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
const require_is_plain_object = require('./is-plain-object.cjs');
|
|
2
|
-
|
|
3
|
-
//#region ../type-checks/src/is-object.ts
|
|
4
|
-
/**
|
|
5
|
-
* Check if the provided value's type is `Object`
|
|
6
|
-
*
|
|
7
|
-
* @param value - The value to type check
|
|
8
|
-
* @returns An indicator specifying if the value provided is of type `Object`
|
|
9
|
-
*/
|
|
10
|
-
const isObject = (value) => {
|
|
11
|
-
try {
|
|
12
|
-
return typeof value === "object" || Boolean(value) && value?.constructor === Object || require_is_plain_object.isPlainObject(value);
|
|
13
|
-
} catch {
|
|
14
|
-
return false;
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
//#endregion
|
|
19
|
-
exports.isObject = isObject;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { isPlainObject } from "./is-plain-object.mjs";
|
|
2
|
-
|
|
3
|
-
//#region ../type-checks/src/is-object.ts
|
|
4
|
-
/**
|
|
5
|
-
* Check if the provided value's type is `Object`
|
|
6
|
-
*
|
|
7
|
-
* @param value - The value to type check
|
|
8
|
-
* @returns An indicator specifying if the value provided is of type `Object`
|
|
9
|
-
*/
|
|
10
|
-
const isObject = (value) => {
|
|
11
|
-
try {
|
|
12
|
-
return typeof value === "object" || Boolean(value) && value?.constructor === Object || isPlainObject(value);
|
|
13
|
-
} catch {
|
|
14
|
-
return false;
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
//#endregion
|
|
19
|
-
export { isObject };
|
|
20
|
-
//# sourceMappingURL=is-object.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"is-object.mjs","names":[],"sources":["../../../../type-checks/src/is-object.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\n/* eslint-disable ts/no-unsafe-function-type */\n/* eslint-disable ts/no-unsafe-call */\n\nimport type { NativeClass } from \"@stryke/types/base\";\nimport { isPlainObject } from \"./is-plain-object\";\n\n// Prepare\nconst isClassRegex = /^class\\s|^function\\s+[A-Z]/;\nconst isConventionalClassRegex = /^function\\s+[A-Z]/;\nconst isNativeClassRegex = /^class\\s/;\n\n/** Is ES6+ class */\nexport function isNativeClass(value?: any): value is NativeClass {\n // NOTE TO DEVELOPER: If any of this changes, isClass must also be updated\n return (\n typeof value === \"function\" && isNativeClassRegex.test(value.toString())\n );\n}\n\n/**\n * Check if the provided value's type is a conventional class\n *\n * @remarks\n * Is Conventional Class\n * Looks for function with capital first letter MyClass\n * First letter is the 9th character\n * If changed, isClass must also be updated\n *\n * @param value - The value to type check\n * @returns An indicator specifying if the value provided is a conventional class\n */\nexport function isConventionalClass(value?: any): value is Function {\n return (\n typeof value === \"function\" &&\n isConventionalClassRegex.test(value.toString())\n );\n}\n\n/**\n * Check if the provided value's type is `Object`\n *\n * @param value - The value to type check\n * @returns An indicator specifying if the value provided is of type `Object`\n */\nexport function isClass(value?: any): value is Function | NativeClass; // only guarantee of truth type, not of validity\nexport function isClass(value?: any): boolean {\n return typeof value === \"function\" && isClassRegex.test(value.toString());\n}\n\n/**\n * Check if the provided value's type is `Object`\n *\n * @param value - The value to type check\n * @returns An indicator specifying if the value provided is of type `Object`\n */\nexport const isObject = (value: unknown): value is object => {\n try {\n return (\n typeof value === \"object\" ||\n (Boolean(value) && value?.constructor === Object) ||\n isPlainObject(value)\n );\n } catch {\n return false;\n }\n};\n"],"mappings":";;;;;;;;;AAyEA,MAAa,YAAY,UAAoC;AAC3D,KAAI;AACF,SACE,OAAO,UAAU,YAChB,QAAQ,MAAM,IAAI,OAAO,gBAAgB,UAC1C,cAAc,MAAM;SAEhB;AACN,SAAO"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"is-plain-object.mjs","names":[],"sources":["../../../../type-checks/src/is-plain-object.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { PlainObject } from \"@stryke/types/base\";\nimport { getObjectTag } from \"./get-object-tag\";\n\n/**\n * Checks if `value` is object-like. A value is object-like if it's not `null`\n * and has a `typeof` result of \"object\".\n *\n * @example\n * ```typescript\n * isObjectLike({})\n * // => true\n *\n * isObjectLike([1, 2, 3])\n * // => true\n *\n * isObjectLike(Function)\n * // => false\n *\n * isObjectLike(null)\n * // => false\n * ```\n *\n * @param value - The value to check.\n * @returns Returns `true` if `value` is object-like, else `false`.\n */\nexport const isObjectLike = (obj: unknown) => {\n return typeof obj === \"object\" && obj !== null;\n};\n\n/**\n * Checks if `obj` is a plain object, that is, an object created by the `Object` constructor or one with a `[[Prototype]]` of `null`.\n *\n * @example\n * ```typescript\n * function Foo() {\n * this.a = 1\n * }\n *\n * isPlainObject(new Foo)\n * // => false\n *\n * isPlainObject([1, 2, 3])\n * // => false\n *\n * isPlainObject({ 'x': 0, 'y': 0 })\n * // => true\n *\n * isPlainObject(Object.create(null))\n * // => true\n * ```\n *\n * @param obj - The value to check.\n * @returns Returns `true` if `obj` is a plain object, else `false`.\n */\nexport const isPlainObject = (obj: unknown): obj is PlainObject => {\n if (!isObjectLike(obj) || getObjectTag(obj) !== \"[object Object]\") {\n return false;\n }\n if (Object.getPrototypeOf(obj) === null) {\n return true;\n }\n let proto = obj;\n while (Object.getPrototypeOf(proto) !== null) {\n proto = Object.getPrototypeOf(proto);\n }\n return Object.getPrototypeOf(obj) === proto;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA2CA,MAAa,gBAAgB,QAAiB;AAC5C,QAAO,OAAO,QAAQ,YAAY,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4B5C,MAAa,iBAAiB,QAAqC;AACjE,KAAI,CAAC,aAAa,IAAI,IAAI,aAAa,IAAI,KAAK,kBAC9C,QAAO;AAET,KAAI,OAAO,eAAe,IAAI,KAAK,KACjC,QAAO;CAET,IAAI,QAAQ;AACZ,QAAO,OAAO,eAAe,MAAM,KAAK,KACtC,SAAQ,OAAO,eAAe,MAAM;AAEtC,QAAO,OAAO,eAAe,IAAI,KAAK"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
const require_is_non_null_object = require('./is-non-null-object.cjs');
|
|
2
|
-
|
|
3
|
-
//#region ../type-checks/src/is-set-object.ts
|
|
4
|
-
/**
|
|
5
|
-
* Check if the provided value's type is an object with some fields set
|
|
6
|
-
*
|
|
7
|
-
* @param value - The value to type check
|
|
8
|
-
* @returns An indicator specifying if the value provided is an object with some fields se
|
|
9
|
-
*/
|
|
10
|
-
const isSetObject = (value) => {
|
|
11
|
-
try {
|
|
12
|
-
return require_is_non_null_object.isNonNullObject(value) && Object.keys(value).length > 0;
|
|
13
|
-
} catch {
|
|
14
|
-
return false;
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
//#endregion
|
|
19
|
-
exports.isSetObject = isSetObject;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { isNonNullObject } from "./is-non-null-object.mjs";
|
|
2
|
-
|
|
3
|
-
//#region ../type-checks/src/is-set-object.ts
|
|
4
|
-
/**
|
|
5
|
-
* Check if the provided value's type is an object with some fields set
|
|
6
|
-
*
|
|
7
|
-
* @param value - The value to type check
|
|
8
|
-
* @returns An indicator specifying if the value provided is an object with some fields se
|
|
9
|
-
*/
|
|
10
|
-
const isSetObject = (value) => {
|
|
11
|
-
try {
|
|
12
|
-
return isNonNullObject(value) && Object.keys(value).length > 0;
|
|
13
|
-
} catch {
|
|
14
|
-
return false;
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
//#endregion
|
|
19
|
-
export { isSetObject };
|
|
20
|
-
//# sourceMappingURL=is-set-object.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"is-set-object.mjs","names":[],"sources":["../../../../type-checks/src/is-set-object.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { isNonNullObject } from \"./is-non-null-object\";\n\n/**\n * Check if the provided value's type is an object with some fields set\n *\n * @param value - The value to type check\n * @returns An indicator specifying if the value provided is an object with some fields se\n */\nexport const isSetObject = (value: unknown): value is NonNullable<object> => {\n try {\n return isNonNullObject(value) && Object.keys(value).length > 0;\n } catch {\n return false;\n }\n};\n"],"mappings":";;;;;;;;;AA0BA,MAAa,eAAe,UAAiD;AAC3E,KAAI;AACF,SAAO,gBAAgB,MAAM,IAAI,OAAO,KAAK,MAAM,CAAC,SAAS;SACvD;AACN,SAAO"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
const require_is_empty = require('./is-empty.cjs');
|
|
2
|
-
|
|
3
|
-
//#region ../type-checks/src/is-set.ts
|
|
4
|
-
/**
|
|
5
|
-
* The inverse of the `isEmpty` function
|
|
6
|
-
*
|
|
7
|
-
* @param value - The value to type check
|
|
8
|
-
* @returns An indicator specifying if the value provided is **NOT** of type `null` or `undefined`
|
|
9
|
-
*/
|
|
10
|
-
const isSet = (value) => {
|
|
11
|
-
try {
|
|
12
|
-
return !require_is_empty.isEmpty(value);
|
|
13
|
-
} catch {
|
|
14
|
-
return false;
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
//#endregion
|
|
19
|
-
exports.isSet = isSet;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { isEmpty } from "./is-empty.mjs";
|
|
2
|
-
|
|
3
|
-
//#region ../type-checks/src/is-set.ts
|
|
4
|
-
/**
|
|
5
|
-
* The inverse of the `isEmpty` function
|
|
6
|
-
*
|
|
7
|
-
* @param value - The value to type check
|
|
8
|
-
* @returns An indicator specifying if the value provided is **NOT** of type `null` or `undefined`
|
|
9
|
-
*/
|
|
10
|
-
const isSet = (value) => {
|
|
11
|
-
try {
|
|
12
|
-
return !isEmpty(value);
|
|
13
|
-
} catch {
|
|
14
|
-
return false;
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
//#endregion
|
|
19
|
-
export { isSet };
|
|
20
|
-
//# sourceMappingURL=is-set.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"is-set.mjs","names":[],"sources":["../../../../type-checks/src/is-set.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { isEmpty } from \"./is-empty\";\n\n/**\n * The inverse of the `isEmpty` function\n *\n * @param value - The value to type check\n * @returns An indicator specifying if the value provided is **NOT** of type `null` or `undefined`\n */\nexport const isSet = (value: unknown): value is NonNullable<unknown> => {\n try {\n return !isEmpty(value);\n } catch {\n return false;\n }\n};\n"],"mappings":";;;;;;;;;AA0BA,MAAa,SAAS,UAAkD;AACtE,KAAI;AACF,SAAO,CAAC,QAAQ,MAAM;SAChB;AACN,SAAO"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"is-string.mjs","names":[],"sources":["../../../../type-checks/src/is-string.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nexport const isString = (value: unknown): value is string => {\n try {\n return typeof value === \"string\";\n } catch {\n return false;\n }\n};\n"],"mappings":";AAkBA,MAAa,YAAY,UAAoC;AAC3D,KAAI;AACF,SAAO,OAAO,UAAU;SAClB;AACN,SAAO"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"is-undefined.mjs","names":[],"sources":["../../../../type-checks/src/is-undefined.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nexport const isUndefined = (value: unknown): value is undefined => {\n return value === undefined;\n};\n"],"mappings":";AAkBA,MAAa,eAAe,UAAuC;AACjE,QAAO,UAAU"}
|
package/dist/types/src/base.cjs
DELETED
package/dist/types/src/base.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"base.mjs","names":[],"sources":["../../../../types/src/base.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { TypedArray } from \"./array\";\n\nexport type SerializablePrimitive =\n | null\n | undefined\n | string\n | number\n | boolean\n | bigint;\nexport type Primitive = SerializablePrimitive | symbol;\n\n/**\n * Matches any primitive, `void`, `Date`, or `RegExp` value.\n */\nexport type BuiltIns = Primitive | void | Date | RegExp;\n\n/**\n * Matches any non-primitive object\n */\n// eslint-disable-next-line ts/no-unsafe-function-type\nexport type AtomicObject = Function | Promise<any> | Date | RegExp;\n\n/** Determines if the passed value is of a specific type */\nexport type TypeTester = (value: any) => boolean;\n\n/**\n * The interface for a type mapping (key =\\> function) to use for {@link getType}.\n * export * The key represents the name of the type. The function represents the {@link TypeTester | test method}.\n * The map should be ordered by testing preference, with more specific tests first.\n * If a test returns true, it is selected, and the key is returned as the type.\n */\nexport type TypeMap = Record<string, TypeTester>;\n\ndeclare const emptyObjectSymbol: unique symbol;\n\nexport type FunctionOrValue<Value> = Value extends () => infer X ? X : Value;\n\n/**\n * A [[List]]\n *\n * @example\n * ```ts\n * type list0 = [1, 2, 3]\n * type list1 = number[]\n * ```\n *\n * @param A - its type\n * @returns [[List]]\n */\nexport type List<A = any> = ReadonlyArray<A>;\n\n/**\n * Alias to create a [[Function]]\n *\n * @example\n * ```ts\n * import { FunctionLike } from '@stryke/types'\n *\n * type test0 = FunctionLike<[string, number], boolean>\n * /// (args_0: string, args_1: number) => boolean\n * ```\n *\n * @param P - parameters\n * @param R - return type\n * @returns [[Function]]\n */\nexport type FunctionLike<P extends List = any, R = any> = (...args: P) => R;\n\nexport type AnyFunction = FunctionLike<any, any>;\nexport type Nullish = undefined | null;\nexport type Nullishable<T> = T | Nullish;\nexport type NonNullishObject = object; // not null/undefined which are Object\nexport type NativeClass = abstract new (...args: any) => any;\nexport type AnyNumber = number | number;\nexport type AnyString = string | string;\nexport type AnyBoolean = boolean | boolean;\nexport type AnyArray = any[];\nexport type PlainObject = Record<any, object>; // https://stackoverflow.com/a/75052315/130638\nexport type AnyMap = Map<any, any>;\nexport type AnyWeakMap = WeakMap<WeakKey, any>;\nexport type EmptyArray = [];\nexport interface EmptyObject {\n [emptyObjectSymbol]?: never;\n}\n\nexport type Any =\n | boolean\n | number\n | bigint\n | string\n | null\n | undefined\n | void\n | symbol\n | object\n | PlainObject\n | AnyArray\n | AnyMap\n | AnyWeakMap;\n\n/**\n * The valid types of the index for an `Indexable` type object\n */\nexport type IndexType = string | number | symbol;\n\n/**\n * The declaration of a ***dictionary-type*** object with a specific type\n *\n * @see {@link Indexable}\n * @see {@link IndexType}\n * @see {@link Dictionary}\n */\nexport type TypedIndexable<T> = Record<IndexType, T>;\n\n/**\n * The declaration of a ***dictionary-type*** object\n *\n * @see {@link TypedIndexable}\n * @see {@link IndexType}\n * @see {@link Dictionary}\n */\nexport type Indexable = TypedIndexable<any>;\n\n/**\n * The declaration of a ***dictionary-type*** object with a specific type\n *\n * @see {@link Indexable}\n * @see {@link IndexType}\n * @see {@link TypedIndexable}\n */\nexport type Dictionary<T> = Record<string, T>;\n\nexport const EMPTY_STRING = \"\";\nexport const NEWLINE_STRING = \"\\r\\n\";\nexport const EMPTY_OBJECT = {};\n\nexport type AnyCase<T extends IndexType> = string extends T\n ? string\n : T extends `${infer F1}${infer F2}${infer R}`\n ? `${Uppercase<F1> | Lowercase<F1>}${Uppercase<F2> | Lowercase<F2>}${AnyCase<R>}`\n : T extends `${infer F}${infer R}`\n ? `${Uppercase<F> | Lowercase<F>}${AnyCase<R>}`\n : typeof EMPTY_STRING;\n\nexport type Newable<T> = new (..._args: never[]) => T;\n\nexport interface Abstract<T> {\n prototype: T;\n}\n\nexport interface Clonable<T> {\n clone: () => T;\n}\n\nexport type MaybePromise<T> = T | Promise<T>;\n\nexport type ReducerFunction<TState, TAction> = (\n state: TState,\n action: TAction\n) => TState;\n\n// NOTE: for the file size optimization\nexport const TYPE_ARGUMENTS = \"Arguments\";\nexport const TYPE_ARRAY = \"Array\";\nexport const TYPE_OBJECT = \"Object\";\nexport const TYPE_MAP = \"Map\";\nexport const TYPE_SET = \"Set\";\n\nexport type Collection =\n | IArguments\n | unknown[]\n | Map<unknown, unknown>\n | Record<string | number | symbol, unknown>\n | Set<unknown>;\n\nexport type NonUndefined<T> = T extends undefined ? never : T;\n\nexport type BrowserNativeObject = Date | File;\n\nexport type DeepPartial<T> = T extends BrowserNativeObject | NestedValue\n ? T\n : {\n [K in keyof T]?: DeepPartial<T[K]>;\n };\n\nexport type Rollback = Record<\n string,\n (initialValue: any, currentValue: any) => any\n>;\n\n/**\n * Extract all required keys from the given type.\n *\n * @remarks\n * This is useful when you want to create a new type that contains different type values for the required keys only or use the list of keys for validation purposes, etc...\n */\nexport type RequiredKeysOf<BaseType extends object> = Exclude<\n {\n [Key in keyof BaseType]: BaseType extends Record<Key, BaseType[Key]>\n ? Key\n : never;\n }[keyof BaseType],\n undefined\n>;\n\n/**\n * Returns a boolean for whether the two given types are equal.\n *\n * @remarks\n * Use-cases: If you want to make a conditional branch based on the result of a comparison of two types.\n *\n * @see https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650\n * @see https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796\n */\nexport type IsEqual<A, B> =\n (<G>() => G extends A ? 1 : 2) extends <G>() => G extends B ? 1 : 2\n ? true\n : false;\n\nexport type Filter<KeyType, ExcludeType> =\n IsEqual<KeyType, ExcludeType> extends true\n ? never\n : KeyType extends ExcludeType\n ? never\n : KeyType;\n\ninterface ExceptOptions {\n /**\n Disallow assigning non-specified properties.\n\n Note that any omitted properties in the resulting type will be present in autocomplete as `undefined`.\n\n @defaultValue false\n */\n requireExactProps?: boolean;\n}\n\n/**\n * Create a type from an object type without certain keys.\n *\n * @remarks\n * We recommend setting the `requireExactProps` option to `true`.\n *\n * This type is a stricter version of [`Omit`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-5.html#the-omit-helper-type). The `Omit` type does not restrict the omitted keys to be keys present on the given type, while `Except` does. The benefits of a stricter type are avoiding typos and allowing the compiler to pick up on rename refactors automatically.\n *\n * This type was proposed to the TypeScript team, which declined it, saying they prefer that libraries implement stricter versions of the built-in types ([microsoft/TypeScript#30825](https://github.com/microsoft/TypeScript/issues/30825#issuecomment-523668235)).\n */\nexport type Except<\n ObjectType,\n KeysType extends keyof ObjectType,\n Options extends ExceptOptions = { requireExactProps: false }\n> = {\n [KeyType in keyof ObjectType as Filter<\n KeyType,\n KeysType\n >]: ObjectType[KeyType];\n} & (Options[\"requireExactProps\"] extends true\n ? Partial<Record<KeysType, never>>\n : Record<string, never>);\n\n/**\n * Useful to flatten the type output to improve type hints shown in editors. And also to transform an interface into a type to aide with assignability.\n *\n * @remarks\n * Sometimes it is desired to pass a value as a function argument that has a different type. At first inspection it may seem assignable, and then you discover it is not because the `value`'s type definition was defined as an interface. In the following example, `fn` requires an argument of type `Record<string, unknown>`. If the value is defined as a literal, then it is assignable. And if the `value` is defined as type using the `Simplify` utility the value is assignable. But if the `value` is defined as an interface, it is not assignable because the interface is not sealed and elsewhere a non-string property could be added to the interface.\n *\n * If the type definition must be an interface (perhaps it was defined in a third-party npm package), then the `value` can be defined as `const value: Simplify<SomeInterface> = ...`. Then `value` will be assignable to the `fn` argument. Or the `value` can be cast as `Simplify<SomeInterface>` if you can't re-declare the `value`.\n *\n * @see https://github.com/microsoft/TypeScript/issues/15300\n */\nexport type Simplify<T> = { [KeyType in keyof T]: T[KeyType] } & {};\n\n/**\n * Create a type that makes the given keys required. The remaining keys are kept as is. The sister of the `SetOptional` type.\n *\n * @remarks\n * Use-case: You want to define a single model where the only thing that changes is whether or not some of the keys are required.\n */\nexport type SetRequired<\n BaseType,\n Keys extends keyof BaseType\n> = BaseType extends unknown // type](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html#distributive-conditional-types). // union into a [distributive conditional // `extends unknown` is always going to be the case and is used to convert any\n ? Simplify<\n // Pick just the keys that are optional from the base type.\n Except<BaseType, Keys> &\n // Pick the keys that should be required from the base type and make them required.\n Required<Pick<BaseType, Keys>>\n >\n : never;\n\nexport const $NestedValue: unique symbol = Symbol(\"NestedValue\");\n\nexport type NestedValue<TValue extends object = object> = {\n [$NestedValue]: never;\n} & TValue;\n\nexport interface RefObject<T> {\n current: T;\n}\n\nexport interface Identity<T = string> {\n id: T;\n}\n\nexport interface Versioned {\n version: number;\n}\n\nexport interface Sequenced {\n /**\n * The sequence number (version, or event counter, etc.) of the record\n */\n sequence: number;\n}\n\nexport interface Typed {\n /**\n * The type of the record\n */\n __type: string;\n}\n\nexport interface ClassTypeCheckable<T> extends Typed {\n /**\n * Run type check on the given value\n * @param value - The value to check\n * @returns True if the value is of the type of the class\n */\n isTypeOf: (value: unknown) => value is T;\n}\n\n/**\n * Matches non-recursive types.\n */\nexport type NonRecursiveType =\n | BuiltIns\n // eslint-disable-next-line ts/no-unsafe-function-type\n | Function\n | (new (...arguments_: any[]) => unknown);\n\nexport type IsPrimitive<T> = [T] extends [Primitive] ? true : false;\nexport type IsNever<T> = [T] extends [never] ? true : false;\nexport type IsAny<T> = 0 extends 1 & T ? true : false;\nexport type IsNull<T> = [T] extends [null] ? true : false;\nexport type IsUndefined<T> = T extends undefined ? true : false;\nexport type IsUnknown<T> = unknown extends T // `T` can be `unknown` or `any`\n ? IsNull<T> extends false // `any` can be `null`, but `unknown` can't be\n ? true\n : false\n : false;\nexport type IsNullish<T> = IsNull<T> & IsUndefined<T>;\nexport type IsFunction<T> = T extends AnyFunction ? true : false;\n\n/**\n * Declare locally scoped properties on `globalThis`.\n *\n * When defining a global variable in a declaration file is inappropriate, it can be helpful to define a `type` or `interface` (say `ExtraGlobals`) with the global variable and then cast `globalThis` via code like `globalThis as unknown as ExtraGlobals`.\n *\n * Instead of casting through `unknown`, you can update your `type` or `interface` to extend `GlobalThis` and then directly cast `globalThis`.\n *\n * @example\n * ```\n * import type { GlobalThis } from '@stryke/types';\n *\n * type ExtraGlobals = GlobalThis & {\n * readonly GLOBAL_TOKEN: string;\n * };\n *\n * (globalThis as ExtraGlobals).GLOBAL_TOKEN;\n * ```\n */\nexport type GlobalThis = typeof globalThis;\n\n/**\n * Matches a [`class`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes).\n */\nexport interface Class<T, Arguments extends unknown[] = any[]> {\n prototype: Pick<T, keyof T>;\n new (...arguments_: Arguments): T;\n}\n\n/**\n * Matches a [`class` constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes).\n */\nexport type Constructor<T, Arguments extends unknown[] = any[]> = new (\n ...arguments_: Arguments\n) => T;\n\n/**\n * Matches an [`abstract class`](https://www.typescriptlang.org/docs/handbook/classes.html#abstract-classes).\n *\n * @privateRemarks\n * We cannot use a `type` here because TypeScript throws: 'abstract' modifier cannot appear on a type member. (1070)\n */\n\nexport interface AbstractClass<\n T,\n Arguments extends unknown[] = any[]\n> extends AbstractConstructor<T, Arguments> {\n prototype: Pick<T, keyof T>;\n}\n\n/**\n * Matches an [`abstract class`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-2.html#abstract-construct-signatures) constructor.\n */\nexport type AbstractConstructor<\n T,\n Arguments extends unknown[] = any[]\n> = abstract new (...arguments_: Arguments) => T;\n\n/**\n * Create a tuple type of the given length `<L>` and fill it with the given type `<Fill>`.\n *\n * If `<Fill>` is not provided, it will default to `unknown`.\n *\n * @see https://itnext.io/implementing-arithmetic-within-typescripts-type-system-a1ef140a6f6f\n */\nexport type BuildTuple<\n L extends number,\n Fill = unknown,\n T extends readonly unknown[] = []\n> = T[\"length\"] extends L ? T : BuildTuple<L, Fill, [...T, Fill]>;\n\n/**\n * Test if the given function has multiple call signatures.\n *\n * Needed to handle the case of a single call signature with properties.\n *\n * Multiple call signatures cannot currently be supported due to a TypeScript limitation.\n * @see https://github.com/microsoft/TypeScript/issues/29732\n */\nexport type HasMultipleCallSignatures<\n T extends (...arguments_: any[]) => unknown\n> = T extends {\n (...arguments_: infer A): unknown;\n (...arguments_: infer B): unknown;\n}\n ? B extends A\n ? A extends B\n ? false\n : true\n : true\n : false;\n\ntype StructuredCloneablePrimitive =\n | string\n | number\n | bigint\n | boolean\n | null\n | undefined\n | boolean\n | number\n | string;\n\ntype StructuredCloneableData =\n | ArrayBuffer\n | DataView\n | Date\n | Error\n | RegExp\n | TypedArray\n | Blob\n | File;\n\n// DOM exclusive types\n// | AudioData\n// | CropTarget\n// | CryptoKey\n// | DOMException\n// | DOMMatrix\n// | DOMMatrixReadOnly\n// | DOMPoint\n// | DOMPointReadOnly\n// | DOMQuad\n// | DOMRect\n// | DOMRectReadOnly\n// | FileList\n// | FileSystemDirectoryHandle\n// | FileSystemFileHandle\n// | FileSystemHandle\n// | GPUCompilationInfo\n// | GPUCompilationMessage\n// | ImageBitmap\n// | ImageData\n// | RTCCertificate\n// | VideoFrame\n\ntype StructuredCloneableCollection =\n | readonly StructuredCloneable[]\n | {\n readonly [key: string]: StructuredCloneable;\n readonly [key: number]: StructuredCloneable;\n }\n | ReadonlyMap<StructuredCloneable, StructuredCloneable>\n | ReadonlySet<StructuredCloneable>;\n\n/**\n * Matches a value that can be losslessly cloned using `structuredClone`.\n *\n * Note:\n * - Custom error types will be cloned as the base `Error` type\n * - This type doesn't include types exclusive to the TypeScript DOM library (e.g. `DOMRect` and `VideoFrame`)\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm\n *\n * @example\n * ```\n * import type { StructuredCloneable } from '@stryke/types';\n *\n * class CustomClass {}\n *\n * // @ts-expect-error\n * const error: StructuredCloneable = {\n * custom: new CustomClass(),\n * };\n *\n * structuredClone(error);\n * //=> {custom: {}}\n *\n * const good: StructuredCloneable = {\n * number: 3,\n * date: new Date(),\n * map: new Map<string, number>(),\n * }\n *\n * good.map.set('key', 1);\n *\n * structuredClone(good);\n * //=> {number: 3, date: Date(2022-10-17 22:22:35.920), map: Map {'key' -> 1}}\n * ```\n */\nexport type StructuredCloneable =\n | StructuredCloneablePrimitive\n | StructuredCloneableData\n | StructuredCloneableCollection;\n"],"mappings":";AAsJA,MAAa,eAAe"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
//#region ../types/src/json.d.ts
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Matches a JSON pointer's path segments.
|
|
5
|
-
*
|
|
6
|
-
* @remarks
|
|
7
|
-
* These segments are used to navigate through the JSON object structure and point to a specific, referenced value.
|
|
8
|
-
*/
|
|
9
|
-
type JsonPointerPath = (string | number)[];
|
|
10
|
-
//#endregion
|
|
11
|
-
export { JsonPointerPath };
|
|
12
|
-
//# sourceMappingURL=json.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"json.d.cts","names":[],"sources":["../../../../types/src/json.ts"],"sourcesContent":[],"mappings":";;;;;;;;KA6CY,eAAA"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
//#region ../types/src/json.d.ts
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Matches a JSON pointer's path segments.
|
|
5
|
-
*
|
|
6
|
-
* @remarks
|
|
7
|
-
* These segments are used to navigate through the JSON object structure and point to a specific, referenced value.
|
|
8
|
-
*/
|
|
9
|
-
type JsonPointerPath = (string | number)[];
|
|
10
|
-
//#endregion
|
|
11
|
-
export { JsonPointerPath };
|
|
12
|
-
//# sourceMappingURL=json.d.mts.map
|