@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.
Files changed (204) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/code-frames-BUtrssZ5.d.cts +17 -0
  3. package/dist/code-frames-BUtrssZ5.d.cts.map +1 -0
  4. package/dist/code-frames-BmUvlJ0w.cjs +82 -0
  5. package/dist/code-frames-CrTAYYSE.d.mts +17 -0
  6. package/dist/code-frames-CrTAYYSE.d.mts.map +1 -0
  7. package/dist/code-frames-DuBfTMu4.mjs +77 -0
  8. package/dist/code-frames-DuBfTMu4.mjs.map +1 -0
  9. package/dist/find-reference-B8xshNXL.d.mts +52 -0
  10. package/dist/find-reference-B8xshNXL.d.mts.map +1 -0
  11. package/dist/find-reference-C-YleCds.d.cts +52 -0
  12. package/dist/find-reference-C-YleCds.d.cts.map +1 -0
  13. package/dist/find-reference-DMSYEaaI.mjs +64 -0
  14. package/dist/find-reference-DMSYEaaI.mjs.map +1 -0
  15. package/dist/find-reference-De5vBQV2.cjs +86 -0
  16. package/dist/index-B_e8BwCm.d.cts +1 -0
  17. package/dist/index-CCt0lwyI.d.mts +1 -0
  18. package/dist/index-CDAfh8Ew.d.cts +1 -0
  19. package/dist/index-DvuJXuAN.d.mts +1 -0
  20. package/dist/index.cjs +37 -14
  21. package/dist/index.d.cts +11 -8
  22. package/dist/index.d.mts +12 -9
  23. package/dist/index.mjs +13 -8
  24. package/dist/is-number-BIwzZzyi.mjs +31 -0
  25. package/dist/is-number-BIwzZzyi.mjs.map +1 -0
  26. package/dist/is-number-c5xguIbS.cjs +42 -0
  27. package/dist/{type-checks/src/is-plain-object.mjs → is-object-BpfmzHWa.mjs} +19 -3
  28. package/dist/is-object-BpfmzHWa.mjs.map +1 -0
  29. package/dist/{type-checks/src/is-plain-object.cjs → is-object-umGh91v1.cjs} +24 -3
  30. package/dist/is-set-object-BmHip9em.cjs +108 -0
  31. package/dist/is-set-object-C1Qnj1Q8.mjs +98 -0
  32. package/dist/is-set-object-C1Qnj1Q8.mjs.map +1 -0
  33. package/dist/{type-checks/src/is-string.mjs → is-string-C2RK4Gjs.cjs} +7 -2
  34. package/dist/{type-checks/src/is-string.cjs → is-string-CLiBUSKV.mjs} +2 -2
  35. package/dist/is-string-CLiBUSKV.mjs.map +1 -0
  36. package/dist/{type-checks/src/is-undefined.cjs → is-undefined-CmyJWYGD.mjs} +2 -2
  37. package/dist/is-undefined-CmyJWYGD.mjs.map +1 -0
  38. package/dist/{type-checks/src/is-undefined.mjs → is-undefined-CnI0qe-z.cjs} +7 -2
  39. package/dist/parse-BGlhbY16.d.cts +9 -0
  40. package/dist/parse-BGlhbY16.d.cts.map +1 -0
  41. package/dist/parse-Bp6kkcQ4.cjs +127 -0
  42. package/dist/parse-ByDxRup5.cjs +62 -0
  43. package/dist/parse-Cj-YfhrI.d.mts +51 -0
  44. package/dist/parse-Cj-YfhrI.d.mts.map +1 -0
  45. package/dist/parse-DZfi3d96.d.cts +51 -0
  46. package/dist/parse-DZfi3d96.d.cts.map +1 -0
  47. package/dist/parse-Dn43ZK9y.mjs +52 -0
  48. package/dist/parse-Dn43ZK9y.mjs.map +1 -0
  49. package/dist/parse-error-7K8s4vWf.d.cts +15 -0
  50. package/dist/parse-error-7K8s4vWf.d.cts.map +1 -0
  51. package/dist/parse-error-Af4zHUQ_.mjs +34 -0
  52. package/dist/parse-error-Af4zHUQ_.mjs.map +1 -0
  53. package/dist/parse-error-DpEv3vo_.d.mts +15 -0
  54. package/dist/parse-error-DpEv3vo_.d.mts.map +1 -0
  55. package/dist/parse-error-N7UE-HMh.cjs +39 -0
  56. package/dist/parse-fXy5pbmE.d.mts +9 -0
  57. package/dist/parse-fXy5pbmE.d.mts.map +1 -0
  58. package/dist/parse-vw_qRD3F.mjs +81 -0
  59. package/dist/parse-vw_qRD3F.mjs.map +1 -0
  60. package/dist/pointer/find-reference.cjs +5 -65
  61. package/dist/pointer/find-reference.d.cts +2 -52
  62. package/dist/pointer/find-reference.d.mts +2 -52
  63. package/dist/pointer/find-reference.mjs +2 -63
  64. package/dist/pointer/index.cjs +15 -14
  65. package/dist/pointer/index.d.cts +2 -2
  66. package/dist/pointer/index.d.mts +2 -2
  67. package/dist/pointer/index.mjs +3 -2
  68. package/dist/pointer/parse.cjs +9 -86
  69. package/dist/pointer/parse.d.cts +2 -44
  70. package/dist/pointer/parse.d.mts +2 -44
  71. package/dist/pointer/parse.mjs +2 -80
  72. package/dist/pointer-B3W_Sme3.cjs +0 -0
  73. package/dist/pointer-Dn__XOdY.mjs +0 -0
  74. package/dist/schema-BO1HCrxv.d.cts +55 -0
  75. package/dist/schema-BO1HCrxv.d.cts.map +1 -0
  76. package/dist/schema-CmH1V_uI.d.mts +55 -0
  77. package/dist/schema-CmH1V_uI.d.mts.map +1 -0
  78. package/dist/schema-DGmzxHja.mjs +72 -0
  79. package/dist/schema-DGmzxHja.mjs.map +1 -0
  80. package/dist/schema-Dl018Aq4.cjs +106 -0
  81. package/dist/schema.cjs +8 -0
  82. package/dist/schema.d.cts +2 -0
  83. package/dist/schema.d.mts +3 -0
  84. package/dist/schema.mjs +3 -0
  85. package/dist/storm-json-8F9CKpXu.d.mts +70 -0
  86. package/dist/storm-json-8F9CKpXu.d.mts.map +1 -0
  87. package/dist/storm-json-BD6WFbrI.cjs +154 -0
  88. package/dist/storm-json-DvIEWMEH.d.cts +70 -0
  89. package/dist/storm-json-DvIEWMEH.d.cts.map +1 -0
  90. package/dist/storm-json-nkhJgTz4.mjs +116 -0
  91. package/dist/storm-json-nkhJgTz4.mjs.map +1 -0
  92. package/dist/storm-json.cjs +3 -116
  93. package/dist/storm-json.d.cts +2 -70
  94. package/dist/storm-json.d.mts +3 -70
  95. package/dist/storm-json.mjs +3 -115
  96. package/dist/stringify-Bc8OkhIr.d.cts +13 -0
  97. package/dist/stringify-Bc8OkhIr.d.cts.map +1 -0
  98. package/dist/stringify-BehjrfhS.cjs +78 -0
  99. package/dist/stringify-CFT1K1LE.d.mts +13 -0
  100. package/dist/stringify-CFT1K1LE.d.mts.map +1 -0
  101. package/dist/stringify-CYHjAvWm.mjs +68 -0
  102. package/dist/stringify-CYHjAvWm.mjs.map +1 -0
  103. package/dist/strip-comments-BA8MS_Fs.d.mts +11 -0
  104. package/dist/strip-comments-BA8MS_Fs.d.mts.map +1 -0
  105. package/dist/strip-comments-CmEG_smS.cjs +94 -0
  106. package/dist/strip-comments-Cz_Wc25t.d.cts +11 -0
  107. package/dist/strip-comments-Cz_Wc25t.d.cts.map +1 -0
  108. package/dist/strip-comments-Dq00N_Sg.mjs +89 -0
  109. package/dist/strip-comments-Dq00N_Sg.mjs.map +1 -0
  110. package/dist/types-Bn8rC098.d.cts +222 -0
  111. package/dist/types-Bn8rC098.d.cts.map +1 -0
  112. package/dist/types-CPQlxauZ.d.mts +222 -0
  113. package/dist/types-CPQlxauZ.d.mts.map +1 -0
  114. package/dist/types.d.cts +2 -69
  115. package/dist/types.d.mts +2 -69
  116. package/dist/types.mjs +0 -1
  117. package/dist/utils/code-frames.cjs +2 -76
  118. package/dist/utils/code-frames.d.cts +2 -17
  119. package/dist/utils/code-frames.d.mts +2 -17
  120. package/dist/utils/code-frames.mjs +2 -76
  121. package/dist/utils/index.cjs +13 -12
  122. package/dist/utils/index.d.cts +5 -5
  123. package/dist/utils/index.d.mts +6 -5
  124. package/dist/utils/index.mjs +6 -5
  125. package/dist/utils/parse-error.cjs +2 -33
  126. package/dist/utils/parse-error.d.cts +2 -15
  127. package/dist/utils/parse-error.d.mts +2 -15
  128. package/dist/utils/parse-error.mjs +2 -33
  129. package/dist/utils/parse.cjs +3 -51
  130. package/dist/utils/parse.d.cts +2 -9
  131. package/dist/utils/parse.d.mts +2 -9
  132. package/dist/utils/parse.mjs +2 -51
  133. package/dist/utils/stringify.cjs +3 -67
  134. package/dist/utils/stringify.d.cts +2 -13
  135. package/dist/utils/stringify.d.mts +2 -13
  136. package/dist/utils/stringify.mjs +2 -67
  137. package/dist/utils/strip-comments.cjs +2 -85
  138. package/dist/utils/strip-comments.d.cts +2 -11
  139. package/dist/utils/strip-comments.d.mts +2 -11
  140. package/dist/utils/strip-comments.mjs +2 -86
  141. package/dist/utils-jN2UkvqB.cjs +0 -0
  142. package/dist/utils-mEkKIcgl.mjs +0 -0
  143. package/package.json +12 -3
  144. package/dist/_virtual/rolldown_runtime.cjs +0 -29
  145. package/dist/pointer/find-reference.d.cts.map +0 -1
  146. package/dist/pointer/find-reference.d.mts.map +0 -1
  147. package/dist/pointer/find-reference.mjs.map +0 -1
  148. package/dist/pointer/parse.d.cts.map +0 -1
  149. package/dist/pointer/parse.d.mts.map +0 -1
  150. package/dist/pointer/parse.mjs.map +0 -1
  151. package/dist/storm-json.d.cts.map +0 -1
  152. package/dist/storm-json.d.mts.map +0 -1
  153. package/dist/storm-json.mjs.map +0 -1
  154. package/dist/type-checks/src/get-object-tag.cjs +0 -15
  155. package/dist/type-checks/src/get-object-tag.mjs +0 -15
  156. package/dist/type-checks/src/get-object-tag.mjs.map +0 -1
  157. package/dist/type-checks/src/is-empty.cjs +0 -20
  158. package/dist/type-checks/src/is-empty.mjs +0 -21
  159. package/dist/type-checks/src/is-empty.mjs.map +0 -1
  160. package/dist/type-checks/src/is-non-null-object.cjs +0 -16
  161. package/dist/type-checks/src/is-non-null-object.mjs +0 -17
  162. package/dist/type-checks/src/is-non-null-object.mjs.map +0 -1
  163. package/dist/type-checks/src/is-null.cjs +0 -12
  164. package/dist/type-checks/src/is-null.mjs +0 -12
  165. package/dist/type-checks/src/is-null.mjs.map +0 -1
  166. package/dist/type-checks/src/is-number.cjs +0 -18
  167. package/dist/type-checks/src/is-number.mjs +0 -18
  168. package/dist/type-checks/src/is-number.mjs.map +0 -1
  169. package/dist/type-checks/src/is-object.cjs +0 -19
  170. package/dist/type-checks/src/is-object.mjs +0 -20
  171. package/dist/type-checks/src/is-object.mjs.map +0 -1
  172. package/dist/type-checks/src/is-plain-object.mjs.map +0 -1
  173. package/dist/type-checks/src/is-set-object.cjs +0 -19
  174. package/dist/type-checks/src/is-set-object.mjs +0 -20
  175. package/dist/type-checks/src/is-set-object.mjs.map +0 -1
  176. package/dist/type-checks/src/is-set.cjs +0 -19
  177. package/dist/type-checks/src/is-set.mjs +0 -20
  178. package/dist/type-checks/src/is-set.mjs.map +0 -1
  179. package/dist/type-checks/src/is-string.mjs.map +0 -1
  180. package/dist/type-checks/src/is-undefined.mjs.map +0 -1
  181. package/dist/types/src/base.cjs +0 -6
  182. package/dist/types/src/base.mjs +0 -6
  183. package/dist/types/src/base.mjs.map +0 -1
  184. package/dist/types/src/json.d.cts +0 -12
  185. package/dist/types/src/json.d.cts.map +0 -1
  186. package/dist/types/src/json.d.mts +0 -12
  187. package/dist/types/src/json.d.mts.map +0 -1
  188. package/dist/types.d.cts.map +0 -1
  189. package/dist/types.d.mts.map +0 -1
  190. package/dist/utils/code-frames.d.cts.map +0 -1
  191. package/dist/utils/code-frames.d.mts.map +0 -1
  192. package/dist/utils/code-frames.mjs.map +0 -1
  193. package/dist/utils/parse-error.d.cts.map +0 -1
  194. package/dist/utils/parse-error.d.mts.map +0 -1
  195. package/dist/utils/parse-error.mjs.map +0 -1
  196. package/dist/utils/parse.d.cts.map +0 -1
  197. package/dist/utils/parse.d.mts.map +0 -1
  198. package/dist/utils/parse.mjs.map +0 -1
  199. package/dist/utils/stringify.d.cts.map +0 -1
  200. package/dist/utils/stringify.d.mts.map +0 -1
  201. package/dist/utils/stringify.mjs.map +0 -1
  202. package/dist/utils/strip-comments.d.cts.map +0 -1
  203. package/dist/utils/strip-comments.d.mts.map +0 -1
  204. package/dist/utils/strip-comments.mjs.map +0 -1
@@ -1,34 +1,3 @@
1
- const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
- const require_utils_code_frames = require('./code-frames.cjs');
3
- let jsonc_parser = require("jsonc-parser");
4
- let lines_and_columns = require("lines-and-columns");
1
+ const require_parse_error = require('../parse-error-N7UE-HMh.cjs');
5
2
 
6
- //#region src/utils/parse-error.ts
7
- /**
8
- * Nicely formats a JSON error with context
9
- *
10
- * @param input - JSON content as string
11
- * @param parseError - jsonc ParseError
12
- * @returns
13
- */
14
- function formatParseError(input, parseError) {
15
- const { error, offset, length } = parseError;
16
- const result = new lines_and_columns.LinesAndColumns(input).locationForIndex(offset);
17
- let line = result?.line ?? 0;
18
- let column = result?.column ?? 0;
19
- line++;
20
- column++;
21
- return `${(0, jsonc_parser.printParseErrorCode)(error)} in JSON at ${line}:${column}\n${require_utils_code_frames.codeFrameColumns(input, {
22
- start: {
23
- line,
24
- column
25
- },
26
- end: {
27
- line,
28
- column: column + length
29
- }
30
- })}\n`;
31
- }
32
-
33
- //#endregion
34
- exports.formatParseError = formatParseError;
3
+ exports.formatParseError = require_parse_error.formatParseError;
@@ -1,15 +1,2 @@
1
- import { ParseError } from "jsonc-parser";
2
-
3
- //#region src/utils/parse-error.d.ts
4
-
5
- /**
6
- * Nicely formats a JSON error with context
7
- *
8
- * @param input - JSON content as string
9
- * @param parseError - jsonc ParseError
10
- * @returns
11
- */
12
- declare function formatParseError(input: string, parseError: ParseError): string;
13
- //#endregion
14
- export { formatParseError };
15
- //# sourceMappingURL=parse-error.d.cts.map
1
+ import { t as formatParseError } from "../parse-error-7K8s4vWf.cjs";
2
+ export { formatParseError };
@@ -1,15 +1,2 @@
1
- import { ParseError } from "jsonc-parser";
2
-
3
- //#region src/utils/parse-error.d.ts
4
-
5
- /**
6
- * Nicely formats a JSON error with context
7
- *
8
- * @param input - JSON content as string
9
- * @param parseError - jsonc ParseError
10
- * @returns
11
- */
12
- declare function formatParseError(input: string, parseError: ParseError): string;
13
- //#endregion
14
- export { formatParseError };
15
- //# sourceMappingURL=parse-error.d.mts.map
1
+ import { t as formatParseError } from "../parse-error-DpEv3vo_.mjs";
2
+ export { formatParseError };
@@ -1,34 +1,3 @@
1
- import { codeFrameColumns } from "./code-frames.mjs";
2
- import { printParseErrorCode } from "jsonc-parser";
3
- import { LinesAndColumns } from "lines-and-columns";
1
+ import { t as formatParseError } from "../parse-error-Af4zHUQ_.mjs";
4
2
 
5
- //#region src/utils/parse-error.ts
6
- /**
7
- * Nicely formats a JSON error with context
8
- *
9
- * @param input - JSON content as string
10
- * @param parseError - jsonc ParseError
11
- * @returns
12
- */
13
- function formatParseError(input, parseError) {
14
- const { error, offset, length } = parseError;
15
- const result = new LinesAndColumns(input).locationForIndex(offset);
16
- let line = result?.line ?? 0;
17
- let column = result?.column ?? 0;
18
- line++;
19
- column++;
20
- return `${printParseErrorCode(error)} in JSON at ${line}:${column}\n${codeFrameColumns(input, {
21
- start: {
22
- line,
23
- column
24
- },
25
- end: {
26
- line,
27
- column: column + length
28
- }
29
- })}\n`;
30
- }
31
-
32
- //#endregion
33
- export { formatParseError };
34
- //# sourceMappingURL=parse-error.mjs.map
3
+ export { formatParseError };
@@ -1,52 +1,4 @@
1
- const require_utils_strip_comments = require('./strip-comments.cjs');
1
+ const require_parse = require('../parse-ByDxRup5.cjs');
2
2
 
3
- //#region src/utils/parse.ts
4
- const suspectProtoRx = /"(?:_|\\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*:/;
5
- const suspectConstructorRx = /"(?: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*:/;
6
- const JsonSigRx = /^\s*["[{]|^\s*-?\d{1,16}(?:\.\d{1,17})?(?:E[+-]?\d+)?\s*$/i;
7
- function jsonParseTransform(key, value) {
8
- if (key === "__proto__" || key === "constructor" && value && typeof value === "object" && "prototype" in value) {
9
- console.warn(`Dropping "${key}" key to prevent prototype pollution.`);
10
- return;
11
- }
12
- return value;
13
- }
14
- function parse(value, options = {}) {
15
- if (typeof value !== "string") return value;
16
- let stripped = require_utils_strip_comments.stripComments(value);
17
- if (stripped[0] === "\"" && stripped[stripped.length - 1] === "\"" && !stripped.includes("\\")) return stripped.slice(1, -1);
18
- stripped = stripped.trim();
19
- if (stripped.length <= 9) switch (stripped.toLowerCase()) {
20
- case "true": return true;
21
- case "false": return false;
22
- case "undefined": return;
23
- case "null": return null;
24
- case "nan": return NaN;
25
- case "infinity": return Number.POSITIVE_INFINITY;
26
- case "-infinity": return Number.NEGATIVE_INFINITY;
27
- }
28
- if (!JsonSigRx.test(stripped)) {
29
- if (options.strict) throw new Error("Invalid JSON");
30
- return stripped;
31
- }
32
- try {
33
- if (suspectProtoRx.test(stripped) || suspectConstructorRx.test(stripped)) {
34
- if (options.strict) throw new Error("Possible prototype pollution");
35
- return JSON.parse(stripped, jsonParseTransform);
36
- }
37
- return JSON.parse(stripped);
38
- } catch (error) {
39
- if (options.strict) throw error;
40
- return value;
41
- }
42
- }
43
- function safeParse(value, options = {}) {
44
- return parse(value, {
45
- ...options,
46
- strict: true
47
- });
48
- }
49
-
50
- //#endregion
51
- exports.parse = parse;
52
- exports.safeParse = safeParse;
3
+ exports.parse = require_parse.parse;
4
+ exports.safeParse = require_parse.safeParse;
@@ -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.cts.map
1
+ import { n as parse, r as safeParse, t as Options } from "../parse-BGlhbY16.cjs";
2
+ export { Options, parse, safeParse };
@@ -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
1
+ import { n as parse, r as safeParse, t as Options } from "../parse-fXy5pbmE.mjs";
2
+ export { Options, parse, safeParse };
@@ -1,52 +1,3 @@
1
- import { stripComments } from "./strip-comments.mjs";
1
+ import { n as safeParse, t as parse } from "../parse-Dn43ZK9y.mjs";
2
2
 
3
- //#region src/utils/parse.ts
4
- const suspectProtoRx = /"(?:_|\\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*:/;
5
- const suspectConstructorRx = /"(?: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*:/;
6
- const JsonSigRx = /^\s*["[{]|^\s*-?\d{1,16}(?:\.\d{1,17})?(?:E[+-]?\d+)?\s*$/i;
7
- function jsonParseTransform(key, value) {
8
- if (key === "__proto__" || key === "constructor" && value && typeof value === "object" && "prototype" in value) {
9
- console.warn(`Dropping "${key}" key to prevent prototype pollution.`);
10
- return;
11
- }
12
- return value;
13
- }
14
- function parse(value, options = {}) {
15
- if (typeof value !== "string") return value;
16
- let stripped = stripComments(value);
17
- if (stripped[0] === "\"" && stripped[stripped.length - 1] === "\"" && !stripped.includes("\\")) return stripped.slice(1, -1);
18
- stripped = stripped.trim();
19
- if (stripped.length <= 9) switch (stripped.toLowerCase()) {
20
- case "true": return true;
21
- case "false": return false;
22
- case "undefined": return;
23
- case "null": return null;
24
- case "nan": return NaN;
25
- case "infinity": return Number.POSITIVE_INFINITY;
26
- case "-infinity": return Number.NEGATIVE_INFINITY;
27
- }
28
- if (!JsonSigRx.test(stripped)) {
29
- if (options.strict) throw new Error("Invalid JSON");
30
- return stripped;
31
- }
32
- try {
33
- if (suspectProtoRx.test(stripped) || suspectConstructorRx.test(stripped)) {
34
- if (options.strict) throw new Error("Possible prototype pollution");
35
- return JSON.parse(stripped, jsonParseTransform);
36
- }
37
- return JSON.parse(stripped);
38
- } catch (error) {
39
- if (options.strict) throw error;
40
- return value;
41
- }
42
- }
43
- function safeParse(value, options = {}) {
44
- return parse(value, {
45
- ...options,
46
- strict: true
47
- });
48
- }
49
-
50
- //#endregion
51
- export { parse, safeParse };
52
- //# sourceMappingURL=parse.mjs.map
3
+ export { parse, safeParse };
@@ -1,68 +1,4 @@
1
- const require_is_number = require('../type-checks/src/is-number.cjs');
2
- const require_is_undefined = require('../type-checks/src/is-undefined.cjs');
1
+ const require_stringify = require('../stringify-BehjrfhS.cjs');
3
2
 
4
- //#region src/utils/stringify.ts
5
- const invalidKeyChars = [
6
- "@",
7
- "/",
8
- "#",
9
- "$",
10
- " ",
11
- ":",
12
- ";",
13
- ",",
14
- ".",
15
- "!",
16
- "?",
17
- "&",
18
- "=",
19
- "+",
20
- "-",
21
- "*",
22
- "%",
23
- "^",
24
- "~",
25
- "|",
26
- "\\",
27
- "\"",
28
- "'",
29
- "`",
30
- "{",
31
- "}",
32
- "[",
33
- "]",
34
- "(",
35
- ")",
36
- "<",
37
- ">"
38
- ];
39
- /**
40
- * Stringify a value to a JSON-like string.
41
- *
42
- * @param value - The value to stringify
43
- * @param spacing - The spacing to use for the stringification
44
- * @returns The stringified value
45
- */
46
- const stringify = (value, spacing = 2) => {
47
- const space = require_is_number.isNumber(spacing) ? " ".repeat(spacing) : spacing;
48
- switch (value) {
49
- case null: return "null";
50
- case void 0: return "\"undefined\"";
51
- case true: return "true";
52
- case false: return "false";
53
- case Number.POSITIVE_INFINITY: return "infinity";
54
- case Number.NEGATIVE_INFINITY: return "-infinity";
55
- }
56
- if (Array.isArray(value)) return `[${space}${value.map((v) => stringify(v, space)).join(`,${space}`)}${space}]`;
57
- if (value instanceof Uint8Array) return value.toString();
58
- switch (typeof value) {
59
- case "number": return `${value}`;
60
- case "string": return JSON.stringify(value);
61
- case "object": return `{${space}${Object.keys(value).filter((key) => !require_is_undefined.isUndefined(value[key])).map((key) => `${invalidKeyChars.some((invalidKeyChar) => key.includes(invalidKeyChar)) ? `"${key}"` : key}: ${space}${stringify(value[key], space)}`).join(`,${space}`)}${space}}`;
62
- default: return "null";
63
- }
64
- };
65
-
66
- //#endregion
67
- exports.invalidKeyChars = invalidKeyChars;
68
- exports.stringify = stringify;
3
+ exports.invalidKeyChars = require_stringify.invalidKeyChars;
4
+ exports.stringify = require_stringify.stringify;
@@ -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
1
+ import { n as stringify, t as invalidKeyChars } from "../stringify-Bc8OkhIr.cjs";
2
+ export { invalidKeyChars, stringify };
@@ -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
1
+ import { n as stringify, t as invalidKeyChars } from "../stringify-CFT1K1LE.mjs";
2
+ export { invalidKeyChars, stringify };
@@ -1,68 +1,3 @@
1
- import { isNumber } from "../type-checks/src/is-number.mjs";
2
- import { isUndefined } from "../type-checks/src/is-undefined.mjs";
1
+ import { n as stringify, t as invalidKeyChars } from "../stringify-CYHjAvWm.mjs";
3
2
 
4
- //#region src/utils/stringify.ts
5
- const invalidKeyChars = [
6
- "@",
7
- "/",
8
- "#",
9
- "$",
10
- " ",
11
- ":",
12
- ";",
13
- ",",
14
- ".",
15
- "!",
16
- "?",
17
- "&",
18
- "=",
19
- "+",
20
- "-",
21
- "*",
22
- "%",
23
- "^",
24
- "~",
25
- "|",
26
- "\\",
27
- "\"",
28
- "'",
29
- "`",
30
- "{",
31
- "}",
32
- "[",
33
- "]",
34
- "(",
35
- ")",
36
- "<",
37
- ">"
38
- ];
39
- /**
40
- * Stringify a value to a JSON-like string.
41
- *
42
- * @param value - The value to stringify
43
- * @param spacing - The spacing to use for the stringification
44
- * @returns The stringified value
45
- */
46
- const stringify = (value, spacing = 2) => {
47
- const space = isNumber(spacing) ? " ".repeat(spacing) : spacing;
48
- switch (value) {
49
- case null: return "null";
50
- case void 0: return "\"undefined\"";
51
- case true: return "true";
52
- case false: return "false";
53
- case Number.POSITIVE_INFINITY: return "infinity";
54
- case Number.NEGATIVE_INFINITY: return "-infinity";
55
- }
56
- if (Array.isArray(value)) return `[${space}${value.map((v) => stringify(v, space)).join(`,${space}`)}${space}]`;
57
- if (value instanceof Uint8Array) return value.toString();
58
- switch (typeof value) {
59
- case "number": return `${value}`;
60
- case "string": return JSON.stringify(value);
61
- case "object": return `{${space}${Object.keys(value).filter((key) => !isUndefined(value[key])).map((key) => `${invalidKeyChars.some((invalidKeyChar) => key.includes(invalidKeyChar)) ? `"${key}"` : key}: ${space}${stringify(value[key], space)}`).join(`,${space}`)}${space}}`;
62
- default: return "null";
63
- }
64
- };
65
-
66
- //#endregion
67
- export { invalidKeyChars, stringify };
68
- //# sourceMappingURL=stringify.mjs.map
3
+ export { invalidKeyChars, stringify };
@@ -1,86 +1,3 @@
1
- const require_base = require('../types/src/base.cjs');
1
+ const require_strip_comments = require('../strip-comments-CmEG_smS.cjs');
2
2
 
3
- //#region src/utils/strip-comments.ts
4
- const singleComment = Symbol("singleComment");
5
- const multiComment = Symbol("multiComment");
6
- function stripWithoutWhitespace() {
7
- return "";
8
- }
9
- function stripWithWhitespace(value, start, end) {
10
- return value.slice(start, end).replace(/\S/g, " ");
11
- }
12
- function isEscaped(value, quotePosition) {
13
- let index = quotePosition - 1;
14
- let backslashCount = 0;
15
- while (value[index] === "\\") {
16
- index -= 1;
17
- backslashCount += 1;
18
- }
19
- return Boolean(backslashCount % 2);
20
- }
21
- function stripComments(value, { whitespace = true, trailingCommas = false } = {}) {
22
- if (typeof value !== "string") throw new TypeError(`Expected argument \`jsonString\` to be a \`string\`, got \`${typeof value}\``);
23
- const strip = whitespace ? stripWithWhitespace : stripWithoutWhitespace;
24
- let isInsideString = false;
25
- let isInsideComment = false;
26
- let offset = 0;
27
- let buffer = "";
28
- let result = "";
29
- let commaIndex = -1;
30
- for (let index = 0; index < value.length; index++) {
31
- const currentCharacter = value[index];
32
- const nextCharacter = value[index + 1];
33
- if (!isInsideComment && currentCharacter === "\"") {
34
- if (!isEscaped(value, index)) isInsideString = !isInsideString;
35
- }
36
- if (isInsideString) continue;
37
- if (!isInsideComment && currentCharacter + (nextCharacter ?? require_base.EMPTY_STRING) === "//") {
38
- buffer += value.slice(offset, index);
39
- offset = index;
40
- isInsideComment = singleComment;
41
- index++;
42
- } else if (isInsideComment === singleComment && currentCharacter + (nextCharacter ?? require_base.EMPTY_STRING) === "\r\n") {
43
- index++;
44
- isInsideComment = false;
45
- buffer += strip(value, offset, index);
46
- offset = index;
47
- } else if (isInsideComment === singleComment && currentCharacter === "\n") {
48
- isInsideComment = false;
49
- buffer += strip(value, offset, index);
50
- offset = index;
51
- } else if (!isInsideComment && currentCharacter + (nextCharacter ?? require_base.EMPTY_STRING) === "/*") {
52
- buffer += value.slice(offset, index);
53
- offset = index;
54
- isInsideComment = multiComment;
55
- index++;
56
- } else if (isInsideComment === multiComment && currentCharacter + (nextCharacter ?? require_base.EMPTY_STRING) === "*/") {
57
- index++;
58
- isInsideComment = false;
59
- buffer += strip(value, offset, index + 1);
60
- offset = index + 1;
61
- } else if (trailingCommas && !isInsideComment) {
62
- if (commaIndex !== -1) {
63
- if (currentCharacter === "}" || currentCharacter === "]") {
64
- buffer += value.slice(offset, index);
65
- result += strip(buffer, 0, 1) + buffer.slice(1);
66
- buffer = "";
67
- offset = index;
68
- commaIndex = -1;
69
- } else if (currentCharacter !== " " && currentCharacter !== " " && currentCharacter !== "\r" && currentCharacter !== "\n") {
70
- buffer += value.slice(offset, index);
71
- offset = index;
72
- commaIndex = -1;
73
- }
74
- } else if (currentCharacter === ",") {
75
- result += buffer + value.slice(offset, index);
76
- buffer = "";
77
- offset = index;
78
- commaIndex = index;
79
- }
80
- }
81
- }
82
- return result + buffer + (isInsideComment ? strip(value.slice(offset)) : value.slice(offset));
83
- }
84
-
85
- //#endregion
86
- exports.stripComments = stripComments;
3
+ exports.stripComments = require_strip_comments.stripComments;
@@ -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
1
+ import { t as stripComments } from "../strip-comments-Cz_Wc25t.cjs";
2
+ export { stripComments };
@@ -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
1
+ import { t as stripComments } from "../strip-comments-BA8MS_Fs.mjs";
2
+ export { stripComments };
@@ -1,87 +1,3 @@
1
- import { EMPTY_STRING } from "../types/src/base.mjs";
1
+ import { t as stripComments } from "../strip-comments-Dq00N_Sg.mjs";
2
2
 
3
- //#region src/utils/strip-comments.ts
4
- const singleComment = Symbol("singleComment");
5
- const multiComment = Symbol("multiComment");
6
- function stripWithoutWhitespace() {
7
- return "";
8
- }
9
- function stripWithWhitespace(value, start, end) {
10
- return value.slice(start, end).replace(/\S/g, " ");
11
- }
12
- function isEscaped(value, quotePosition) {
13
- let index = quotePosition - 1;
14
- let backslashCount = 0;
15
- while (value[index] === "\\") {
16
- index -= 1;
17
- backslashCount += 1;
18
- }
19
- return Boolean(backslashCount % 2);
20
- }
21
- function stripComments(value, { whitespace = true, trailingCommas = false } = {}) {
22
- if (typeof value !== "string") throw new TypeError(`Expected argument \`jsonString\` to be a \`string\`, got \`${typeof value}\``);
23
- const strip = whitespace ? stripWithWhitespace : stripWithoutWhitespace;
24
- let isInsideString = false;
25
- let isInsideComment = false;
26
- let offset = 0;
27
- let buffer = "";
28
- let result = "";
29
- let commaIndex = -1;
30
- for (let index = 0; index < value.length; index++) {
31
- const currentCharacter = value[index];
32
- const nextCharacter = value[index + 1];
33
- if (!isInsideComment && currentCharacter === "\"") {
34
- if (!isEscaped(value, index)) isInsideString = !isInsideString;
35
- }
36
- if (isInsideString) continue;
37
- if (!isInsideComment && currentCharacter + (nextCharacter ?? EMPTY_STRING) === "//") {
38
- buffer += value.slice(offset, index);
39
- offset = index;
40
- isInsideComment = singleComment;
41
- index++;
42
- } else if (isInsideComment === singleComment && currentCharacter + (nextCharacter ?? EMPTY_STRING) === "\r\n") {
43
- index++;
44
- isInsideComment = false;
45
- buffer += strip(value, offset, index);
46
- offset = index;
47
- } else if (isInsideComment === singleComment && currentCharacter === "\n") {
48
- isInsideComment = false;
49
- buffer += strip(value, offset, index);
50
- offset = index;
51
- } else if (!isInsideComment && currentCharacter + (nextCharacter ?? EMPTY_STRING) === "/*") {
52
- buffer += value.slice(offset, index);
53
- offset = index;
54
- isInsideComment = multiComment;
55
- index++;
56
- } else if (isInsideComment === multiComment && currentCharacter + (nextCharacter ?? EMPTY_STRING) === "*/") {
57
- index++;
58
- isInsideComment = false;
59
- buffer += strip(value, offset, index + 1);
60
- offset = index + 1;
61
- } else if (trailingCommas && !isInsideComment) {
62
- if (commaIndex !== -1) {
63
- if (currentCharacter === "}" || currentCharacter === "]") {
64
- buffer += value.slice(offset, index);
65
- result += strip(buffer, 0, 1) + buffer.slice(1);
66
- buffer = "";
67
- offset = index;
68
- commaIndex = -1;
69
- } else if (currentCharacter !== " " && currentCharacter !== " " && currentCharacter !== "\r" && currentCharacter !== "\n") {
70
- buffer += value.slice(offset, index);
71
- offset = index;
72
- commaIndex = -1;
73
- }
74
- } else if (currentCharacter === ",") {
75
- result += buffer + value.slice(offset, index);
76
- buffer = "";
77
- offset = index;
78
- commaIndex = index;
79
- }
80
- }
81
- }
82
- return result + buffer + (isInsideComment ? strip(value.slice(offset)) : value.slice(offset));
83
- }
84
-
85
- //#endregion
86
- export { stripComments };
87
- //# sourceMappingURL=strip-comments.mjs.map
3
+ export { stripComments };
File without changes
File without changes