@stryke/json 0.9.43 → 0.10.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 (201) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/code-frames-BMkA9i6j.d.mts +17 -0
  3. package/dist/code-frames-BMkA9i6j.d.mts.map +1 -0
  4. package/dist/code-frames-BUtrssZ5.d.cts +17 -0
  5. package/dist/code-frames-BUtrssZ5.d.cts.map +1 -0
  6. package/dist/code-frames-Cv8r5tSN.cjs +82 -0
  7. package/dist/code-frames-DISWdYL6.mjs +77 -0
  8. package/dist/code-frames-DISWdYL6.mjs.map +1 -0
  9. package/dist/find-reference-BCg3dQx1.cjs +157 -0
  10. package/dist/find-reference-C-YleCds.d.cts +52 -0
  11. package/dist/find-reference-C-YleCds.d.cts.map +1 -0
  12. package/dist/find-reference-b7rRdLFx.d.mts +52 -0
  13. package/dist/find-reference-b7rRdLFx.d.mts.map +1 -0
  14. package/dist/find-reference-woYMiWzN.mjs +135 -0
  15. package/dist/find-reference-woYMiWzN.mjs.map +1 -0
  16. package/dist/index-B_e8BwCm.d.cts +1 -0
  17. package/dist/index-CDAfh8Ew.d.cts +1 -0
  18. package/dist/index-DwO9IdNa.d.mts +1 -0
  19. package/dist/index-VWno75SQ.d.mts +1 -0
  20. package/dist/index.cjs +32 -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/{type-checks/src/is-string.mjs → is-string-C2RK4Gjs.cjs} +7 -2
  31. package/dist/{type-checks/src/is-string.cjs → is-string-CLiBUSKV.mjs} +2 -2
  32. package/dist/is-string-CLiBUSKV.mjs.map +1 -0
  33. package/dist/{type-checks/src/is-undefined.cjs → is-undefined-CmyJWYGD.mjs} +2 -2
  34. package/dist/is-undefined-CmyJWYGD.mjs.map +1 -0
  35. package/dist/{type-checks/src/is-undefined.mjs → is-undefined-CnI0qe-z.cjs} +7 -2
  36. package/dist/parse-BGlhbY16.d.cts +9 -0
  37. package/dist/parse-BGlhbY16.d.cts.map +1 -0
  38. package/dist/parse-Crgv3Nl1.mjs +81 -0
  39. package/dist/parse-Crgv3Nl1.mjs.map +1 -0
  40. package/dist/parse-DZfi3d96.d.cts +51 -0
  41. package/dist/parse-DZfi3d96.d.cts.map +1 -0
  42. package/dist/parse-DgYW5BBj.d.mts +9 -0
  43. package/dist/parse-DgYW5BBj.d.mts.map +1 -0
  44. package/dist/parse-KiRakdIR.cjs +127 -0
  45. package/dist/parse-ZRTh45ZI.d.mts +51 -0
  46. package/dist/parse-ZRTh45ZI.d.mts.map +1 -0
  47. package/dist/parse-error-7K8s4vWf.d.cts +15 -0
  48. package/dist/parse-error-7K8s4vWf.d.cts.map +1 -0
  49. package/dist/parse-error-C3Qmubee.mjs +34 -0
  50. package/dist/parse-error-C3Qmubee.mjs.map +1 -0
  51. package/dist/parse-error-DY_MelEh.d.mts +15 -0
  52. package/dist/parse-error-DY_MelEh.d.mts.map +1 -0
  53. package/dist/parse-error-Dzwg4sdE.cjs +39 -0
  54. package/dist/parse-obdkJfj5.mjs +52 -0
  55. package/dist/parse-obdkJfj5.mjs.map +1 -0
  56. package/dist/parse-wxSDzBPf.cjs +62 -0
  57. package/dist/pointer/find-reference.cjs +5 -65
  58. package/dist/pointer/find-reference.d.cts +2 -52
  59. package/dist/pointer/find-reference.d.mts +2 -52
  60. package/dist/pointer/find-reference.mjs +2 -63
  61. package/dist/pointer/index.cjs +15 -14
  62. package/dist/pointer/index.d.cts +2 -2
  63. package/dist/pointer/index.d.mts +2 -2
  64. package/dist/pointer/index.mjs +3 -2
  65. package/dist/pointer/parse.cjs +9 -86
  66. package/dist/pointer/parse.d.cts +2 -44
  67. package/dist/pointer/parse.d.mts +2 -44
  68. package/dist/pointer/parse.mjs +2 -80
  69. package/dist/pointer-Cc7IR0Bj.cjs +0 -0
  70. package/dist/pointer-CiTXvh1G.mjs +0 -0
  71. package/dist/schema-B1RVJHzJ.d.cts +7 -0
  72. package/dist/schema-B1RVJHzJ.d.cts.map +1 -0
  73. package/dist/schema-CfhPLy30.mjs +9 -0
  74. package/dist/schema-CfhPLy30.mjs.map +1 -0
  75. package/dist/schema-D5Aqvh2i.cjs +14 -0
  76. package/dist/schema-ai_NU-JC.d.mts +7 -0
  77. package/dist/schema-ai_NU-JC.d.mts.map +1 -0
  78. package/dist/schema.cjs +3 -0
  79. package/dist/schema.d.cts +2 -0
  80. package/dist/schema.d.mts +3 -0
  81. package/dist/schema.mjs +3 -0
  82. package/dist/storm-json-6WpS7qnH.cjs +154 -0
  83. package/dist/storm-json-AaFeOao2.d.cts +70 -0
  84. package/dist/storm-json-AaFeOao2.d.cts.map +1 -0
  85. package/dist/storm-json-BvRkzAlR.d.mts +70 -0
  86. package/dist/storm-json-BvRkzAlR.d.mts.map +1 -0
  87. package/dist/storm-json-Cy3PuAhj.mjs +116 -0
  88. package/dist/storm-json-Cy3PuAhj.mjs.map +1 -0
  89. package/dist/storm-json.cjs +3 -116
  90. package/dist/storm-json.d.cts +2 -70
  91. package/dist/storm-json.d.mts +3 -70
  92. package/dist/storm-json.mjs +3 -115
  93. package/dist/stringify-B6iAeg0u.d.mts +13 -0
  94. package/dist/stringify-B6iAeg0u.d.mts.map +1 -0
  95. package/dist/stringify-Bc8OkhIr.d.cts +13 -0
  96. package/dist/stringify-Bc8OkhIr.d.cts.map +1 -0
  97. package/dist/stringify-D5baUfEe.mjs +68 -0
  98. package/dist/stringify-D5baUfEe.mjs.map +1 -0
  99. package/dist/stringify-DEw3S4_Z.cjs +78 -0
  100. package/dist/strip-comments-Bg3R_Y4S.d.mts +11 -0
  101. package/dist/strip-comments-Bg3R_Y4S.d.mts.map +1 -0
  102. package/dist/strip-comments-CMaAgTqz.mjs +89 -0
  103. package/dist/strip-comments-CMaAgTqz.mjs.map +1 -0
  104. package/dist/strip-comments-CtFoX0xG.cjs +94 -0
  105. package/dist/strip-comments-Cz_Wc25t.d.cts +11 -0
  106. package/dist/strip-comments-Cz_Wc25t.d.cts.map +1 -0
  107. package/dist/types-BUeTTE_U.d.cts +222 -0
  108. package/dist/types-BUeTTE_U.d.cts.map +1 -0
  109. package/dist/types-C_KlcCNw.d.mts +222 -0
  110. package/dist/types-C_KlcCNw.d.mts.map +1 -0
  111. package/dist/types.d.cts +2 -69
  112. package/dist/types.d.mts +2 -69
  113. package/dist/types.mjs +0 -1
  114. package/dist/utils/code-frames.cjs +2 -76
  115. package/dist/utils/code-frames.d.cts +2 -17
  116. package/dist/utils/code-frames.d.mts +2 -17
  117. package/dist/utils/code-frames.mjs +2 -76
  118. package/dist/utils/index.cjs +13 -12
  119. package/dist/utils/index.d.cts +5 -5
  120. package/dist/utils/index.d.mts +6 -5
  121. package/dist/utils/index.mjs +6 -5
  122. package/dist/utils/parse-error.cjs +2 -33
  123. package/dist/utils/parse-error.d.cts +2 -15
  124. package/dist/utils/parse-error.d.mts +2 -15
  125. package/dist/utils/parse-error.mjs +2 -33
  126. package/dist/utils/parse.cjs +3 -51
  127. package/dist/utils/parse.d.cts +2 -9
  128. package/dist/utils/parse.d.mts +2 -9
  129. package/dist/utils/parse.mjs +2 -51
  130. package/dist/utils/stringify.cjs +3 -67
  131. package/dist/utils/stringify.d.cts +2 -13
  132. package/dist/utils/stringify.d.mts +2 -13
  133. package/dist/utils/stringify.mjs +2 -67
  134. package/dist/utils/strip-comments.cjs +2 -85
  135. package/dist/utils/strip-comments.d.cts +2 -11
  136. package/dist/utils/strip-comments.d.mts +2 -11
  137. package/dist/utils/strip-comments.mjs +2 -86
  138. package/dist/utils-CVcIdLuL.mjs +0 -0
  139. package/dist/utils-Cz3OCwUK.cjs +0 -0
  140. package/package.json +8 -3
  141. package/dist/_virtual/rolldown_runtime.cjs +0 -29
  142. package/dist/pointer/find-reference.d.cts.map +0 -1
  143. package/dist/pointer/find-reference.d.mts.map +0 -1
  144. package/dist/pointer/find-reference.mjs.map +0 -1
  145. package/dist/pointer/parse.d.cts.map +0 -1
  146. package/dist/pointer/parse.d.mts.map +0 -1
  147. package/dist/pointer/parse.mjs.map +0 -1
  148. package/dist/storm-json.d.cts.map +0 -1
  149. package/dist/storm-json.d.mts.map +0 -1
  150. package/dist/storm-json.mjs.map +0 -1
  151. package/dist/type-checks/src/get-object-tag.cjs +0 -15
  152. package/dist/type-checks/src/get-object-tag.mjs +0 -15
  153. package/dist/type-checks/src/get-object-tag.mjs.map +0 -1
  154. package/dist/type-checks/src/is-empty.cjs +0 -20
  155. package/dist/type-checks/src/is-empty.mjs +0 -21
  156. package/dist/type-checks/src/is-empty.mjs.map +0 -1
  157. package/dist/type-checks/src/is-non-null-object.cjs +0 -16
  158. package/dist/type-checks/src/is-non-null-object.mjs +0 -17
  159. package/dist/type-checks/src/is-non-null-object.mjs.map +0 -1
  160. package/dist/type-checks/src/is-null.cjs +0 -12
  161. package/dist/type-checks/src/is-null.mjs +0 -12
  162. package/dist/type-checks/src/is-null.mjs.map +0 -1
  163. package/dist/type-checks/src/is-number.cjs +0 -18
  164. package/dist/type-checks/src/is-number.mjs +0 -18
  165. package/dist/type-checks/src/is-number.mjs.map +0 -1
  166. package/dist/type-checks/src/is-object.cjs +0 -19
  167. package/dist/type-checks/src/is-object.mjs +0 -20
  168. package/dist/type-checks/src/is-object.mjs.map +0 -1
  169. package/dist/type-checks/src/is-plain-object.mjs.map +0 -1
  170. package/dist/type-checks/src/is-set-object.cjs +0 -19
  171. package/dist/type-checks/src/is-set-object.mjs +0 -20
  172. package/dist/type-checks/src/is-set-object.mjs.map +0 -1
  173. package/dist/type-checks/src/is-set.cjs +0 -19
  174. package/dist/type-checks/src/is-set.mjs +0 -20
  175. package/dist/type-checks/src/is-set.mjs.map +0 -1
  176. package/dist/type-checks/src/is-string.mjs.map +0 -1
  177. package/dist/type-checks/src/is-undefined.mjs.map +0 -1
  178. package/dist/types/src/base.cjs +0 -6
  179. package/dist/types/src/base.mjs +0 -6
  180. package/dist/types/src/base.mjs.map +0 -1
  181. package/dist/types/src/json.d.cts +0 -12
  182. package/dist/types/src/json.d.cts.map +0 -1
  183. package/dist/types/src/json.d.mts +0 -12
  184. package/dist/types/src/json.d.mts.map +0 -1
  185. package/dist/types.d.cts.map +0 -1
  186. package/dist/types.d.mts.map +0 -1
  187. package/dist/utils/code-frames.d.cts.map +0 -1
  188. package/dist/utils/code-frames.d.mts.map +0 -1
  189. package/dist/utils/code-frames.mjs.map +0 -1
  190. package/dist/utils/parse-error.d.cts.map +0 -1
  191. package/dist/utils/parse-error.d.mts.map +0 -1
  192. package/dist/utils/parse-error.mjs.map +0 -1
  193. package/dist/utils/parse.d.cts.map +0 -1
  194. package/dist/utils/parse.d.mts.map +0 -1
  195. package/dist/utils/parse.mjs.map +0 -1
  196. package/dist/utils/stringify.d.cts.map +0 -1
  197. package/dist/utils/stringify.d.mts.map +0 -1
  198. package/dist/utils/stringify.mjs.map +0 -1
  199. package/dist/utils/strip-comments.d.cts.map +0 -1
  200. package/dist/utils/strip-comments.d.mts.map +0 -1
  201. package/dist/utils/strip-comments.mjs.map +0 -1
@@ -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-D5baUfEe.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-CtFoX0xG.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-Bg3R_Y4S.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-CMaAgTqz.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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stryke/json",
3
- "version": "0.9.43",
3
+ "version": "0.10.0",
4
4
  "type": "module",
5
5
  "description": "A package containing JSON parsing/stringify utilities used by Storm Software.",
6
6
  "repository": {
@@ -25,6 +25,10 @@
25
25
  "require": "./dist/pointer/parse.cjs",
26
26
  "import": "./dist/pointer/parse.mjs"
27
27
  },
28
+ "./schema": {
29
+ "require": "./dist/schema.cjs",
30
+ "import": "./dist/schema.mjs"
31
+ },
28
32
  "./storm-json": {
29
33
  "require": "./dist/storm-json.cjs",
30
34
  "import": "./dist/storm-json.mjs"
@@ -59,10 +63,11 @@
59
63
  "types": "./dist/index.d.cts",
60
64
  "dependencies": {
61
65
  "buffer": "6.0.3",
66
+ "jsonc-parser": "3.3.1",
62
67
  "lines-and-columns": "2.0.4",
63
68
  "superjson": "2.2.2"
64
69
  },
65
- "devDependencies": { "@types/node": "^24.10.12", "tsdown": "^0.17.2" },
70
+ "devDependencies": { "@types/node": "^24.11.0", "tsdown": "^0.17.2" },
66
71
  "publishConfig": { "access": "public" },
67
- "gitHead": "6dde4aa98913fd92c253aff3b574cdd5e048b9dc"
72
+ "gitHead": "7755bd92180cadaa0ef8168e4e123deaacc4ccb8"
68
73
  }
@@ -1,29 +0,0 @@
1
- //#region rolldown:runtime
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from === "object" || typeof from === "function") {
10
- for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
11
- key = keys[i];
12
- if (!__hasOwnProp.call(to, key) && key !== except) {
13
- __defProp(to, key, {
14
- get: ((k) => from[k]).bind(null, key),
15
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
- });
17
- }
18
- }
19
- }
20
- return to;
21
- };
22
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
23
- value: mod,
24
- enumerable: true
25
- }) : target, mod));
26
-
27
- //#endregion
28
-
29
- exports.__toESM = __toESM;
@@ -1 +0,0 @@
1
- {"version":3,"file":"find-reference.d.cts","names":[],"sources":["../../src/pointer/find-reference.ts"],"sourcesContent":[],"mappings":";UAqBiB,SAAA;EAAA;EAoCJ,SAyCZ,GAAA,EAAA,OAzCwC;EA2CxB;EAOJ,SAAA,GAAA,CAAA,EAAA,OAEiE,GAAA,MAAA,GAAA,OAAA,EAAA;EADvE;EACkB,SAAA,GAAA,CAAA,EAAA,MAAA,GAAA,MAAA;;;AAEzB;AAGA;;;;;AAMA;;;;;;;;;;;;;;;;;;cA/Da,2BAA4B,uBAAqB;UA2C7C;;4BAEW;gBACZ;;;cAIH,qCACN,qBACG,eAAe;cAEZ,kBAAmB;UAGf;gBACD;gBACA,eAAe;;;cAIlB,sCACN,qBACG,gBAAgB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"find-reference.d.mts","names":[],"sources":["../../src/pointer/find-reference.ts"],"sourcesContent":[],"mappings":";UAqBiB,SAAA;EAAA;EAoCJ,SAyCZ,GAAA,EAAA,OAzCwC;EA2CxB;EAOJ,SAAA,GAAA,CAAA,EAAA,OAEiE,GAAA,MAAA,GAAA,OAAA,EAAA;EADvE;EACkB,SAAA,GAAA,CAAA,EAAA,MAAA,GAAA,MAAA;;;AAEzB;AAGA;;;;;AAMA;;;;;;;;;;;;;;;;;;cA/Da,2BAA4B,uBAAqB;UA2C7C;;4BAEW;gBACZ;;;cAIH,qCACN,qBACG,eAAe;cAEZ,kBAAmB;UAGf;gBACD;gBACA,eAAe;;;cAIlB,sCACN,qBACG,gBAAgB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"find-reference.mjs","names":["obj: Reference[\"obj\"]","key: Reference[\"key\"]"],"sources":["../../src/pointer/find-reference.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isString } from \"@stryke/type-checks/is-string\";\n\nexport interface Reference {\n /** Target value where pointer is pointing. */\n readonly val: unknown;\n /** Object which contains the target value. */\n readonly obj?: unknown | object | unknown[];\n /** Key which targets the target value in the object. */\n readonly key?: string | number;\n}\n\nconst { isArray } = Array;\n\n/**\n * Finds a target in document specified by JSON Pointer. Also returns the\n * object containing the target and key used to reference that object.\n *\n * Throws Error('NOT_FOUND') if pointer does not result into a value in the middle\n * of the path. If the last element of the path does not result into a value, the\n * lookup succeeds with `val` set to `undefined`. It can be used to discriminate\n * missing values, because `undefined` is not a valid JSON value.\n *\n * If last element in array is targeted using \"-\", e.g. \"/arr/-\", use\n * `isArrayEnd` to verify that:\n *\n * ```js\n * const ref = find({arr: [1, 2, 3], ['arr', '-']});\n * if (isArrayReference(ref)) {\n * if (isArrayEnd(ref)) {\n * // ...\n * }\n * }\n * ```\n *\n * @param val - Document to search in.\n * @param path - JSON Pointer path.\n * @returns Reference to the target.\n */\nexport const find = (val: unknown, path: Reference[\"key\"][]): Reference => {\n const pathLength = path.length;\n if (!pathLength) {\n return { val };\n }\n\n let obj: Reference[\"obj\"];\n let key: Reference[\"key\"];\n for (let i = 0; i < pathLength; i++) {\n obj = val;\n key = path[i];\n if (isArray(obj)) {\n const length = obj.length;\n if (key === \"-\") {\n key = length;\n } else if (isString(key)) {\n const key2 = Math.trunc(Number.parseInt(key));\n if (String(key2) !== key) {\n throw new Error(\"INVALID_INDEX\");\n }\n\n key = key2;\n if (key < 0) {\n throw new Error(\"INVALID_INDEX\");\n }\n }\n\n if (key) {\n val = obj[key];\n }\n } else if (isSetObject(obj)) {\n val = key && key in obj ? (obj as any)[key] : undefined;\n } else throw new Error(\"NOT_FOUND\");\n }\n const ref: Reference = {\n val,\n obj,\n key\n };\n\n return ref;\n};\n\nexport interface ArrayReference<T = unknown> {\n /** `undefined` in case JSON Pointer points to last element, e.g. \"/foo/-\". */\n readonly val: undefined | T;\n readonly obj: T[];\n readonly key: number;\n}\n\nexport const isArrayReference = <T = unknown>(\n ref: Reference\n): ref is ArrayReference<T> => isArray(ref.obj) && typeof ref.key === \"number\";\n\nexport const isArrayEnd = (ref: ArrayReference): boolean =>\n ref.obj.length === ref.key;\n\nexport interface ObjectReference<T = unknown> {\n readonly val: T;\n readonly obj: Record<string, T>;\n readonly key: string;\n}\n\nexport const isObjectReference = <T = unknown>(\n ref: Reference\n): ref is ObjectReference<T> =>\n typeof ref.obj === \"object\" && typeof ref.key === \"string\";\n"],"mappings":";;;;AA8BA,MAAM,EAAE,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BpB,MAAa,QAAQ,KAAc,SAAwC;CACzE,MAAM,aAAa,KAAK;AACxB,KAAI,CAAC,WACH,QAAO,EAAE,KAAK;CAGhB,IAAIA;CACJ,IAAIC;AACJ,MAAK,IAAI,IAAI,GAAG,IAAI,YAAY,KAAK;AACnC,QAAM;AACN,QAAM,KAAK;AACX,MAAI,QAAQ,IAAI,EAAE;GAChB,MAAM,SAAS,IAAI;AACnB,OAAI,QAAQ,IACV,OAAM;YACG,SAAS,IAAI,EAAE;IACxB,MAAM,OAAO,KAAK,MAAM,OAAO,SAAS,IAAI,CAAC;AAC7C,QAAI,OAAO,KAAK,KAAK,IACnB,OAAM,IAAI,MAAM,gBAAgB;AAGlC,UAAM;AACN,QAAI,MAAM,EACR,OAAM,IAAI,MAAM,gBAAgB;;AAIpC,OAAI,IACF,OAAM,IAAI;aAEH,YAAY,IAAI,CACzB,OAAM,OAAO,OAAO,MAAO,IAAY,OAAO;MACzC,OAAM,IAAI,MAAM,YAAY;;AAQrC,QANuB;EACrB;EACA;EACA;EACD;;AAYH,MAAa,oBACX,QAC6B,QAAQ,IAAI,IAAI,IAAI,OAAO,IAAI,QAAQ;AAEtE,MAAa,cAAc,QACzB,IAAI,IAAI,WAAW,IAAI;AAQzB,MAAa,qBACX,QAEA,OAAO,IAAI,QAAQ,YAAY,OAAO,IAAI,QAAQ"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"parse.d.cts","names":[],"sources":["../../src/pointer/parse.ts"],"sourcesContent":[],"mappings":";;;;;;AAiCA;AAcA;AAYA;AAaA;AAYa,iBAnDG,oBAAA,CAmD8C,OAAA,EAAA,MAAA,CAAA,EAAA,MAAA;AAU9D;AAWA;AAUA;;;;iBApEgB,sBAAA;;;;;iBAYA,gBAAA,mBAAmC;;;;;iBAanC,iBAAA,OAAwB;;;;cAY3B,iCAAkC;;;;iBAU/B,MAAA,OAAa,kBAAkB;;;;iBAW/B,YAAA;cAUH"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"parse.d.mts","names":[],"sources":["../../src/pointer/parse.ts"],"sourcesContent":[],"mappings":";;;;;;AAiCA;AAcA;AAYA;AAaA;AAYa,iBAnDG,oBAAA,CAmD8C,OAAA,EAAA,MAAA,CAAA,EAAA,MAAA;AAU9D;AAWA;AAUA;;;;iBApEgB,sBAAA;;;;;iBAYA,gBAAA,mBAAmC;;;;;iBAanC,iBAAA,OAAwB;;;;cAY3B,iCAAkC;;;;iBAU/B,MAAA,OAAa,kBAAkB;;;;iBAW/B,YAAA;cAUH"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"parse.mjs","names":["charCode: any"],"sources":["../../src/pointer/parse.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { isNumber } from \"@stryke/type-checks/is-number\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport type { JsonPointerPath } from \"@stryke/types/json\";\n\nconst TILDE_ONE = /~1/g;\nconst TILDE_ZERO = /~0/g;\nconst TILDE = /~/g;\nconst FORWARD_SLASH = /\\//g;\n\n/**\n * Escapes a JSON pointer path segment.\n *\n * @param segment - JSON pointer path segment.\n * @returns Escaped JSON pointer path segment.\n */\nexport function escapePointerSegment(segment: string): string {\n if (!segment.includes(\"/\") && !segment.includes(\"~\")) {\n return segment;\n }\n\n return segment.replace(TILDE, \"~0\").replace(FORWARD_SLASH, \"~1\");\n}\n\n/**\n * Unescapes a JSON pointer path segment.\n *\n * @param segment - JSON pointer path segment.\n * @returns Unescaped JSON pointer path segment.\n */\nexport function unescapePointerSegment(segment: string): string {\n if (!segment.includes(\"~\")) {\n return segment;\n }\n\n return segment.replace(TILDE_ONE, \"/\").replace(TILDE_ZERO, \"~\");\n}\n\n/**\n * Convert JSON pointer like \"/foo/bar\" to array like [\"\", \"foo\", \"bar\"], while\n * also un-escaping reserved characters.\n */\nexport function parseJsonPointer(pointer: string): JsonPointerPath {\n if (!pointer) return [];\n // TODO: Performance of this line can be improved: (1) don't use .split(); (2) don't use .map().\n return pointer\n .slice(1)\n .split(\"/\")\n .map(segment => unescapePointerSegment(segment));\n}\n\n/**\n * Escape and format a path array like [\"\", \"foo\", \"bar\"] to JSON pointer\n * like \"/foo/bar\".\n */\nexport function formatJsonPointer(path: JsonPointerPath): string {\n // eslint-disable-next-line ts/no-use-before-define\n if (isRoot(path)) {\n return \"\";\n }\n\n return `/${path.map(segment => escapePointerSegment(String(segment))).join(\"/\")}`;\n}\n\n/**\n * Returns true if JSON Pointer points to root value, false otherwise.\n */\nexport const isRoot = (path: string | number | JsonPointerPath): boolean =>\n isString(path)\n ? path === \"\"\n : isNumber(path)\n ? path === 0\n : Array.isArray(path) && path.length === 0;\n\n/**\n * Returns parent path, e.g. for ['foo', 'bar', 'baz'] returns ['foo', 'bar'].\n */\nexport function parent(path: JsonPointerPath): JsonPointerPath {\n if (path.length === 0) {\n throw new Error(\"NO_PARENT\");\n }\n\n return path.slice(0, -1);\n}\n\n/**\n * Check if path component can be a valid array index.\n */\nexport function isValidIndex(index: string | number): boolean {\n if (isNumber(index)) {\n return true;\n }\n\n const n = Number.parseInt(index, 10);\n\n return String(n) === index && n >= 0;\n}\n\nexport const isInteger = (str: string): boolean => {\n const len = str.length;\n let i = 0;\n let charCode: any;\n while (i < len) {\n charCode = str.codePointAt(i);\n if (charCode >= 48 && charCode <= 57) {\n i++;\n continue;\n }\n return false;\n }\n return true;\n};\n"],"mappings":";;;;AAsBA,MAAM,YAAY;AAClB,MAAM,aAAa;AACnB,MAAM,QAAQ;AACd,MAAM,gBAAgB;;;;;;;AAQtB,SAAgB,qBAAqB,SAAyB;AAC5D,KAAI,CAAC,QAAQ,SAAS,IAAI,IAAI,CAAC,QAAQ,SAAS,IAAI,CAClD,QAAO;AAGT,QAAO,QAAQ,QAAQ,OAAO,KAAK,CAAC,QAAQ,eAAe,KAAK;;;;;;;;AASlE,SAAgB,uBAAuB,SAAyB;AAC9D,KAAI,CAAC,QAAQ,SAAS,IAAI,CACxB,QAAO;AAGT,QAAO,QAAQ,QAAQ,WAAW,IAAI,CAAC,QAAQ,YAAY,IAAI;;;;;;AAOjE,SAAgB,iBAAiB,SAAkC;AACjE,KAAI,CAAC,QAAS,QAAO,EAAE;AAEvB,QAAO,QACJ,MAAM,EAAE,CACR,MAAM,IAAI,CACV,KAAI,YAAW,uBAAuB,QAAQ,CAAC;;;;;;AAOpD,SAAgB,kBAAkB,MAA+B;AAE/D,KAAI,OAAO,KAAK,CACd,QAAO;AAGT,QAAO,IAAI,KAAK,KAAI,YAAW,qBAAqB,OAAO,QAAQ,CAAC,CAAC,CAAC,KAAK,IAAI;;;;;AAMjF,MAAa,UAAU,SACrB,SAAS,KAAK,GACV,SAAS,KACT,SAAS,KAAK,GACZ,SAAS,IACT,MAAM,QAAQ,KAAK,IAAI,KAAK,WAAW;;;;AAK/C,SAAgB,OAAO,MAAwC;AAC7D,KAAI,KAAK,WAAW,EAClB,OAAM,IAAI,MAAM,YAAY;AAG9B,QAAO,KAAK,MAAM,GAAG,GAAG;;;;;AAM1B,SAAgB,aAAa,OAAiC;AAC5D,KAAI,SAAS,MAAM,CACjB,QAAO;CAGT,MAAM,IAAI,OAAO,SAAS,OAAO,GAAG;AAEpC,QAAO,OAAO,EAAE,KAAK,SAAS,KAAK;;AAGrC,MAAa,aAAa,QAAyB;CACjD,MAAM,MAAM,IAAI;CAChB,IAAI,IAAI;CACR,IAAIA;AACJ,QAAO,IAAI,KAAK;AACd,aAAW,IAAI,YAAY,EAAE;AAC7B,MAAI,YAAY,MAAM,YAAY,IAAI;AACpC;AACA;;AAEF,SAAO;;AAET,QAAO"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"storm-json.d.cts","names":[],"sources":["../src/storm-json.ts"],"sourcesContent":[],"mappings":";;;;;;;AA0CA;;;;AAuB2C,cAvB9B,SAAA,SAAkB,SAAA,CAuBY;EAAY,CAAA,OAAA;EAUS,WAAA,QAAA,CAAA,CAAA,EA9BhC,SA8BgC;EAarD;;;EAyBN,OAAA,WAAA,CAAA,QAAA,OAAA,CAAA,CAAA,OAAA,EAxDQ,gBAwDR,CAAA,EAvDA,KAuDA;EAiCmB;;;EAGQ,OAAA,SAAA,CAAA,MAAA,EApFW,SAoFX,CAAA,EApFuB,gBAoFvB;EACR;;;;;;gDA3EwC;;;;;;;;;6BAarD,cACI;;;;;;;;;+DAuBD,mBACT;;;;;;;;;mDAiCmB,YAAY,2CAGd,UAAU,iCACR,gBAAgB,4CACC;;;;;;yCAkBnB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"storm-json.d.mts","names":[],"sources":["../src/storm-json.ts"],"sourcesContent":[],"mappings":";;;;;;;AA0CA;;;;AAuB2C,cAvB9B,SAAA,SAAkB,SAAA,CAuBY;EAAY,CAAA,OAAA;EAUS,WAAA,QAAA,CAAA,CAAA,EA9BhC,SA8BgC;EAarD;;;EAyBN,OAAA,WAAA,CAAA,QAAA,OAAA,CAAA,CAAA,OAAA,EAxDQ,gBAwDR,CAAA,EAvDA,KAuDA;EAiCmB;;;EAGQ,OAAA,SAAA,CAAA,MAAA,EApFW,SAoFX,CAAA,EApFuB,gBAoFvB;EACR;;;;;;gDA3EwC;;;;;;;;;6BAarD,cACI;;;;;;;;;+DAuBD,mBACT;;;;;;;;;mDAiCmB,YAAY,2CAGd,UAAU,iCACR,gBAAgB,4CACC;;;;;;yCAkBnB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"storm-json.mjs","names":["#instance","parseValue","stringifyValue","errors: ParseError[]"],"sources":["../src/storm-json.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { ParseError } from \"jsonc-parser\";\nimport type {\n Class,\n JsonParseOptions,\n JsonParserResult,\n JsonSerializeOptions,\n JsonValue\n} from \"./types\";\n// import { Decimal } from \"decimal.js\";\nimport { isObject } from \"@stryke/type-checks/is-object\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport { parse } from \"jsonc-parser\";\nimport { Buffer } from \"node:buffer\";\nimport SuperJSON from \"superjson\";\nimport { parse as parseValue } from \"./utils/parse\";\nimport { formatParseError } from \"./utils/parse-error\";\nimport { stringify as stringifyValue } from \"./utils/stringify\";\n\n/**\n * A static JSON parser class used by Storm Software to serialize and deserialize JSON data\n *\n * @remarks\n * This class uses the [SuperJSON](https://github.com/blitz-js/superjson) library under the hood.\n */\nexport class StormJSON extends SuperJSON {\n static #instance: StormJSON;\n\n public static get instance(): StormJSON {\n if (!StormJSON.#instance) {\n StormJSON.#instance = new StormJSON();\n }\n\n return StormJSON.#instance;\n }\n\n /**\n * Deserialize the given value with superjson using the given metadata\n */\n public static override deserialize<TData = unknown>(\n payload: JsonParserResult\n ): TData {\n return StormJSON.instance.deserialize(payload);\n }\n\n /**\n * Serialize the given value with superjson\n */\n public static override serialize(object: JsonValue): JsonParserResult {\n return StormJSON.instance.serialize(object);\n }\n\n /**\n * Parse the given string value with superjson using the given metadata\n *\n * @param value - The string value to parse\n * @returns The parsed data\n */\n public static override parse<TData = unknown>(value: string): TData {\n return parseValue(value);\n }\n\n /**\n * Serializes the given data to a JSON string.\n * By default the JSON string is formatted with a 2 space indentation to be easy readable.\n *\n * @param value - Object which should be serialized to JSON\n * @param _options - JSON serialize options\n * @returns the formatted JSON representation of the object\n */\n public static override stringify<T>(\n value: T,\n _options?: JsonSerializeOptions\n ): string {\n const customTransformer =\n StormJSON.instance.customTransformerRegistry.findApplicable(value);\n\n let result = value;\n if (customTransformer && customTransformer.isApplicable(value)) {\n result = customTransformer.serialize(result) as T;\n }\n\n return stringifyValue(result);\n }\n\n /**\n * Parses the given JSON string and returns the object the JSON content represents.\n * By default javascript-style comments and trailing commas are allowed.\n *\n * @param strData - JSON content as string\n * @param options - JSON parse options\n * @returns Object the JSON content represents\n */\n public static parseJson<TData = unknown>(\n strData: string,\n options?: JsonParseOptions\n ): TData {\n try {\n if (options?.expectComments === false) {\n return StormJSON.instance.parse(strData);\n }\n } catch {\n // Do nothing\n }\n\n const errors: ParseError[] = [];\n const opts = {\n allowTrailingComma: true,\n ...options\n };\n const result = parse(strData, errors, opts) as TData;\n\n if (errors.length > 0 && errors[0]) {\n throw new Error(formatParseError(strData, errors[0]));\n }\n\n return result;\n }\n\n /**\n * Register a custom schema with superjson\n *\n * @param name - The name of the schema\n * @param serialize - The function to serialize the schema\n * @param deserialize - The function to deserialize the schema\n * @param isApplicable - The function to check if the schema is applicable\n */\n public static register<\n TData = any,\n TJsonObject extends JsonValue = JsonValue\n >(\n name: string,\n serialize: (data: TData) => TJsonObject,\n deserialize: (json: TJsonObject) => TData,\n isApplicable: (data: any) => data is TData\n ) {\n StormJSON.instance.registerCustom<TData, TJsonObject>(\n {\n isApplicable,\n serialize,\n deserialize\n },\n name\n );\n }\n\n /**\n * Register a class with superjson\n *\n * @param classConstructor - The class constructor to register\n */\n public static override registerClass(\n classConstructor: Class,\n options?: { identifier?: string; allowProps?: string[] } | string\n ) {\n StormJSON.instance.registerClass(classConstructor, {\n identifier: isString(options)\n ? options\n : options?.identifier || classConstructor.name,\n allowProps:\n options &&\n isObject(options) &&\n options?.allowProps &&\n Array.isArray(options.allowProps)\n ? options.allowProps\n : [\"__typename\"]\n });\n }\n\n private constructor() {\n super({ dedupe: true });\n }\n}\n\nStormJSON.instance.registerCustom<Buffer, string>(\n {\n isApplicable: (v): v is Buffer => Buffer.isBuffer(v),\n serialize: v => v.toString(\"base64\"),\n deserialize: v => Buffer.from(v, \"base64\")\n },\n \"Bytes\"\n);\n"],"mappings":";;;;;;;;;;;;;;;;AA0CA,IAAa,YAAb,MAAa,kBAAkB,UAAU;CACvC,QAAOA;CAEP,WAAkB,WAAsB;AACtC,MAAI,CAAC,WAAUA,SACb,YAAUA,WAAY,IAAI,WAAW;AAGvC,SAAO,WAAUA;;;;;CAMnB,OAAuB,YACrB,SACO;AACP,SAAO,UAAU,SAAS,YAAY,QAAQ;;;;;CAMhD,OAAuB,UAAU,QAAqC;AACpE,SAAO,UAAU,SAAS,UAAU,OAAO;;;;;;;;CAS7C,OAAuB,MAAuB,OAAsB;AAClE,SAAOC,QAAW,MAAM;;;;;;;;;;CAW1B,OAAuB,UACrB,OACA,UACQ;EACR,MAAM,oBACJ,UAAU,SAAS,0BAA0B,eAAe,MAAM;EAEpE,IAAI,SAAS;AACb,MAAI,qBAAqB,kBAAkB,aAAa,MAAM,CAC5D,UAAS,kBAAkB,UAAU,OAAO;AAG9C,SAAOC,UAAe,OAAO;;;;;;;;;;CAW/B,OAAc,UACZ,SACA,SACO;AACP,MAAI;AACF,OAAI,SAAS,mBAAmB,MAC9B,QAAO,UAAU,SAAS,MAAM,QAAQ;UAEpC;EAIR,MAAMC,SAAuB,EAAE;EAK/B,MAAM,SAAS,MAAM,SAAS,QAJjB;GACX,oBAAoB;GACpB,GAAG;GACJ,CAC0C;AAE3C,MAAI,OAAO,SAAS,KAAK,OAAO,GAC9B,OAAM,IAAI,MAAM,iBAAiB,SAAS,OAAO,GAAG,CAAC;AAGvD,SAAO;;;;;;;;;;CAWT,OAAc,SAIZ,MACA,WACA,aACA,cACA;AACA,YAAU,SAAS,eACjB;GACE;GACA;GACA;GACD,EACD,KACD;;;;;;;CAQH,OAAuB,cACrB,kBACA,SACA;AACA,YAAU,SAAS,cAAc,kBAAkB;GACjD,YAAY,SAAS,QAAQ,GACzB,UACA,SAAS,cAAc,iBAAiB;GAC5C,YACE,WACA,SAAS,QAAQ,IACjB,SAAS,cACT,MAAM,QAAQ,QAAQ,WAAW,GAC7B,QAAQ,aACR,CAAC,aAAa;GACrB,CAAC;;CAGJ,AAAQ,cAAc;AACpB,QAAM,EAAE,QAAQ,MAAM,CAAC;;;AAI3B,UAAU,SAAS,eACjB;CACE,eAAe,MAAmB,OAAO,SAAS,EAAE;CACpD,YAAW,MAAK,EAAE,SAAS,SAAS;CACpC,cAAa,MAAK,OAAO,KAAK,GAAG,SAAS;CAC3C,EACD,QACD"}
@@ -1,15 +0,0 @@
1
-
2
- //#region ../type-checks/src/get-object-tag.ts
3
- /**
4
- * Gets the `toStringTag` of `obj`.
5
- *
6
- * @param value - The obj to query.
7
- * @returns Returns the `toStringTag`.
8
- */
9
- const getObjectTag = (value) => {
10
- if (value == null) return value === void 0 ? "[object Undefined]" : "[object Null]";
11
- return Object.prototype.toString.call(value);
12
- };
13
-
14
- //#endregion
15
- exports.getObjectTag = getObjectTag;
@@ -1,15 +0,0 @@
1
- //#region ../type-checks/src/get-object-tag.ts
2
- /**
3
- * Gets the `toStringTag` of `obj`.
4
- *
5
- * @param value - The obj to query.
6
- * @returns Returns the `toStringTag`.
7
- */
8
- const getObjectTag = (value) => {
9
- if (value == null) return value === void 0 ? "[object Undefined]" : "[object Null]";
10
- return Object.prototype.toString.call(value);
11
- };
12
-
13
- //#endregion
14
- export { getObjectTag };
15
- //# sourceMappingURL=get-object-tag.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"get-object-tag.mjs","names":[],"sources":["../../../../type-checks/src/get-object-tag.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\n/**\n * Gets the `toStringTag` of `obj`.\n *\n * @param value - The obj to query.\n * @returns Returns the `toStringTag`.\n */\nexport const getObjectTag = (value: unknown): string => {\n if (value == null) {\n return value === undefined ? \"[object Undefined]\" : \"[object Null]\";\n }\n return Object.prototype.toString.call(value);\n};\n"],"mappings":";;;;;;;AAwBA,MAAa,gBAAgB,UAA2B;AACtD,KAAI,SAAS,KACX,QAAO,UAAU,SAAY,uBAAuB;AAEtD,QAAO,OAAO,UAAU,SAAS,KAAK,MAAM"}
@@ -1,20 +0,0 @@
1
- const require_is_undefined = require('./is-undefined.cjs');
2
- const require_is_null = require('./is-null.cjs');
3
-
4
- //#region ../type-checks/src/is-empty.ts
5
- /**
6
- * Check if the provided value's type is `null` or `undefined`
7
- *
8
- * @param value - The value to type check
9
- * @returns An indicator specifying if the value provided is of type `null` or `undefined`
10
- */
11
- const isEmpty = (value) => {
12
- try {
13
- return require_is_undefined.isUndefined(value) || require_is_null.isNull(value);
14
- } catch {
15
- return false;
16
- }
17
- };
18
-
19
- //#endregion
20
- exports.isEmpty = isEmpty;
@@ -1,21 +0,0 @@
1
- import { isUndefined } from "./is-undefined.mjs";
2
- import { isNull } from "./is-null.mjs";
3
-
4
- //#region ../type-checks/src/is-empty.ts
5
- /**
6
- * Check if the provided value's type is `null` or `undefined`
7
- *
8
- * @param value - The value to type check
9
- * @returns An indicator specifying if the value provided is of type `null` or `undefined`
10
- */
11
- const isEmpty = (value) => {
12
- try {
13
- return isUndefined(value) || isNull(value);
14
- } catch {
15
- return false;
16
- }
17
- };
18
-
19
- //#endregion
20
- export { isEmpty };
21
- //# sourceMappingURL=is-empty.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"is-empty.mjs","names":[],"sources":["../../../../type-checks/src/is-empty.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { isDate } from \"./is-date\";\nimport { isFunction } from \"./is-function\";\nimport { isNull } from \"./is-null\";\nimport { isNumber } from \"./is-number\";\nimport { isSymbol } from \"./is-symbol\";\nimport { isUndefined } from \"./is-undefined\";\n\n/**\n * Check if the provided value's type is `null` or `undefined`\n *\n * @param value - The value to type check\n * @returns An indicator specifying if the value provided is of type `null` or `undefined`\n */\nexport const isEmpty = (value: unknown) => {\n try {\n return isUndefined(value) || isNull(value);\n } catch {\n return false;\n }\n};\n\nexport const isEmptyAnything = (value: any) => {\n if (value === true || value === false) return true;\n if (value === null || value === undefined) return true;\n if (isNumber(value)) return value === 0;\n if (isDate(value)) return Number.isNaN(value.getTime());\n if (isFunction(value)) return false;\n if (isSymbol(value)) return false;\n const { length } = value;\n if (isNumber(length)) return length === 0;\n const { size } = value;\n if (isNumber(size)) return size === 0;\n const keys = Object.keys(value).length;\n\n return keys === 0;\n};\n"],"mappings":";;;;;;;;;;AA+BA,MAAa,WAAW,UAAmB;AACzC,KAAI;AACF,SAAO,YAAY,MAAM,IAAI,OAAO,MAAM;SACpC;AACN,SAAO"}
@@ -1,16 +0,0 @@
1
- const require_is_object = require('./is-object.cjs');
2
- const require_is_set = require('./is-set.cjs');
3
-
4
- //#region ../type-checks/src/is-non-null-object.ts
5
- /**
6
- * Check if the provided value's type is `Object` and is not `null` or `undefined`
7
- *
8
- * @param value - The value to type check
9
- * @returns An indicator specifying if the value provided is of type `Object` and is not `null` or `undefined`
10
- */
11
- const isNonNullObject = (value) => {
12
- return require_is_set.isSet(value) && require_is_object.isObject(value);
13
- };
14
-
15
- //#endregion
16
- exports.isNonNullObject = isNonNullObject;
@@ -1,17 +0,0 @@
1
- import { isObject } from "./is-object.mjs";
2
- import { isSet } from "./is-set.mjs";
3
-
4
- //#region ../type-checks/src/is-non-null-object.ts
5
- /**
6
- * Check if the provided value's type is `Object` and is not `null` or `undefined`
7
- *
8
- * @param value - The value to type check
9
- * @returns An indicator specifying if the value provided is of type `Object` and is not `null` or `undefined`
10
- */
11
- const isNonNullObject = (value) => {
12
- return isSet(value) && isObject(value);
13
- };
14
-
15
- //#endregion
16
- export { isNonNullObject };
17
- //# sourceMappingURL=is-non-null-object.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"is-non-null-object.mjs","names":[],"sources":["../../../../type-checks/src/is-non-null-object.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { isObject } from \"./is-object\";\nimport { isSet } from \"./is-set\";\n\n/**\n * Check if the provided value's type is `Object` and is not `null` or `undefined`\n *\n * @param value - The value to type check\n * @returns An indicator specifying if the value provided is of type `Object` and is not `null` or `undefined`\n */\nexport const isNonNullObject = (value: any): value is NonNullable<object> => {\n return isSet(value) && isObject(value);\n};\n"],"mappings":";;;;;;;;;;AA2BA,MAAa,mBAAmB,UAA6C;AAC3E,QAAO,MAAM,MAAM,IAAI,SAAS,MAAM"}
@@ -1,12 +0,0 @@
1
-
2
- //#region ../type-checks/src/is-null.ts
3
- const isNull = (value) => {
4
- try {
5
- return value === null;
6
- } catch {
7
- return false;
8
- }
9
- };
10
-
11
- //#endregion
12
- exports.isNull = isNull;
@@ -1,12 +0,0 @@
1
- //#region ../type-checks/src/is-null.ts
2
- const isNull = (value) => {
3
- try {
4
- return value === null;
5
- } catch {
6
- return false;
7
- }
8
- };
9
-
10
- //#endregion
11
- export { isNull };
12
- //# sourceMappingURL=is-null.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"is-null.mjs","names":[],"sources":["../../../../type-checks/src/is-null.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nexport const isNull = (value: unknown): value is null => {\n try {\n return value === null;\n } catch {\n return false;\n }\n};\n"],"mappings":";AAkBA,MAAa,UAAU,UAAkC;AACvD,KAAI;AACF,SAAO,UAAU;SACX;AACN,SAAO"}
@@ -1,18 +0,0 @@
1
-
2
- //#region ../type-checks/src/is-number.ts
3
- /**
4
- * Check if the provided value's type is `number`
5
- *
6
- * @param value - The value to type check
7
- * @returns An indicator specifying if the value provided is of type `number`
8
- */
9
- const isNumber = (value) => {
10
- try {
11
- return value instanceof Number || typeof value === "number" || Number(value) === value;
12
- } catch {
13
- return false;
14
- }
15
- };
16
-
17
- //#endregion
18
- exports.isNumber = isNumber;
@@ -1,18 +0,0 @@
1
- //#region ../type-checks/src/is-number.ts
2
- /**
3
- * Check if the provided value's type is `number`
4
- *
5
- * @param value - The value to type check
6
- * @returns An indicator specifying if the value provided is of type `number`
7
- */
8
- const isNumber = (value) => {
9
- try {
10
- return value instanceof Number || typeof value === "number" || Number(value) === value;
11
- } catch {
12
- return false;
13
- }
14
- };
15
-
16
- //#endregion
17
- export { isNumber };
18
- //# sourceMappingURL=is-number.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"is-number.mjs","names":[],"sources":["../../../../type-checks/src/is-number.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { AnyNumber } from \"@stryke/types/base\";\nimport { getObjectTag } from \"./get-object-tag\";\n\n/**\n * Check if the provided value's type is `number`\n *\n * @param value - The value to type check\n * @returns An indicator specifying if the value provided is of type `number`\n */\nexport const isNumber = (value: unknown): value is number => {\n try {\n return (\n value instanceof Number ||\n typeof value === \"number\" ||\n Number(value) === value\n );\n } catch {\n return false;\n }\n};\n\n/**\n * Check if the provided value's type is `AnyNumber`\n *\n * @param value - The value to type check\n * @returns An indicator specifying if the value provided is of type `AnyNumber`\n */\nexport function isAnyNumber(value?: any): value is AnyNumber {\n return isNumber(value) || getObjectTag(value) === \"[object Number]\";\n}\n"],"mappings":";;;;;;;AA2BA,MAAa,YAAY,UAAoC;AAC3D,KAAI;AACF,SACE,iBAAiB,UACjB,OAAO,UAAU,YACjB,OAAO,MAAM,KAAK;SAEd;AACN,SAAO"}