@stryke/json 0.9.26 → 0.9.28
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 +14 -0
- package/dist/_virtual/rolldown_runtime.cjs +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +7 -7
- package/dist/index.d.mts +8 -8
- package/dist/index.mjs +1 -1
- package/dist/pointer/find-reference.cjs +1 -1
- package/dist/pointer/find-reference.d.cts +52 -2
- package/dist/pointer/find-reference.d.cts.map +1 -0
- package/dist/pointer/find-reference.d.mts +52 -2
- package/dist/pointer/find-reference.d.mts.map +1 -0
- package/dist/pointer/find-reference.mjs +2 -1
- package/dist/pointer/find-reference.mjs.map +1 -0
- package/dist/pointer/index.cjs +1 -1
- package/dist/pointer/index.d.cts +2 -2
- package/dist/pointer/index.d.mts +2 -2
- package/dist/pointer/index.mjs +1 -1
- package/dist/pointer/parse.cjs +1 -1
- package/dist/pointer/parse.d.cts +44 -2
- package/dist/pointer/parse.d.cts.map +1 -0
- package/dist/pointer/parse.d.mts +44 -2
- package/dist/pointer/parse.d.mts.map +1 -0
- package/dist/pointer/parse.mjs +2 -1
- package/dist/pointer/parse.mjs.map +1 -0
- package/dist/storm-json.cjs +1 -1
- package/dist/storm-json.d.cts +70 -2
- package/dist/storm-json.d.cts.map +1 -0
- package/dist/storm-json.d.mts +70 -3
- package/dist/storm-json.d.mts.map +1 -0
- package/dist/storm-json.mjs +2 -1
- package/dist/storm-json.mjs.map +1 -0
- package/dist/type-checks/src/get-object-tag.cjs +1 -0
- package/dist/type-checks/src/get-object-tag.mjs +2 -0
- package/dist/type-checks/src/get-object-tag.mjs.map +1 -0
- package/dist/type-checks/src/is-empty.cjs +1 -0
- package/dist/type-checks/src/is-empty.mjs +2 -0
- package/dist/type-checks/src/is-empty.mjs.map +1 -0
- package/dist/type-checks/src/is-non-null-object.cjs +1 -0
- package/dist/type-checks/src/is-non-null-object.mjs +2 -0
- package/dist/type-checks/src/is-non-null-object.mjs.map +1 -0
- package/dist/type-checks/src/is-null.cjs +1 -0
- package/dist/type-checks/src/is-null.mjs +2 -0
- package/dist/type-checks/src/is-null.mjs.map +1 -0
- package/dist/type-checks/src/is-number.cjs +1 -0
- package/dist/type-checks/src/is-number.mjs +2 -0
- package/dist/type-checks/src/is-number.mjs.map +1 -0
- package/dist/type-checks/src/is-object.cjs +1 -0
- package/dist/type-checks/src/is-object.mjs +2 -0
- package/dist/type-checks/src/is-object.mjs.map +1 -0
- package/dist/type-checks/src/is-plain-object.cjs +1 -0
- package/dist/type-checks/src/is-plain-object.mjs +2 -0
- package/dist/type-checks/src/is-plain-object.mjs.map +1 -0
- package/dist/type-checks/src/is-set-object.cjs +1 -0
- package/dist/type-checks/src/is-set-object.mjs +2 -0
- package/dist/type-checks/src/is-set-object.mjs.map +1 -0
- package/dist/type-checks/src/is-set.cjs +1 -0
- package/dist/type-checks/src/is-set.mjs +2 -0
- package/dist/type-checks/src/is-set.mjs.map +1 -0
- package/dist/{is-string-VB7nGKjX.mjs → type-checks/src/is-string.cjs} +1 -2
- package/dist/type-checks/src/is-string.mjs +2 -0
- package/dist/type-checks/src/is-string.mjs.map +1 -0
- package/dist/type-checks/src/is-undefined.cjs +1 -0
- package/dist/type-checks/src/is-undefined.mjs +2 -0
- package/dist/type-checks/src/is-undefined.mjs.map +1 -0
- package/dist/types/src/base.cjs +1 -0
- package/dist/types/src/base.mjs +2 -0
- package/dist/types/src/base.mjs.map +1 -0
- package/dist/types/src/json.d.cts +12 -0
- package/dist/types/src/json.d.cts.map +1 -0
- package/dist/types/src/json.d.mts +12 -0
- package/dist/types/src/json.d.mts.map +1 -0
- package/dist/types.d.cts +69 -2
- package/dist/types.d.cts.map +1 -0
- package/dist/types.d.mts +69 -2
- package/dist/types.d.mts.map +1 -0
- package/dist/utils/code-frames.cjs +3 -1
- package/dist/utils/code-frames.d.cts +17 -2
- package/dist/utils/code-frames.d.cts.map +1 -0
- package/dist/utils/code-frames.d.mts +17 -2
- package/dist/utils/code-frames.d.mts.map +1 -0
- package/dist/utils/code-frames.mjs +4 -1
- package/dist/utils/code-frames.mjs.map +1 -0
- package/dist/utils/index.cjs +1 -1
- package/dist/utils/index.d.cts +5 -5
- package/dist/utils/index.d.mts +5 -6
- package/dist/utils/index.mjs +1 -1
- package/dist/utils/parse-error.cjs +1 -1
- package/dist/utils/parse-error.d.cts +15 -2
- package/dist/utils/parse-error.d.cts.map +1 -0
- package/dist/utils/parse-error.d.mts +15 -2
- package/dist/utils/parse-error.d.mts.map +1 -0
- package/dist/utils/parse-error.mjs +2 -1
- package/dist/utils/parse-error.mjs.map +1 -0
- package/dist/utils/parse.cjs +1 -1
- package/dist/utils/parse.d.cts +9 -2
- package/dist/utils/parse.d.cts.map +1 -0
- package/dist/utils/parse.d.mts +9 -2
- package/dist/utils/parse.d.mts.map +1 -0
- package/dist/utils/parse.mjs +2 -1
- package/dist/utils/parse.mjs.map +1 -0
- package/dist/utils/stringify.cjs +1 -1
- package/dist/utils/stringify.d.cts +13 -2
- package/dist/utils/stringify.d.cts.map +1 -0
- package/dist/utils/stringify.d.mts +13 -2
- package/dist/utils/stringify.d.mts.map +1 -0
- package/dist/utils/stringify.mjs +2 -1
- package/dist/utils/stringify.mjs.map +1 -0
- package/dist/utils/strip-comments.cjs +4 -1
- package/dist/utils/strip-comments.d.cts +11 -2
- package/dist/utils/strip-comments.d.cts.map +1 -0
- package/dist/utils/strip-comments.d.mts +11 -2
- package/dist/utils/strip-comments.d.mts.map +1 -0
- package/dist/utils/strip-comments.mjs +5 -1
- package/dist/utils/strip-comments.mjs.map +1 -0
- package/package.json +3 -3
- package/dist/code-frames-BQI7PKd_.mjs +0 -4
- package/dist/code-frames-BQI7PKd_.mjs.map +0 -1
- package/dist/code-frames-CXX37tnR.d.mts +0 -17
- package/dist/code-frames-CXX37tnR.d.mts.map +0 -1
- package/dist/code-frames-DEWi5iIn.cjs +0 -3
- package/dist/code-frames-DViwqU8S.d.cts +0 -17
- package/dist/code-frames-DViwqU8S.d.cts.map +0 -1
- package/dist/find-reference-AvNORSzC.d.mts +0 -52
- package/dist/find-reference-AvNORSzC.d.mts.map +0 -1
- package/dist/find-reference-BUIYIOS4.mjs +0 -2
- package/dist/find-reference-BUIYIOS4.mjs.map +0 -1
- package/dist/find-reference-ChoPoDcB.d.cts +0 -52
- package/dist/find-reference-ChoPoDcB.d.cts.map +0 -1
- package/dist/find-reference-DQJK1LbJ.cjs +0 -1
- package/dist/index-CMuRFTR3.d.mts +0 -1
- package/dist/index-uTS5iDq_.d.cts +0 -1
- package/dist/is-number-CebQk_B0.mjs +0 -2
- package/dist/is-number-CebQk_B0.mjs.map +0 -1
- package/dist/is-number-wfNPC3Mj.cjs +0 -1
- package/dist/is-object-CGB7EeiA.cjs +0 -1
- package/dist/is-object-DDPbtSWR.mjs +0 -2
- package/dist/is-object-DDPbtSWR.mjs.map +0 -1
- package/dist/is-string-D5yKZC0U.cjs +0 -1
- package/dist/is-string-VB7nGKjX.mjs.map +0 -1
- package/dist/is-undefined-D6sfLkFq.mjs +0 -2
- package/dist/is-undefined-D6sfLkFq.mjs.map +0 -1
- package/dist/is-undefined-Pevixi0g.cjs +0 -1
- package/dist/parse-BYhuR8fo.mjs +0 -2
- package/dist/parse-BYhuR8fo.mjs.map +0 -1
- package/dist/parse-BpylFCf0.mjs +0 -2
- package/dist/parse-BpylFCf0.mjs.map +0 -1
- package/dist/parse-BwhwGAkA.cjs +0 -1
- package/dist/parse-D-7TqXVh.d.mts +0 -51
- package/dist/parse-D-7TqXVh.d.mts.map +0 -1
- package/dist/parse-DU-kIQN6.d.cts +0 -51
- package/dist/parse-DU-kIQN6.d.cts.map +0 -1
- package/dist/parse-DmriuGKI.cjs +0 -1
- package/dist/parse-error-0BAtatMf.cjs +0 -1
- package/dist/parse-error-CJTV0jdn.d.mts +0 -15
- package/dist/parse-error-CJTV0jdn.d.mts.map +0 -1
- package/dist/parse-error-DLuqEXmf.d.cts +0 -15
- package/dist/parse-error-DLuqEXmf.d.cts.map +0 -1
- package/dist/parse-error-DrJJkemH.mjs +0 -2
- package/dist/parse-error-DrJJkemH.mjs.map +0 -1
- package/dist/parse-fX7NFKdt.d.cts +0 -9
- package/dist/parse-fX7NFKdt.d.cts.map +0 -1
- package/dist/parse-xFkFesIF.d.mts +0 -9
- package/dist/parse-xFkFesIF.d.mts.map +0 -1
- package/dist/storm-json-BsdLpzM_.mjs +0 -2
- package/dist/storm-json-BsdLpzM_.mjs.map +0 -1
- package/dist/storm-json-CfqJ0KzG.d.mts +0 -70
- package/dist/storm-json-CfqJ0KzG.d.mts.map +0 -1
- package/dist/storm-json-DBxiMujR.cjs +0 -1
- package/dist/storm-json-Q1bOIv3-.d.cts +0 -70
- package/dist/storm-json-Q1bOIv3-.d.cts.map +0 -1
- package/dist/stringify-BpBMOhle.d.cts +0 -13
- package/dist/stringify-BpBMOhle.d.cts.map +0 -1
- package/dist/stringify-DjBDt8SC.mjs +0 -2
- package/dist/stringify-DjBDt8SC.mjs.map +0 -1
- package/dist/stringify-Dp0lF-wN.cjs +0 -1
- package/dist/stringify-ln223ZC9.d.mts +0 -13
- package/dist/stringify-ln223ZC9.d.mts.map +0 -1
- package/dist/strip-comments-BhdK_E8s.cjs +0 -4
- package/dist/strip-comments-CKLSXchM.d.cts +0 -11
- package/dist/strip-comments-CKLSXchM.d.cts.map +0 -1
- package/dist/strip-comments-DdsCzji6.d.mts +0 -11
- package/dist/strip-comments-DdsCzji6.d.mts.map +0 -1
- package/dist/strip-comments-LcqiBhvo.mjs +0 -5
- package/dist/strip-comments-LcqiBhvo.mjs.map +0 -1
- package/dist/types-CEiKQHlk.d.cts +0 -69
- package/dist/types-CEiKQHlk.d.cts.map +0 -1
- package/dist/types-CQHq94S4.d.mts +0 -69
- package/dist/types-CQHq94S4.d.mts.map +0 -1
- package/dist/utils-BkLHzBxb.mjs +0 -1
- package/dist/utils-DFU9Wltn.cjs +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse.d.cts","names":[],"sources":["../../src/utils/parse.ts"],"sourcesContent":[],"mappings":";UA4CiB,OAAA;EAAA,MAAA,CAAA,EAAA,OAAO;AAIxB;AAmEgB,iBAnEA,KAmE4C,CAAA,IAAA,OAAgB,CAAA,CAAA,KAAA,EAAA,GAAA,EAAA,OAAA,CAAA,EAnEpB,OAmEoB,CAAA,EAnEL,CAmEK;iBAA5D,6CAA4C,UAAe"}
|
package/dist/utils/parse.d.mts
CHANGED
|
@@ -1,2 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
//#region src/utils/parse.d.ts
|
|
2
|
+
interface Options {
|
|
3
|
+
strict?: boolean;
|
|
4
|
+
}
|
|
5
|
+
declare function parse<T = unknown>(value: any, options?: Options): T;
|
|
6
|
+
declare function safeParse<T = unknown>(value: any, options?: Options): T;
|
|
7
|
+
//#endregion
|
|
8
|
+
export { Options, parse, safeParse };
|
|
9
|
+
//# sourceMappingURL=parse.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse.d.mts","names":[],"sources":["../../src/utils/parse.ts"],"sourcesContent":[],"mappings":";UA4CiB,OAAA;EAAA,MAAA,CAAA,EAAA,OAAO;AAIxB;AAmEgB,iBAnEA,KAmE4C,CAAA,IAAA,OAAgB,CAAA,CAAA,KAAA,EAAA,GAAA,EAAA,OAAA,CAAA,EAnEpB,OAmEoB,CAAA,EAnEL,CAmEK;iBAA5D,6CAA4C,UAAe"}
|
package/dist/utils/parse.mjs
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{stripComments as e}from"./strip-comments.mjs";const t=/"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/,n=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/,r=/^\s*["[{]|^\s*-?\d{1,16}(?:\.\d{1,17})?(?:E[+-]?\d+)?\s*$/i;function i(e,t){if(e===`__proto__`||e===`constructor`&&t&&typeof t==`object`&&`prototype`in t){console.warn(`Dropping "${e}" key to prevent prototype pollution.`);return}return t}function a(a,o={}){if(typeof a!=`string`)return a;let s=e(a);if(s[0]===`"`&&s[s.length-1]===`"`&&!s.includes(`\\`))return s.slice(1,-1);if(s=s.trim(),s.length<=9)switch(s.toLowerCase()){case`true`:return!0;case`false`:return!1;case`undefined`:return;case`null`:return null;case`nan`:return NaN;case`infinity`:return 1/0;case`-infinity`:return-1/0}if(!r.test(s)){if(o.strict)throw Error(`Invalid JSON`);return s}try{if(t.test(s)||n.test(s)){if(o.strict)throw Error(`Possible prototype pollution`);return JSON.parse(s,i)}return JSON.parse(s)}catch(e){if(o.strict)throw e;return a}}function o(e,t={}){return a(e,{...t,strict:!0})}export{a as parse,o as safeParse};
|
|
2
|
+
//# sourceMappingURL=parse.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse.mjs","names":[],"sources":["../../src/utils/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 { stripComments } from \"./strip-comments\";\n\n// https://github.com/fastify/secure-json-parse\n// https://github.com/hapijs/bourne\nconst suspectProtoRx =\n /\"(?:_|\\\\u0{2}5[Ff]){2}(?:p|\\\\u0{2}70)(?:r|\\\\u0{2}72)(?:o|\\\\u0{2}6[Ff])(?:t|\\\\u0{2}74)(?:o|\\\\u0{2}6[Ff])(?:_|\\\\u0{2}5[Ff]){2}\"\\s*:/;\nconst suspectConstructorRx =\n /\"(?:c|\\\\u0063)(?:o|\\\\u006[Ff])(?:n|\\\\u006[Ee])(?:s|\\\\u0073)(?:t|\\\\u0074)(?:r|\\\\u0072)(?:u|\\\\u0075)(?:c|\\\\u0063)(?:t|\\\\u0074)(?:o|\\\\u006[Ff])(?:r|\\\\u0072)\"\\s*:/;\n\nconst JsonSigRx = /^\\s*[\"[{]|^\\s*-?\\d{1,16}(?:\\.\\d{1,17})?(?:E[+-]?\\d+)?\\s*$/i;\n\nfunction jsonParseTransform(key: string, value: any): any {\n if (\n key === \"__proto__\" ||\n (key === \"constructor\" &&\n value &&\n typeof value === \"object\" &&\n \"prototype\" in value)\n ) {\n // eslint-disable-next-line no-console\n console.warn(`Dropping \"${key}\" key to prevent prototype pollution.`);\n return;\n }\n return value;\n}\n\nexport interface Options {\n strict?: boolean;\n}\n\nexport function parse<T = unknown>(value: any, options: Options = {}): T {\n if (typeof value !== \"string\") {\n return value;\n }\n\n let stripped = stripComments(value);\n\n if (\n stripped[0] === '\"' &&\n stripped[stripped.length - 1] === '\"' &&\n !stripped.includes(\"\\\\\")\n ) {\n return stripped.slice(1, -1) as T;\n }\n\n stripped = stripped.trim();\n\n if (stripped.length <= 9) {\n switch (stripped.toLowerCase()) {\n case \"true\": {\n return true as T;\n }\n case \"false\": {\n return false as T;\n }\n case \"undefined\": {\n return undefined as T;\n }\n case \"null\": {\n return null as T;\n }\n case \"nan\": {\n return Number.NaN as T;\n }\n case \"infinity\": {\n return Number.POSITIVE_INFINITY as T;\n }\n case \"-infinity\": {\n return Number.NEGATIVE_INFINITY as T;\n }\n }\n }\n\n if (!JsonSigRx.test(stripped)) {\n if (options.strict) {\n throw new Error(\"Invalid JSON\");\n }\n return stripped as T;\n }\n\n try {\n if (suspectProtoRx.test(stripped) || suspectConstructorRx.test(stripped)) {\n if (options.strict) {\n throw new Error(\"Possible prototype pollution\");\n }\n return JSON.parse(stripped, jsonParseTransform);\n }\n\n return JSON.parse(stripped);\n } catch (error) {\n if (options.strict) {\n throw error;\n }\n return value as T;\n }\n}\n\nexport function safeParse<T = unknown>(value: any, options: Options = {}): T {\n return parse<T>(value, { ...options, strict: true });\n}\n"],"mappings":"qDAsBA,MAAM,EACJ,oIACI,EACJ,iKAEI,EAAY,6DAElB,SAAS,EAAmB,EAAa,EAAiB,CACxD,GACE,IAAQ,aACP,IAAQ,eACP,GACA,OAAO,GAAU,UACjB,cAAe,EACjB,CAEA,QAAQ,KAAK,aAAa,EAAI,uCAAuC,CACrE,OAEF,OAAO,EAOT,SAAgB,EAAmB,EAAY,EAAmB,EAAE,CAAK,CACvE,GAAI,OAAO,GAAU,SACnB,OAAO,EAGT,IAAI,EAAW,EAAc,EAAM,CAEnC,GACE,EAAS,KAAO,KAChB,EAAS,EAAS,OAAS,KAAO,KAClC,CAAC,EAAS,SAAS,KAAK,CAExB,OAAO,EAAS,MAAM,EAAG,GAAG,CAK9B,GAFA,EAAW,EAAS,MAAM,CAEtB,EAAS,QAAU,EACrB,OAAQ,EAAS,aAAa,CAA9B,CACE,IAAK,OACH,MAAO,GAET,IAAK,QACH,MAAO,GAET,IAAK,YACH,OAEF,IAAK,OACH,OAAO,KAET,IAAK,MACH,MAAO,KAET,IAAK,WACH,MAAO,KAET,IAAK,YACH,MAAO,KAKb,GAAI,CAAC,EAAU,KAAK,EAAS,CAAE,CAC7B,GAAI,EAAQ,OACV,MAAU,MAAM,eAAe,CAEjC,OAAO,EAGT,GAAI,CACF,GAAI,EAAe,KAAK,EAAS,EAAI,EAAqB,KAAK,EAAS,CAAE,CACxE,GAAI,EAAQ,OACV,MAAU,MAAM,+BAA+B,CAEjD,OAAO,KAAK,MAAM,EAAU,EAAmB,CAGjD,OAAO,KAAK,MAAM,EAAS,OACpB,EAAO,CACd,GAAI,EAAQ,OACV,MAAM,EAER,OAAO,GAIX,SAAgB,EAAuB,EAAY,EAAmB,EAAE,CAAK,CAC3E,OAAO,EAAS,EAAO,CAAE,GAAG,EAAS,OAAQ,GAAM,CAAC"}
|
package/dist/utils/stringify.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`../
|
|
1
|
+
const e=require(`../type-checks/src/is-number.cjs`),t=require(`../type-checks/src/is-undefined.cjs`),n=`@/#$ :;,.!?&=+-*%^~|\\"'\`{}[]()<>`.split(``),r=(i,a=2)=>{let o=e.isNumber(a)?` `.repeat(a):a;switch(i){case null:return`null`;case void 0:return`"undefined"`;case!0:return`true`;case!1:return`false`;case 1/0:return`infinity`;case-1/0:return`-infinity`}if(Array.isArray(i))return`[${o}${i.map(e=>r(e,o)).join(`,${o}`)}${o}]`;if(i instanceof Uint8Array)return i.toString();switch(typeof i){case`number`:return`${i}`;case`string`:return JSON.stringify(i);case`object`:return`{${o}${Object.keys(i).filter(e=>!t.isUndefined(i[e])).map(e=>`${n.some(t=>e.includes(t))?`"${e}"`:e}: ${o}${r(i[e],o)}`).join(`,${o}`)}${o}}`;default:return`null`}};exports.invalidKeyChars=n,exports.stringify=r;
|
|
@@ -1,2 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
//#region src/utils/stringify.d.ts
|
|
2
|
+
declare const invalidKeyChars: readonly ["@", "/", "#", "$", " ", ":", ";", ",", ".", "!", "?", "&", "=", "+", "-", "*", "%", "^", "~", "|", "\\", "\"", "'", "`", "{", "}", "[", "]", "(", ")", "<", ">"];
|
|
3
|
+
/**
|
|
4
|
+
* Stringify a value to a JSON-like string.
|
|
5
|
+
*
|
|
6
|
+
* @param value - The value to stringify
|
|
7
|
+
* @param spacing - The spacing to use for the stringification
|
|
8
|
+
* @returns The stringified value
|
|
9
|
+
*/
|
|
10
|
+
declare const stringify: (value: unknown, spacing?: string | number) => string;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { invalidKeyChars, stringify };
|
|
13
|
+
//# sourceMappingURL=stringify.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stringify.d.cts","names":[],"sources":["../../src/utils/stringify.ts"],"sourcesContent":[],"mappings":";cAqBa;AAAb;AA0CA;;;;;;cAAa"}
|
|
@@ -1,2 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
//#region src/utils/stringify.d.ts
|
|
2
|
+
declare const invalidKeyChars: readonly ["@", "/", "#", "$", " ", ":", ";", ",", ".", "!", "?", "&", "=", "+", "-", "*", "%", "^", "~", "|", "\\", "\"", "'", "`", "{", "}", "[", "]", "(", ")", "<", ">"];
|
|
3
|
+
/**
|
|
4
|
+
* Stringify a value to a JSON-like string.
|
|
5
|
+
*
|
|
6
|
+
* @param value - The value to stringify
|
|
7
|
+
* @param spacing - The spacing to use for the stringification
|
|
8
|
+
* @returns The stringified value
|
|
9
|
+
*/
|
|
10
|
+
declare const stringify: (value: unknown, spacing?: string | number) => string;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { invalidKeyChars, stringify };
|
|
13
|
+
//# sourceMappingURL=stringify.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stringify.d.mts","names":[],"sources":["../../src/utils/stringify.ts"],"sourcesContent":[],"mappings":";cAqBa;AAAb;AA0CA;;;;;;cAAa"}
|
package/dist/utils/stringify.mjs
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{isNumber as e}from"../type-checks/src/is-number.mjs";import{isUndefined as t}from"../type-checks/src/is-undefined.mjs";const n=`@/#$ :;,.!?&=+-*%^~|\\"'\`{}[]()<>`.split(``),r=(i,a=2)=>{let o=e(a)?` `.repeat(a):a;switch(i){case null:return`null`;case void 0:return`"undefined"`;case!0:return`true`;case!1:return`false`;case 1/0:return`infinity`;case-1/0:return`-infinity`}if(Array.isArray(i))return`[${o}${i.map(e=>r(e,o)).join(`,${o}`)}${o}]`;if(i instanceof Uint8Array)return i.toString();switch(typeof i){case`number`:return`${i}`;case`string`:return JSON.stringify(i);case`object`:return`{${o}${Object.keys(i).filter(e=>!t(i[e])).map(e=>`${n.some(t=>e.includes(t))?`"${e}"`:e}: ${o}${r(i[e],o)}`).join(`,${o}`)}${o}}`;default:return`null`}};export{n as invalidKeyChars,r as stringify};
|
|
2
|
+
//# sourceMappingURL=stringify.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stringify.mjs","names":[],"sources":["../../src/utils/stringify.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 { isUndefined } from \"@stryke/type-checks/is-undefined\";\n\nexport const invalidKeyChars = [\n \"@\",\n \"/\",\n \"#\",\n \"$\",\n \" \",\n \":\",\n \";\",\n \",\",\n \".\",\n \"!\",\n \"?\",\n \"&\",\n \"=\",\n \"+\",\n \"-\",\n \"*\",\n \"%\",\n \"^\",\n \"~\",\n \"|\",\n \"\\\\\",\n '\"',\n \"'\",\n \"`\",\n \"{\",\n \"}\",\n \"[\",\n \"]\",\n \"(\",\n \")\",\n \"<\",\n \">\"\n] as const;\n\n/**\n * Stringify a value to a JSON-like string.\n *\n * @param value - The value to stringify\n * @param spacing - The spacing to use for the stringification\n * @returns The stringified value\n */\nexport const stringify = (\n value: unknown,\n spacing: string | number = 2\n): string => {\n const space = isNumber(spacing) ? \" \".repeat(spacing) : spacing;\n\n switch (value) {\n case null: {\n return \"null\";\n }\n case undefined: {\n return '\"undefined\"';\n }\n case true: {\n return \"true\";\n }\n case false: {\n return \"false\";\n }\n case Number.POSITIVE_INFINITY: {\n return \"infinity\";\n }\n case Number.NEGATIVE_INFINITY: {\n return \"-infinity\";\n }\n }\n\n if (Array.isArray(value)) {\n return `[${space}${value.map(v => stringify(v, space)).join(`,${space}`)}${space}]`;\n }\n if (value instanceof Uint8Array) {\n return value.toString();\n }\n\n // eslint-disable-next-line ts/switch-exhaustiveness-check\n switch (typeof value) {\n case \"number\": {\n return `${value}`;\n }\n case \"string\": {\n return JSON.stringify(value);\n }\n case \"object\": {\n const keys = Object.keys(value as object).filter(\n key => !isUndefined((value as any)[key])\n );\n\n return `{${space}${keys\n .map(\n key =>\n `${invalidKeyChars.some(invalidKeyChar => key.includes(invalidKeyChar)) ? `\"${key}\"` : key}: ${space}${stringify((value as any)[key], space)}`\n )\n .join(`,${space}`)}${space}}`;\n }\n default:\n return \"null\";\n }\n};\n"],"mappings":"8HAqBA,MAAa,EAAkB,8CAiC9B,CASY,GACX,EACA,EAA2B,IAChB,CACX,IAAM,EAAQ,EAAS,EAAQ,CAAG,IAAI,OAAO,EAAQ,CAAG,EAExD,OAAQ,EAAR,CACE,KAAK,KACH,MAAO,OAET,KAAK,IAAA,GACH,MAAO,cAET,IAAK,GACH,MAAO,OAET,IAAK,GACH,MAAO,QAET,IAAK,KACH,MAAO,WAET,IAAK,KACH,MAAO,YAIX,GAAI,MAAM,QAAQ,EAAM,CACtB,MAAO,IAAI,IAAQ,EAAM,IAAI,GAAK,EAAU,EAAG,EAAM,CAAC,CAAC,KAAK,IAAI,IAAQ,GAAG,EAAM,GAEnF,GAAI,aAAiB,WACnB,OAAO,EAAM,UAAU,CAIzB,OAAQ,OAAO,EAAf,CACE,IAAK,SACH,MAAO,GAAG,IAEZ,IAAK,SACH,OAAO,KAAK,UAAU,EAAM,CAE9B,IAAK,SAKH,MAAO,IAAI,IAJE,OAAO,KAAK,EAAgB,CAAC,OACxC,GAAO,CAAC,EAAa,EAAc,GAAK,CACzC,CAGE,IACC,GACE,GAAG,EAAgB,KAAK,GAAkB,EAAI,SAAS,EAAe,CAAC,CAAG,IAAI,EAAI,GAAK,EAAI,IAAI,IAAQ,EAAW,EAAc,GAAM,EAAM,GAC/I,CACA,KAAK,IAAI,IAAQ,GAAG,EAAM,GAE/B,QACE,MAAO"}
|
|
@@ -1 +1,4 @@
|
|
|
1
|
-
const e=require(`../
|
|
1
|
+
const e=require(`../types/src/base.cjs`),t=Symbol(`singleComment`),n=Symbol(`multiComment`);function r(){return``}function i(e,t,n){return e.slice(t,n).replace(/\S/g,` `)}function a(e,t){let n=t-1,r=0;for(;e[n]===`\\`;)--n,r+=1;return!!(r%2)}function o(o,{whitespace:s=!0,trailingCommas:c=!1}={}){if(typeof o!=`string`)throw TypeError(`Expected argument \`jsonString\` to be a \`string\`, got \`${typeof o}\``);let l=s?i:r,u=!1,d=!1,f=0,p=``,m=``,h=-1;for(let r=0;r<o.length;r++){let i=o[r],s=o[r+1];!d&&i===`"`&&(a(o,r)||(u=!u)),!u&&(!d&&i+(s??e.EMPTY_STRING)===`//`?(p+=o.slice(f,r),f=r,d=t,r++):d===t&&i+(s??e.EMPTY_STRING)===`\r
|
|
2
|
+
`?(r++,d=!1,p+=l(o,f,r),f=r):d===t&&i===`
|
|
3
|
+
`?(d=!1,p+=l(o,f,r),f=r):!d&&i+(s??e.EMPTY_STRING)===`/*`?(p+=o.slice(f,r),f=r,d=n,r++):d===n&&i+(s??e.EMPTY_STRING)===`*/`?(r++,d=!1,p+=l(o,f,r+1),f=r+1):c&&!d&&(h===-1?i===`,`&&(m+=p+o.slice(f,r),p=``,f=r,h=r):i===`}`||i===`]`?(p+=o.slice(f,r),m+=l(p,0,1)+p.slice(1),p=``,f=r,h=-1):i!==` `&&i!==` `&&i!==`\r`&&i!==`
|
|
4
|
+
`&&(p+=o.slice(f,r),f=r,h=-1)))}return m+p+(d?l(o.slice(f)):o.slice(f))}exports.stripComments=o;
|
|
@@ -1,2 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
//#region src/utils/strip-comments.d.ts
|
|
2
|
+
declare function stripComments(value: string, {
|
|
3
|
+
whitespace,
|
|
4
|
+
trailingCommas
|
|
5
|
+
}?: {
|
|
6
|
+
whitespace?: boolean | undefined;
|
|
7
|
+
trailingCommas?: boolean | undefined;
|
|
8
|
+
}): string;
|
|
9
|
+
//#endregion
|
|
10
|
+
export { stripComments };
|
|
11
|
+
//# sourceMappingURL=strip-comments.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"strip-comments.d.cts","names":[],"sources":["../../src/utils/strip-comments.ts"],"sourcesContent":[],"mappings":";iBAyCgB,aAAA;;;;EAAA,UAAA,CAAA,EAAA,OAAa,GAAA,SAEzB"}
|
|
@@ -1,2 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
//#region src/utils/strip-comments.d.ts
|
|
2
|
+
declare function stripComments(value: string, {
|
|
3
|
+
whitespace,
|
|
4
|
+
trailingCommas
|
|
5
|
+
}?: {
|
|
6
|
+
whitespace?: boolean | undefined;
|
|
7
|
+
trailingCommas?: boolean | undefined;
|
|
8
|
+
}): string;
|
|
9
|
+
//#endregion
|
|
10
|
+
export { stripComments };
|
|
11
|
+
//# sourceMappingURL=strip-comments.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"strip-comments.d.mts","names":[],"sources":["../../src/utils/strip-comments.ts"],"sourcesContent":[],"mappings":";iBAyCgB,aAAA;;;;EAAA,UAAA,CAAA,EAAA,OAAa,GAAA,SAEzB"}
|
|
@@ -1 +1,5 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{EMPTY_STRING as e}from"../types/src/base.mjs";const t=Symbol(`singleComment`),n=Symbol(`multiComment`);function r(){return``}function i(e,t,n){return e.slice(t,n).replace(/\S/g,` `)}function a(e,t){let n=t-1,r=0;for(;e[n]===`\\`;)--n,r+=1;return!!(r%2)}function o(o,{whitespace:s=!0,trailingCommas:c=!1}={}){if(typeof o!=`string`)throw TypeError(`Expected argument \`jsonString\` to be a \`string\`, got \`${typeof o}\``);let l=s?i:r,u=!1,d=!1,f=0,p=``,m=``,h=-1;for(let r=0;r<o.length;r++){let i=o[r],s=o[r+1];!d&&i===`"`&&(a(o,r)||(u=!u)),!u&&(!d&&i+(s??e)===`//`?(p+=o.slice(f,r),f=r,d=t,r++):d===t&&i+(s??e)===`\r
|
|
2
|
+
`?(r++,d=!1,p+=l(o,f,r),f=r):d===t&&i===`
|
|
3
|
+
`?(d=!1,p+=l(o,f,r),f=r):!d&&i+(s??e)===`/*`?(p+=o.slice(f,r),f=r,d=n,r++):d===n&&i+(s??e)===`*/`?(r++,d=!1,p+=l(o,f,r+1),f=r+1):c&&!d&&(h===-1?i===`,`&&(m+=p+o.slice(f,r),p=``,f=r,h=r):i===`}`||i===`]`?(p+=o.slice(f,r),m+=l(p,0,1)+p.slice(1),p=``,f=r,h=-1):i!==` `&&i!==` `&&i!==`\r`&&i!==`
|
|
4
|
+
`&&(p+=o.slice(f,r),f=r,h=-1)))}return m+p+(d?l(o.slice(f)):o.slice(f))}export{o as stripComments};
|
|
5
|
+
//# sourceMappingURL=strip-comments.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"strip-comments.mjs","names":["isInsideString: boolean | symbol","isInsideComment: boolean | symbol"],"sources":["../../src/utils/strip-comments.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 { EMPTY_STRING } from \"@stryke/types/base\";\n\nconst singleComment = Symbol(\"singleComment\");\nconst multiComment = Symbol(\"multiComment\");\n\nfunction stripWithoutWhitespace() {\n return \"\";\n}\nfunction stripWithWhitespace(value: string, start?: number, end?: number) {\n return value.slice(start, end).replace(/\\S/g, \" \");\n}\n\nfunction isEscaped(value: string, quotePosition: number) {\n let index = quotePosition - 1;\n let backslashCount = 0;\n while (value[index] === \"\\\\\") {\n index -= 1;\n backslashCount += 1;\n }\n\n return Boolean(backslashCount % 2);\n}\n\nexport function stripComments(\n value: string,\n { whitespace = true, trailingCommas = false } = {}\n) {\n if (typeof value !== \"string\") {\n throw new TypeError(\n `Expected argument \\`jsonString\\` to be a \\`string\\`, got \\`${typeof value}\\``\n );\n }\n\n const strip = whitespace ? stripWithWhitespace : stripWithoutWhitespace;\n let isInsideString: boolean | symbol = false;\n let isInsideComment: boolean | symbol = false;\n let offset = 0;\n let buffer = \"\";\n let result = \"\";\n let commaIndex = -1;\n for (let index = 0; index < value.length; index++) {\n const currentCharacter = value[index];\n const nextCharacter = value[index + 1];\n if (!isInsideComment && currentCharacter === '\"') {\n const escaped = isEscaped(value, index);\n if (!escaped) {\n isInsideString = !isInsideString;\n }\n }\n if (isInsideString) {\n continue;\n }\n if (\n !isInsideComment &&\n currentCharacter + (nextCharacter ?? EMPTY_STRING) === \"//\"\n ) {\n buffer += value.slice(offset, index);\n offset = index;\n isInsideComment = singleComment;\n index++;\n } else if (\n isInsideComment === singleComment &&\n currentCharacter + (nextCharacter ?? EMPTY_STRING) === \"\\r\\n\"\n ) {\n index++;\n isInsideComment = false;\n buffer += strip(value, offset, index);\n offset = index;\n } else if (isInsideComment === singleComment && currentCharacter === \"\\n\") {\n isInsideComment = false;\n buffer += strip(value, offset, index);\n offset = index;\n } else if (\n !isInsideComment &&\n currentCharacter + (nextCharacter ?? EMPTY_STRING) === \"/*\"\n ) {\n buffer += value.slice(offset, index);\n offset = index;\n isInsideComment = multiComment;\n index++;\n } else if (\n isInsideComment === multiComment &&\n currentCharacter + (nextCharacter ?? EMPTY_STRING) === \"*/\"\n ) {\n index++;\n isInsideComment = false;\n buffer += strip(value, offset, index + 1);\n offset = index + 1;\n } else if (trailingCommas && !isInsideComment) {\n if (commaIndex !== -1) {\n if (currentCharacter === \"}\" || currentCharacter === \"]\") {\n buffer += value.slice(offset, index);\n result += strip(buffer, 0, 1) + buffer.slice(1);\n buffer = \"\";\n offset = index;\n commaIndex = -1;\n } else if (\n currentCharacter !== \" \" &&\n currentCharacter !== \"\t\" &&\n currentCharacter !== \"\\r\" &&\n currentCharacter !== \"\\n\"\n ) {\n buffer += value.slice(offset, index);\n offset = index;\n commaIndex = -1;\n }\n } else if (currentCharacter === \",\") {\n result += buffer + value.slice(offset, index);\n buffer = \"\";\n offset = index;\n commaIndex = index;\n }\n }\n }\n\n return (\n result +\n buffer +\n (isInsideComment ? strip(value.slice(offset)) : value.slice(offset))\n );\n}\n"],"mappings":"qDAoBA,MAAM,EAAgB,OAAO,gBAAgB,CACvC,EAAe,OAAO,eAAe,CAE3C,SAAS,GAAyB,CAChC,MAAO,GAET,SAAS,EAAoB,EAAe,EAAgB,EAAc,CACxE,OAAO,EAAM,MAAM,EAAO,EAAI,CAAC,QAAQ,MAAO,IAAI,CAGpD,SAAS,EAAU,EAAe,EAAuB,CACvD,IAAI,EAAQ,EAAgB,EACxB,EAAiB,EACrB,KAAO,EAAM,KAAW,MACtB,IACA,GAAkB,EAGpB,MAAO,GAAQ,EAAiB,GAGlC,SAAgB,EACd,EACA,CAAE,aAAa,GAAM,iBAAiB,IAAU,EAAE,CAClD,CACA,GAAI,OAAO,GAAU,SACnB,MAAU,UACR,8DAA8D,OAAO,EAAM,IAC5E,CAGH,IAAM,EAAQ,EAAa,EAAsB,EAC7CA,EAAmC,GACnCC,EAAoC,GACpC,EAAS,EACT,EAAS,GACT,EAAS,GACT,EAAa,GACjB,IAAK,IAAI,EAAQ,EAAG,EAAQ,EAAM,OAAQ,IAAS,CACjD,IAAM,EAAmB,EAAM,GACzB,EAAgB,EAAM,EAAQ,GAChC,CAAC,GAAmB,IAAqB,MAC3B,EAAU,EAAO,EAAM,GAErC,EAAiB,CAAC,IAGlB,KAIF,CAAC,GACD,GAAoB,GAAiB,KAAkB,MAEvD,GAAU,EAAM,MAAM,EAAQ,EAAM,CACpC,EAAS,EACT,EAAkB,EAClB,KAEA,IAAoB,GACpB,GAAoB,GAAiB,KAAkB;GAEvD,IACA,EAAkB,GAClB,GAAU,EAAM,EAAO,EAAQ,EAAM,CACrC,EAAS,GACA,IAAoB,GAAiB,IAAqB;GACnE,EAAkB,GAClB,GAAU,EAAM,EAAO,EAAQ,EAAM,CACrC,EAAS,GAET,CAAC,GACD,GAAoB,GAAiB,KAAkB,MAEvD,GAAU,EAAM,MAAM,EAAQ,EAAM,CACpC,EAAS,EACT,EAAkB,EAClB,KAEA,IAAoB,GACpB,GAAoB,GAAiB,KAAkB,MAEvD,IACA,EAAkB,GAClB,GAAU,EAAM,EAAO,EAAQ,EAAQ,EAAE,CACzC,EAAS,EAAQ,GACR,GAAkB,CAAC,IACxB,IAAe,GAiBR,IAAqB,MAC9B,GAAU,EAAS,EAAM,MAAM,EAAQ,EAAM,CAC7C,EAAS,GACT,EAAS,EACT,EAAa,GApBT,IAAqB,KAAO,IAAqB,KACnD,GAAU,EAAM,MAAM,EAAQ,EAAM,CACpC,GAAU,EAAM,EAAQ,EAAG,EAAE,CAAG,EAAO,MAAM,EAAE,CAC/C,EAAS,GACT,EAAS,EACT,EAAa,IAEb,IAAqB,KACrB,IAAqB,KACrB,IAAqB,MACrB,IAAqB;IAErB,GAAU,EAAM,MAAM,EAAQ,EAAM,CACpC,EAAS,EACT,EAAa,MAWrB,OACE,EACA,GACC,EAAkB,EAAM,EAAM,MAAM,EAAO,CAAC,CAAG,EAAM,MAAM,EAAO"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stryke/json",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.28",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A package containing JSON parsing/stringify utilities used by Storm Software.",
|
|
6
6
|
"repository": {
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"lines-and-columns": "2.0.4",
|
|
63
63
|
"superjson": "2.2.2"
|
|
64
64
|
},
|
|
65
|
-
"devDependencies": { "@types/node": "^24.10.
|
|
65
|
+
"devDependencies": { "@types/node": "^24.10.4", "tsdown": "^0.17.2" },
|
|
66
66
|
"publishConfig": { "access": "public" },
|
|
67
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "8f2e484743eb3ce54929e99096ca2ea188b4730e"
|
|
68
68
|
}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
const e=/\r\n|[\n\r\u2028\u2029]/;function t(e,t,n={}){let r={column:0,line:-1,...e.start},i={...r,...e.end},{linesAbove:a=2,linesBelow:o=3}=n||{},s=r.line,c=r.column,l=i.line,u=i.column,d=Math.max(s-(a+1),0),f=Math.min(t.length,l+o);s===-1&&(d=0),l===-1&&(f=t.length);let p=l-s,m={};if(p)for(let e=0;e<=p;e++){let n=e+s;c?e===0?m[n]=[c,(t[n-1]?.length??0)-c+1]:e===p?m[n]=[0,u]:m[n]=[0,t[n-e]?.length??0]:m[n]=!0}else c===u?m[s]=c?[c,0]:!0:m[s]=[c,u-c];return{start:d,end:f,markerLines:m}}function n(n,r,i={}){let{start:a,end:o,markerLines:s}=t(r,n.split(e),i),c=String(o).length;return(i.highlight?i.highlight(n):n).split(e).slice(a,o).map((e,t)=>{let n=a+1+t,r=` ${` ${n}`.slice(-c)} | `,i=!!(s[n]??!1);if(i){let t=``;if(Array.isArray(i)){let n=e.slice(0,Math.max(i[0]-1,0)).replace(/[^\t]/g,` `),a=i[1]||1;t=[`
|
|
2
|
-
`,r.replace(/\d/g,` `),n,`^`.repeat(a)].join(``)}return[`>`,r,e,t].join(``)}return` ${r}${e}`}).join(`
|
|
3
|
-
`)}export{n as t};
|
|
4
|
-
//# sourceMappingURL=code-frames-BQI7PKd_.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"code-frames-BQI7PKd_.mjs","names":["startLoc: Location","endLoc: Location"],"sources":["../src/utils/code-frames.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\ninterface Location {\n column: number;\n line: number;\n}\n\ninterface NodeLocation {\n end?: Location;\n start?: Location;\n}\n\n// Adapted from https://raw.githubusercontent.com/babel/babel/4108524/packages/babel-code-frame/src/index.js\n\n/**\n * RegExp to test for newlines in terminal.\n */\nconst NEWLINE = /\\r\\n|[\\n\\r\\u2028\\u2029]/;\n\n/**\n * Extract what lines should be marked and highlighted.\n */\nfunction getMarkerLines(\n loc: NodeLocation,\n source: string[],\n opts: { linesAbove?: number; linesBelow?: number } = {}\n): {\n start: number;\n end: number;\n markerLines: Record<number, boolean | [number, number]>;\n} {\n const startLoc: Location = {\n column: 0,\n line: -1,\n ...loc.start\n };\n const endLoc: Location = {\n ...startLoc,\n ...loc.end\n };\n const { linesAbove = 2, linesBelow = 3 } = opts || {};\n const startLine = startLoc.line;\n const startColumn = startLoc.column;\n const endLine = endLoc.line;\n const endColumn = endLoc.column;\n\n let start = Math.max(startLine - (linesAbove + 1), 0);\n let end = Math.min(source.length, endLine + linesBelow);\n\n if (startLine === -1) {\n start = 0;\n }\n\n if (endLine === -1) {\n end = source.length;\n }\n\n const lineDiff = endLine - startLine;\n const markerLines = {} as Record<number, boolean | [number, number]>;\n\n if (lineDiff) {\n for (let i = 0; i <= lineDiff; i++) {\n const lineNumber = i + startLine;\n\n if (!startColumn) {\n markerLines[lineNumber] = true;\n } else if (i === 0) {\n const sourceLength = source[lineNumber - 1]?.length ?? 0;\n\n markerLines[lineNumber] = [startColumn, sourceLength - startColumn + 1];\n } else if (i === lineDiff) {\n markerLines[lineNumber] = [0, endColumn];\n } else {\n const sourceLength = source[lineNumber - i]?.length ?? 0;\n\n markerLines[lineNumber] = [0, sourceLength];\n }\n }\n } else if (startColumn === endColumn) {\n markerLines[startLine] = startColumn ? [startColumn, 0] : true;\n } else {\n markerLines[startLine] = [startColumn, endColumn - startColumn];\n }\n\n return {\n start,\n end,\n markerLines\n };\n}\n\nexport function codeFrameColumns(\n rawLines: string,\n loc: NodeLocation,\n opts: {\n linesAbove?: number;\n linesBelow?: number;\n highlight?: (rawLines: string) => string;\n } = {}\n): string {\n const lines = rawLines.split(NEWLINE);\n const { start, end, markerLines } = getMarkerLines(loc, lines, opts);\n\n const numberMaxWidth = String(end).length;\n const highlightedLines = opts.highlight ? opts.highlight(rawLines) : rawLines;\n\n const frame = highlightedLines\n .split(NEWLINE)\n .slice(start, end)\n .map((line, index) => {\n const number = start + 1 + index;\n const paddedNumber = ` ${number}`.slice(-numberMaxWidth);\n const gutter = ` ${paddedNumber} | `;\n const hasMarker = Boolean(markerLines[number] ?? false);\n if (hasMarker) {\n let markerLine = \"\";\n if (Array.isArray(hasMarker)) {\n const markerSpacing = line\n .slice(0, Math.max(hasMarker[0] - 1, 0))\n .replace(/[^\\t]/g, \" \");\n const numberOfMarkers = hasMarker[1] || 1;\n\n markerLine = [\n \"\\n \",\n gutter.replace(/\\d/g, \" \"),\n markerSpacing,\n \"^\".repeat(numberOfMarkers)\n ].join(\"\");\n }\n return [\">\", gutter, line, markerLine].join(\"\");\n }\n return ` ${gutter}${line}`;\n })\n .join(\"\\n\");\n\n return frame;\n}\n"],"mappings":"AAiCA,MAAM,EAAU,0BAKhB,SAAS,EACP,EACA,EACA,EAAqD,EAAE,CAKvD,CACA,IAAMA,EAAqB,CACzB,OAAQ,EACR,KAAM,GACN,GAAG,EAAI,MACR,CACKC,EAAmB,CACvB,GAAG,EACH,GAAG,EAAI,IACR,CACK,CAAE,aAAa,EAAG,aAAa,GAAM,GAAQ,EAAE,CAC/C,EAAY,EAAS,KACrB,EAAc,EAAS,OACvB,EAAU,EAAO,KACjB,EAAY,EAAO,OAErB,EAAQ,KAAK,IAAI,GAAa,EAAa,GAAI,EAAE,CACjD,EAAM,KAAK,IAAI,EAAO,OAAQ,EAAU,EAAW,CAEnD,IAAc,KAChB,EAAQ,GAGN,IAAY,KACd,EAAM,EAAO,QAGf,IAAM,EAAW,EAAU,EACrB,EAAc,EAAE,CAEtB,GAAI,EACF,IAAK,IAAI,EAAI,EAAG,GAAK,EAAU,IAAK,CAClC,IAAM,EAAa,EAAI,EAElB,EAEM,IAAM,EAGf,EAAY,GAAc,CAAC,GAFN,EAAO,EAAa,IAAI,QAAU,GAEA,EAAc,EAAE,CAC9D,IAAM,EACf,EAAY,GAAc,CAAC,EAAG,EAAU,CAIxC,EAAY,GAAc,CAAC,EAFN,EAAO,EAAa,IAAI,QAAU,EAEZ,CAV3C,EAAY,GAAc,QAarB,IAAgB,EACzB,EAAY,GAAa,EAAc,CAAC,EAAa,EAAE,CAAG,GAE1D,EAAY,GAAa,CAAC,EAAa,EAAY,EAAY,CAGjE,MAAO,CACL,QACA,MACA,cACD,CAGH,SAAgB,EACd,EACA,EACA,EAII,EAAE,CACE,CAER,GAAM,CAAE,QAAO,MAAK,eAAgB,EAAe,EADrC,EAAS,MAAM,EAAQ,CAC0B,EAAK,CAE9D,EAAiB,OAAO,EAAI,CAAC,OAgCnC,OA/ByB,EAAK,UAAY,EAAK,UAAU,EAAS,CAAG,GAGlE,MAAM,EAAQ,CACd,MAAM,EAAO,EAAI,CACjB,KAAK,EAAM,IAAU,CACpB,IAAM,EAAS,EAAQ,EAAI,EAErB,EAAS,IADM,IAAI,IAAS,MAAM,CAAC,EAAe,CACxB,KAC1B,EAAY,GAAQ,EAAY,IAAW,IACjD,GAAI,EAAW,CACb,IAAI,EAAa,GACjB,GAAI,MAAM,QAAQ,EAAU,CAAE,CAC5B,IAAM,EAAgB,EACnB,MAAM,EAAG,KAAK,IAAI,EAAU,GAAK,EAAG,EAAE,CAAC,CACvC,QAAQ,SAAU,IAAI,CACnB,EAAkB,EAAU,IAAM,EAExC,EAAa,CACX;GACA,EAAO,QAAQ,MAAO,IAAI,CAC1B,EACA,IAAI,OAAO,EAAgB,CAC5B,CAAC,KAAK,GAAG,CAEZ,MAAO,CAAC,IAAK,EAAQ,EAAM,EAAW,CAAC,KAAK,GAAG,CAEjD,MAAO,IAAI,IAAS,KACpB,CACD,KAAK;EAAK"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
//#region src/utils/code-frames.d.ts
|
|
2
|
-
interface Location {
|
|
3
|
-
column: number;
|
|
4
|
-
line: number;
|
|
5
|
-
}
|
|
6
|
-
interface NodeLocation {
|
|
7
|
-
end?: Location;
|
|
8
|
-
start?: Location;
|
|
9
|
-
}
|
|
10
|
-
declare function codeFrameColumns(rawLines: string, loc: NodeLocation, opts?: {
|
|
11
|
-
linesAbove?: number;
|
|
12
|
-
linesBelow?: number;
|
|
13
|
-
highlight?: (rawLines: string) => string;
|
|
14
|
-
}): string;
|
|
15
|
-
//#endregion
|
|
16
|
-
export { codeFrameColumns as t };
|
|
17
|
-
//# sourceMappingURL=code-frames-CXX37tnR.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"code-frames-CXX37tnR.d.mts","names":[],"sources":["../src/utils/code-frames.ts"],"sourcesContent":[],"mappings":";UAkBU,QAAA;EAAA,MAAA,EAAA,MAAQ;EAKR,IAAA,EAAA,MAAA;AAoFV;UApFU,YAAA;QACF;UACE;;iBAkFM,gBAAA,wBAET"}
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
const e=/\r\n|[\n\r\u2028\u2029]/;function t(e,t,n={}){let r={column:0,line:-1,...e.start},i={...r,...e.end},{linesAbove:a=2,linesBelow:o=3}=n||{},s=r.line,c=r.column,l=i.line,u=i.column,d=Math.max(s-(a+1),0),f=Math.min(t.length,l+o);s===-1&&(d=0),l===-1&&(f=t.length);let p=l-s,m={};if(p)for(let e=0;e<=p;e++){let n=e+s;c?e===0?m[n]=[c,(t[n-1]?.length??0)-c+1]:e===p?m[n]=[0,u]:m[n]=[0,t[n-e]?.length??0]:m[n]=!0}else c===u?m[s]=c?[c,0]:!0:m[s]=[c,u-c];return{start:d,end:f,markerLines:m}}function n(n,r,i={}){let{start:a,end:o,markerLines:s}=t(r,n.split(e),i),c=String(o).length;return(i.highlight?i.highlight(n):n).split(e).slice(a,o).map((e,t)=>{let n=a+1+t,r=` ${` ${n}`.slice(-c)} | `,i=!!(s[n]??!1);if(i){let t=``;if(Array.isArray(i)){let n=e.slice(0,Math.max(i[0]-1,0)).replace(/[^\t]/g,` `),a=i[1]||1;t=[`
|
|
2
|
-
`,r.replace(/\d/g,` `),n,`^`.repeat(a)].join(``)}return[`>`,r,e,t].join(``)}return` ${r}${e}`}).join(`
|
|
3
|
-
`)}Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return n}});
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
//#region src/utils/code-frames.d.ts
|
|
2
|
-
interface Location {
|
|
3
|
-
column: number;
|
|
4
|
-
line: number;
|
|
5
|
-
}
|
|
6
|
-
interface NodeLocation {
|
|
7
|
-
end?: Location;
|
|
8
|
-
start?: Location;
|
|
9
|
-
}
|
|
10
|
-
declare function codeFrameColumns(rawLines: string, loc: NodeLocation, opts?: {
|
|
11
|
-
linesAbove?: number;
|
|
12
|
-
linesBelow?: number;
|
|
13
|
-
highlight?: (rawLines: string) => string;
|
|
14
|
-
}): string;
|
|
15
|
-
//#endregion
|
|
16
|
-
export { codeFrameColumns as t };
|
|
17
|
-
//# sourceMappingURL=code-frames-DViwqU8S.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"code-frames-DViwqU8S.d.cts","names":[],"sources":["../src/utils/code-frames.ts"],"sourcesContent":[],"mappings":";UAkBU,QAAA;EAAA,MAAA,EAAA,MAAQ;EAKR,IAAA,EAAA,MAAA;AAoFV;UApFU,YAAA;QACF;UACE;;iBAkFM,gBAAA,wBAET"}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
//#region src/pointer/find-reference.d.ts
|
|
2
|
-
interface Reference {
|
|
3
|
-
/** Target value where pointer is pointing. */
|
|
4
|
-
readonly val: unknown;
|
|
5
|
-
/** Object which contains the target value. */
|
|
6
|
-
readonly obj?: unknown | object | unknown[];
|
|
7
|
-
/** Key which targets the target value in the object. */
|
|
8
|
-
readonly key?: string | number;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Finds a target in document specified by JSON Pointer. Also returns the
|
|
12
|
-
* object containing the target and key used to reference that object.
|
|
13
|
-
*
|
|
14
|
-
* Throws Error('NOT_FOUND') if pointer does not result into a value in the middle
|
|
15
|
-
* of the path. If the last element of the path does not result into a value, the
|
|
16
|
-
* lookup succeeds with `val` set to `undefined`. It can be used to discriminate
|
|
17
|
-
* missing values, because `undefined` is not a valid JSON value.
|
|
18
|
-
*
|
|
19
|
-
* If last element in array is targeted using "-", e.g. "/arr/-", use
|
|
20
|
-
* `isArrayEnd` to verify that:
|
|
21
|
-
*
|
|
22
|
-
* ```js
|
|
23
|
-
* const ref = find({arr: [1, 2, 3], ['arr', '-']});
|
|
24
|
-
* if (isArrayReference(ref)) {
|
|
25
|
-
* if (isArrayEnd(ref)) {
|
|
26
|
-
* // ...
|
|
27
|
-
* }
|
|
28
|
-
* }
|
|
29
|
-
* ```
|
|
30
|
-
*
|
|
31
|
-
* @param val - Document to search in.
|
|
32
|
-
* @param path - JSON Pointer path.
|
|
33
|
-
* @returns Reference to the target.
|
|
34
|
-
*/
|
|
35
|
-
declare const find: (val: unknown, path: Reference["key"][]) => Reference;
|
|
36
|
-
interface ArrayReference<T = unknown> {
|
|
37
|
-
/** `undefined` in case JSON Pointer points to last element, e.g. "/foo/-". */
|
|
38
|
-
readonly val: undefined | T;
|
|
39
|
-
readonly obj: T[];
|
|
40
|
-
readonly key: number;
|
|
41
|
-
}
|
|
42
|
-
declare const isArrayReference: <T = unknown>(ref: Reference) => ref is ArrayReference<T>;
|
|
43
|
-
declare const isArrayEnd: (ref: ArrayReference) => boolean;
|
|
44
|
-
interface ObjectReference<T = unknown> {
|
|
45
|
-
readonly val: T;
|
|
46
|
-
readonly obj: Record<string, T>;
|
|
47
|
-
readonly key: string;
|
|
48
|
-
}
|
|
49
|
-
declare const isObjectReference: <T = unknown>(ref: Reference) => ref is ObjectReference<T>;
|
|
50
|
-
//#endregion
|
|
51
|
-
export { isArrayEnd as a, find as i, ObjectReference as n, isArrayReference as o, Reference as r, isObjectReference as s, ArrayReference as t };
|
|
52
|
-
//# sourceMappingURL=find-reference-AvNORSzC.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"find-reference-AvNORSzC.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,2 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./is-object-DDPbtSWR.mjs";import{t}from"./is-string-VB7nGKjX.mjs";import{t as n}from"./is-undefined-D6sfLkFq.mjs";const r=e=>{try{return e===null}catch{return!1}},i=e=>{try{return n(e)||r(e)}catch{return!1}},a=e=>{try{return!i(e)}catch{return!1}},o=t=>a(t)&&e(t),s=e=>{try{return o(e)&&Object.keys(e).length>0}catch{return!1}},{isArray:c}=Array,l=(e,n)=>{let r=n.length;if(!r)return{val:e};let i,a;for(let o=0;o<r;o++)if(i=e,a=n[o],c(i)){let n=i.length;if(a===`-`)a=n;else if(t(a)){let e=Math.trunc(Number.parseInt(a));if(String(e)!==a||(a=e,a<0))throw Error(`INVALID_INDEX`)}a&&(e=i[a])}else if(s(i))e=a&&a in i?i[a]:void 0;else throw Error(`NOT_FOUND`);return{val:e,obj:i,key:a}},u=e=>c(e.obj)&&typeof e.key==`number`,d=e=>e.obj.length===e.key,f=e=>typeof e.obj==`object`&&typeof e.key==`string`;export{f as i,d as n,u as r,l as t};
|
|
2
|
-
//# sourceMappingURL=find-reference-BUIYIOS4.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"find-reference-BUIYIOS4.mjs","names":["obj: Reference[\"obj\"]","key: Reference[\"key\"]"],"sources":["../../type-checks/src/is-null.ts","../../type-checks/src/is-empty.ts","../../type-checks/src/is-set.ts","../../type-checks/src/is-non-null-object.ts","../../type-checks/src/is-set-object.ts","../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\nexport const isNull = (value: unknown): value is null => {\n try {\n return value === null;\n } catch {\n return false;\n }\n};\n","/* -------------------------------------------------------------------\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","/* -------------------------------------------------------------------\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","/* -------------------------------------------------------------------\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","/* -------------------------------------------------------------------\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","/* -------------------------------------------------------------------\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":"qIAkBA,MAAa,EAAU,GAAkC,CACvD,GAAI,CACF,OAAO,IAAU,UACX,CACN,MAAO,KCSE,EAAW,GAAmB,CACzC,GAAI,CACF,OAAO,EAAY,EAAM,EAAI,EAAO,EAAM,MACpC,CACN,MAAO,KCTE,EAAS,GAAkD,CACtE,GAAI,CACF,MAAO,CAAC,EAAQ,EAAM,MAChB,CACN,MAAO,KCHE,EAAmB,GACvB,EAAM,EAAM,EAAI,EAAS,EAAM,CCF3B,EAAe,GAAiD,CAC3E,GAAI,CACF,OAAO,EAAgB,EAAM,EAAI,OAAO,KAAK,EAAM,CAAC,OAAS,OACvD,CACN,MAAO,KCAL,CAAE,WAAY,MA2BP,GAAQ,EAAc,IAAwC,CACzE,IAAM,EAAa,EAAK,OACxB,GAAI,CAAC,EACH,MAAO,CAAE,MAAK,CAGhB,IAAIA,EACAC,EACJ,IAAK,IAAI,EAAI,EAAG,EAAI,EAAY,IAG9B,GAFA,EAAM,EACN,EAAM,EAAK,GACP,EAAQ,EAAI,CAAE,CAChB,IAAM,EAAS,EAAI,OACnB,GAAI,IAAQ,IACV,EAAM,UACG,EAAS,EAAI,CAAE,CACxB,IAAM,EAAO,KAAK,MAAM,OAAO,SAAS,EAAI,CAAC,CAM7C,GALI,OAAO,EAAK,GAAK,IAIrB,EAAM,EACF,EAAM,GACR,MAAU,MAAM,gBAAgB,CAIhC,IACF,EAAM,EAAI,YAEH,EAAY,EAAI,CACzB,EAAM,GAAO,KAAO,EAAO,EAAY,GAAO,IAAA,QACzC,MAAU,MAAM,YAAY,CAQrC,MANuB,CACrB,MACA,MACA,MACD,EAYU,EACX,GAC6B,EAAQ,EAAI,IAAI,EAAI,OAAO,EAAI,KAAQ,SAEzD,EAAc,GACzB,EAAI,IAAI,SAAW,EAAI,IAQZ,EACX,GAEA,OAAO,EAAI,KAAQ,UAAY,OAAO,EAAI,KAAQ"}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
//#region src/pointer/find-reference.d.ts
|
|
2
|
-
interface Reference {
|
|
3
|
-
/** Target value where pointer is pointing. */
|
|
4
|
-
readonly val: unknown;
|
|
5
|
-
/** Object which contains the target value. */
|
|
6
|
-
readonly obj?: unknown | object | unknown[];
|
|
7
|
-
/** Key which targets the target value in the object. */
|
|
8
|
-
readonly key?: string | number;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Finds a target in document specified by JSON Pointer. Also returns the
|
|
12
|
-
* object containing the target and key used to reference that object.
|
|
13
|
-
*
|
|
14
|
-
* Throws Error('NOT_FOUND') if pointer does not result into a value in the middle
|
|
15
|
-
* of the path. If the last element of the path does not result into a value, the
|
|
16
|
-
* lookup succeeds with `val` set to `undefined`. It can be used to discriminate
|
|
17
|
-
* missing values, because `undefined` is not a valid JSON value.
|
|
18
|
-
*
|
|
19
|
-
* If last element in array is targeted using "-", e.g. "/arr/-", use
|
|
20
|
-
* `isArrayEnd` to verify that:
|
|
21
|
-
*
|
|
22
|
-
* ```js
|
|
23
|
-
* const ref = find({arr: [1, 2, 3], ['arr', '-']});
|
|
24
|
-
* if (isArrayReference(ref)) {
|
|
25
|
-
* if (isArrayEnd(ref)) {
|
|
26
|
-
* // ...
|
|
27
|
-
* }
|
|
28
|
-
* }
|
|
29
|
-
* ```
|
|
30
|
-
*
|
|
31
|
-
* @param val - Document to search in.
|
|
32
|
-
* @param path - JSON Pointer path.
|
|
33
|
-
* @returns Reference to the target.
|
|
34
|
-
*/
|
|
35
|
-
declare const find: (val: unknown, path: Reference["key"][]) => Reference;
|
|
36
|
-
interface ArrayReference<T = unknown> {
|
|
37
|
-
/** `undefined` in case JSON Pointer points to last element, e.g. "/foo/-". */
|
|
38
|
-
readonly val: undefined | T;
|
|
39
|
-
readonly obj: T[];
|
|
40
|
-
readonly key: number;
|
|
41
|
-
}
|
|
42
|
-
declare const isArrayReference: <T = unknown>(ref: Reference) => ref is ArrayReference<T>;
|
|
43
|
-
declare const isArrayEnd: (ref: ArrayReference) => boolean;
|
|
44
|
-
interface ObjectReference<T = unknown> {
|
|
45
|
-
readonly val: T;
|
|
46
|
-
readonly obj: Record<string, T>;
|
|
47
|
-
readonly key: string;
|
|
48
|
-
}
|
|
49
|
-
declare const isObjectReference: <T = unknown>(ref: Reference) => ref is ObjectReference<T>;
|
|
50
|
-
//#endregion
|
|
51
|
-
export { isArrayEnd as a, find as i, ObjectReference as n, isArrayReference as o, Reference as r, isObjectReference as s, ArrayReference as t };
|
|
52
|
-
//# sourceMappingURL=find-reference-ChoPoDcB.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"find-reference-ChoPoDcB.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
|
-
const e=require(`./is-object-CGB7EeiA.cjs`),t=require(`./is-string-D5yKZC0U.cjs`),n=require(`./is-undefined-Pevixi0g.cjs`),r=e=>{try{return e===null}catch{return!1}},i=e=>{try{return n.t(e)||r(e)}catch{return!1}},a=e=>{try{return!i(e)}catch{return!1}},o=t=>a(t)&&e.t(t),s=e=>{try{return o(e)&&Object.keys(e).length>0}catch{return!1}},{isArray:c}=Array,l=(e,n)=>{let r=n.length;if(!r)return{val:e};let i,a;for(let o=0;o<r;o++)if(i=e,a=n[o],c(i)){let n=i.length;if(a===`-`)a=n;else if(t.t(a)){let e=Math.trunc(Number.parseInt(a));if(String(e)!==a||(a=e,a<0))throw Error(`INVALID_INDEX`)}a&&(e=i[a])}else if(s(i))e=a&&a in i?i[a]:void 0;else throw Error(`NOT_FOUND`);return{val:e,obj:i,key:a}},u=e=>c(e.obj)&&typeof e.key==`number`,d=e=>e.obj.length===e.key,f=e=>typeof e.obj==`object`&&typeof e.key==`string`;Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return f}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return l}});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"is-number-CebQk_B0.mjs","names":[],"sources":["../../type-checks/src/get-object-tag.ts","../../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\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","/* -------------------------------------------------------------------\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":"AAwBA,MAAa,EAAgB,GACvB,GAAS,KACJ,IAAU,IAAA,GAAY,qBAAuB,gBAE/C,OAAO,UAAU,SAAS,KAAK,EAAM,CCDjC,EAAY,GAAoC,CAC3D,GAAI,CACF,OACE,aAAiB,QACjB,OAAO,GAAU,UACjB,OAAO,EAAM,GAAK,OAEd,CACN,MAAO"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const e=e=>e==null?e===void 0?`[object Undefined]`:`[object Null]`:Object.prototype.toString.call(e),t=e=>{try{return e instanceof Number||typeof e==`number`||Number(e)===e}catch{return!1}};Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return e}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return t}});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const e=require(`./is-number-wfNPC3Mj.cjs`),t=e=>typeof e==`object`&&!!e,n=n=>{if(!t(n)||e.n(n)!==`[object Object]`)return!1;if(Object.getPrototypeOf(n)===null)return!0;let r=n;for(;Object.getPrototypeOf(r)!==null;)r=Object.getPrototypeOf(r);return Object.getPrototypeOf(n)===r},r=e=>{try{return typeof e==`object`||!!e&&e?.constructor===Object||n(e)}catch{return!1}};Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return r}});
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{n as e}from"./is-number-CebQk_B0.mjs";const t=e=>typeof e==`object`&&!!e,n=n=>{if(!t(n)||e(n)!==`[object Object]`)return!1;if(Object.getPrototypeOf(n)===null)return!0;let r=n;for(;Object.getPrototypeOf(r)!==null;)r=Object.getPrototypeOf(r);return Object.getPrototypeOf(n)===r},r=e=>{try{return typeof e==`object`||!!e&&e?.constructor===Object||n(e)}catch{return!1}};export{r as t};
|
|
2
|
-
//# sourceMappingURL=is-object-DDPbtSWR.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"is-object-DDPbtSWR.mjs","names":[],"sources":["../../type-checks/src/is-plain-object.ts","../../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\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","/* -------------------------------------------------------------------\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":"6CA2CA,MAAa,EAAgB,GACpB,OAAO,GAAQ,YAAY,EA4BvB,EAAiB,GAAqC,CACjE,GAAI,CAAC,EAAa,EAAI,EAAI,EAAa,EAAI,GAAK,kBAC9C,MAAO,GAET,GAAI,OAAO,eAAe,EAAI,GAAK,KACjC,MAAO,GAET,IAAI,EAAQ,EACZ,KAAO,OAAO,eAAe,EAAM,GAAK,MACtC,EAAQ,OAAO,eAAe,EAAM,CAEtC,OAAO,OAAO,eAAe,EAAI,GAAK,GCV3B,EAAY,GAAoC,CAC3D,GAAI,CACF,OACE,OAAO,GAAU,UAChB,EAAQ,GAAU,GAAO,cAAgB,QAC1C,EAAc,EAAM,MAEhB,CACN,MAAO"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const e=e=>{try{return typeof e==`string`}catch{return!1}};Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return e}});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"is-string-VB7nGKjX.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,EAAY,GAAoC,CAC3D,GAAI,CACF,OAAO,OAAO,GAAU,cAClB,CACN,MAAO"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"is-undefined-D6sfLkFq.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,GACnB,IAAU,IAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const e=e=>e===void 0;Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return e}});
|
package/dist/parse-BYhuR8fo.mjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./is-number-CebQk_B0.mjs";import{t}from"./is-string-VB7nGKjX.mjs";const n=/~1/g,r=/~0/g,i=/~/g,a=/\//g;function o(e){return!e.includes(`/`)&&!e.includes(`~`)?e:e.replace(i,`~0`).replace(a,`~1`)}function s(e){return e.includes(`~`)?e.replace(n,`/`).replace(r,`~`):e}function c(e){return e?e.slice(1).split(`/`).map(e=>s(e)):[]}function l(e){return u(e)?``:`/${e.map(e=>o(String(e))).join(`/`)}`}const u=n=>t(n)?n===``:e(n)?n===0:Array.isArray(n)&&n.length===0;function d(e){if(e.length===0)throw Error(`NO_PARENT`);return e.slice(0,-1)}function f(t){if(e(t))return!0;let n=Number.parseInt(t,10);return String(n)===t&&n>=0}const p=e=>{let t=e.length,n=0,r;for(;n<t;){if(r=e.codePointAt(n),r>=48&&r<=57){n++;continue}return!1}return!0};export{f as a,s as c,u as i,l as n,d as o,p as r,c as s,o as t};
|
|
2
|
-
//# sourceMappingURL=parse-BYhuR8fo.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parse-BYhuR8fo.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":"qFAsBA,MAAM,EAAY,MACZ,EAAa,MACb,EAAQ,KACR,EAAgB,MAQtB,SAAgB,EAAqB,EAAyB,CAK5D,MAJI,CAAC,EAAQ,SAAS,IAAI,EAAI,CAAC,EAAQ,SAAS,IAAI,CAC3C,EAGF,EAAQ,QAAQ,EAAO,KAAK,CAAC,QAAQ,EAAe,KAAK,CASlE,SAAgB,EAAuB,EAAyB,CAK9D,OAJK,EAAQ,SAAS,IAAI,CAInB,EAAQ,QAAQ,EAAW,IAAI,CAAC,QAAQ,EAAY,IAAI,CAHtD,EAUX,SAAgB,EAAiB,EAAkC,CAGjE,OAFK,EAEE,EACJ,MAAM,EAAE,CACR,MAAM,IAAI,CACV,IAAI,GAAW,EAAuB,EAAQ,CAAC,CAL7B,EAAE,CAYzB,SAAgB,EAAkB,EAA+B,CAM/D,OAJI,EAAO,EAAK,CACP,GAGF,IAAI,EAAK,IAAI,GAAW,EAAqB,OAAO,EAAQ,CAAC,CAAC,CAAC,KAAK,IAAI,GAMjF,MAAa,EAAU,GACrB,EAAS,EAAK,CACV,IAAS,GACT,EAAS,EAAK,CACZ,IAAS,EACT,MAAM,QAAQ,EAAK,EAAI,EAAK,SAAW,EAK/C,SAAgB,EAAO,EAAwC,CAC7D,GAAI,EAAK,SAAW,EAClB,MAAU,MAAM,YAAY,CAG9B,OAAO,EAAK,MAAM,EAAG,GAAG,CAM1B,SAAgB,EAAa,EAAiC,CAC5D,GAAI,EAAS,EAAM,CACjB,MAAO,GAGT,IAAM,EAAI,OAAO,SAAS,EAAO,GAAG,CAEpC,OAAO,OAAO,EAAE,GAAK,GAAS,GAAK,EAGrC,MAAa,EAAa,GAAyB,CACjD,IAAM,EAAM,EAAI,OACZ,EAAI,EACJA,EACJ,KAAO,EAAI,GAAK,CAEd,GADA,EAAW,EAAI,YAAY,EAAE,CACzB,GAAY,IAAM,GAAY,GAAI,CACpC,IACA,SAEF,MAAO,GAET,MAAO"}
|
package/dist/parse-BpylFCf0.mjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./strip-comments-LcqiBhvo.mjs";const t=/"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/,n=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/,r=/^\s*["[{]|^\s*-?\d{1,16}(?:\.\d{1,17})?(?:E[+-]?\d+)?\s*$/i;function i(e,t){if(e===`__proto__`||e===`constructor`&&t&&typeof t==`object`&&`prototype`in t){console.warn(`Dropping "${e}" key to prevent prototype pollution.`);return}return t}function a(a,o={}){if(typeof a!=`string`)return a;let s=e(a);if(s[0]===`"`&&s[s.length-1]===`"`&&!s.includes(`\\`))return s.slice(1,-1);if(s=s.trim(),s.length<=9)switch(s.toLowerCase()){case`true`:return!0;case`false`:return!1;case`undefined`:return;case`null`:return null;case`nan`:return NaN;case`infinity`:return 1/0;case`-infinity`:return-1/0}if(!r.test(s)){if(o.strict)throw Error(`Invalid JSON`);return s}try{if(t.test(s)||n.test(s)){if(o.strict)throw Error(`Possible prototype pollution`);return JSON.parse(s,i)}return JSON.parse(s)}catch(e){if(o.strict)throw e;return a}}function o(e,t={}){return a(e,{...t,strict:!0})}export{o as n,a as t};
|
|
2
|
-
//# sourceMappingURL=parse-BpylFCf0.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parse-BpylFCf0.mjs","names":[],"sources":["../src/utils/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 { stripComments } from \"./strip-comments\";\n\n// https://github.com/fastify/secure-json-parse\n// https://github.com/hapijs/bourne\nconst suspectProtoRx =\n /\"(?:_|\\\\u0{2}5[Ff]){2}(?:p|\\\\u0{2}70)(?:r|\\\\u0{2}72)(?:o|\\\\u0{2}6[Ff])(?:t|\\\\u0{2}74)(?:o|\\\\u0{2}6[Ff])(?:_|\\\\u0{2}5[Ff]){2}\"\\s*:/;\nconst suspectConstructorRx =\n /\"(?:c|\\\\u0063)(?:o|\\\\u006[Ff])(?:n|\\\\u006[Ee])(?:s|\\\\u0073)(?:t|\\\\u0074)(?:r|\\\\u0072)(?:u|\\\\u0075)(?:c|\\\\u0063)(?:t|\\\\u0074)(?:o|\\\\u006[Ff])(?:r|\\\\u0072)\"\\s*:/;\n\nconst JsonSigRx = /^\\s*[\"[{]|^\\s*-?\\d{1,16}(?:\\.\\d{1,17})?(?:E[+-]?\\d+)?\\s*$/i;\n\nfunction jsonParseTransform(key: string, value: any): any {\n if (\n key === \"__proto__\" ||\n (key === \"constructor\" &&\n value &&\n typeof value === \"object\" &&\n \"prototype\" in value)\n ) {\n // eslint-disable-next-line no-console\n console.warn(`Dropping \"${key}\" key to prevent prototype pollution.`);\n return;\n }\n return value;\n}\n\nexport interface Options {\n strict?: boolean;\n}\n\nexport function parse<T = unknown>(value: any, options: Options = {}): T {\n if (typeof value !== \"string\") {\n return value;\n }\n\n let stripped = stripComments(value);\n\n if (\n stripped[0] === '\"' &&\n stripped[stripped.length - 1] === '\"' &&\n !stripped.includes(\"\\\\\")\n ) {\n return stripped.slice(1, -1) as T;\n }\n\n stripped = stripped.trim();\n\n if (stripped.length <= 9) {\n switch (stripped.toLowerCase()) {\n case \"true\": {\n return true as T;\n }\n case \"false\": {\n return false as T;\n }\n case \"undefined\": {\n return undefined as T;\n }\n case \"null\": {\n return null as T;\n }\n case \"nan\": {\n return Number.NaN as T;\n }\n case \"infinity\": {\n return Number.POSITIVE_INFINITY as T;\n }\n case \"-infinity\": {\n return Number.NEGATIVE_INFINITY as T;\n }\n }\n }\n\n if (!JsonSigRx.test(stripped)) {\n if (options.strict) {\n throw new Error(\"Invalid JSON\");\n }\n return stripped as T;\n }\n\n try {\n if (suspectProtoRx.test(stripped) || suspectConstructorRx.test(stripped)) {\n if (options.strict) {\n throw new Error(\"Possible prototype pollution\");\n }\n return JSON.parse(stripped, jsonParseTransform);\n }\n\n return JSON.parse(stripped);\n } catch (error) {\n if (options.strict) {\n throw error;\n }\n return value as T;\n }\n}\n\nexport function safeParse<T = unknown>(value: any, options: Options = {}): T {\n return parse<T>(value, { ...options, strict: true });\n}\n"],"mappings":"kDAsBA,MAAM,EACJ,oIACI,EACJ,iKAEI,EAAY,6DAElB,SAAS,EAAmB,EAAa,EAAiB,CACxD,GACE,IAAQ,aACP,IAAQ,eACP,GACA,OAAO,GAAU,UACjB,cAAe,EACjB,CAEA,QAAQ,KAAK,aAAa,EAAI,uCAAuC,CACrE,OAEF,OAAO,EAOT,SAAgB,EAAmB,EAAY,EAAmB,EAAE,CAAK,CACvE,GAAI,OAAO,GAAU,SACnB,OAAO,EAGT,IAAI,EAAW,EAAc,EAAM,CAEnC,GACE,EAAS,KAAO,KAChB,EAAS,EAAS,OAAS,KAAO,KAClC,CAAC,EAAS,SAAS,KAAK,CAExB,OAAO,EAAS,MAAM,EAAG,GAAG,CAK9B,GAFA,EAAW,EAAS,MAAM,CAEtB,EAAS,QAAU,EACrB,OAAQ,EAAS,aAAa,CAA9B,CACE,IAAK,OACH,MAAO,GAET,IAAK,QACH,MAAO,GAET,IAAK,YACH,OAEF,IAAK,OACH,OAAO,KAET,IAAK,MACH,MAAO,KAET,IAAK,WACH,MAAO,KAET,IAAK,YACH,MAAO,KAKb,GAAI,CAAC,EAAU,KAAK,EAAS,CAAE,CAC7B,GAAI,EAAQ,OACV,MAAU,MAAM,eAAe,CAEjC,OAAO,EAGT,GAAI,CACF,GAAI,EAAe,KAAK,EAAS,EAAI,EAAqB,KAAK,EAAS,CAAE,CACxE,GAAI,EAAQ,OACV,MAAU,MAAM,+BAA+B,CAEjD,OAAO,KAAK,MAAM,EAAU,EAAmB,CAGjD,OAAO,KAAK,MAAM,EAAS,OACpB,EAAO,CACd,GAAI,EAAQ,OACV,MAAM,EAER,OAAO,GAIX,SAAgB,EAAuB,EAAY,EAAmB,EAAE,CAAK,CAC3E,OAAO,EAAS,EAAO,CAAE,GAAG,EAAS,OAAQ,GAAM,CAAC"}
|
package/dist/parse-BwhwGAkA.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const e=require(`./is-number-wfNPC3Mj.cjs`),t=require(`./is-string-D5yKZC0U.cjs`),n=/~1/g,r=/~0/g,i=/~/g,a=/\//g;function o(e){return!e.includes(`/`)&&!e.includes(`~`)?e:e.replace(i,`~0`).replace(a,`~1`)}function s(e){return e.includes(`~`)?e.replace(n,`/`).replace(r,`~`):e}function c(e){return e?e.slice(1).split(`/`).map(e=>s(e)):[]}function l(e){return u(e)?``:`/${e.map(e=>o(String(e))).join(`/`)}`}const u=n=>t.t(n)?n===``:e.t(n)?n===0:Array.isArray(n)&&n.length===0;function d(e){if(e.length===0)throw Error(`NO_PARENT`);return e.slice(0,-1)}function f(t){if(e.t(t))return!0;let n=Number.parseInt(t,10);return String(n)===t&&n>=0}const p=e=>{let t=e.length,n=0,r;for(;n<t;){if(r=e.codePointAt(n),r>=48&&r<=57){n++;continue}return!1}return!0};Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return f}}),Object.defineProperty(exports,`c`,{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return p}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return o}});
|