@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.
Files changed (190) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/_virtual/rolldown_runtime.cjs +1 -0
  3. package/dist/index.cjs +1 -1
  4. package/dist/index.d.cts +7 -7
  5. package/dist/index.d.mts +8 -8
  6. package/dist/index.mjs +1 -1
  7. package/dist/pointer/find-reference.cjs +1 -1
  8. package/dist/pointer/find-reference.d.cts +52 -2
  9. package/dist/pointer/find-reference.d.cts.map +1 -0
  10. package/dist/pointer/find-reference.d.mts +52 -2
  11. package/dist/pointer/find-reference.d.mts.map +1 -0
  12. package/dist/pointer/find-reference.mjs +2 -1
  13. package/dist/pointer/find-reference.mjs.map +1 -0
  14. package/dist/pointer/index.cjs +1 -1
  15. package/dist/pointer/index.d.cts +2 -2
  16. package/dist/pointer/index.d.mts +2 -2
  17. package/dist/pointer/index.mjs +1 -1
  18. package/dist/pointer/parse.cjs +1 -1
  19. package/dist/pointer/parse.d.cts +44 -2
  20. package/dist/pointer/parse.d.cts.map +1 -0
  21. package/dist/pointer/parse.d.mts +44 -2
  22. package/dist/pointer/parse.d.mts.map +1 -0
  23. package/dist/pointer/parse.mjs +2 -1
  24. package/dist/pointer/parse.mjs.map +1 -0
  25. package/dist/storm-json.cjs +1 -1
  26. package/dist/storm-json.d.cts +70 -2
  27. package/dist/storm-json.d.cts.map +1 -0
  28. package/dist/storm-json.d.mts +70 -3
  29. package/dist/storm-json.d.mts.map +1 -0
  30. package/dist/storm-json.mjs +2 -1
  31. package/dist/storm-json.mjs.map +1 -0
  32. package/dist/type-checks/src/get-object-tag.cjs +1 -0
  33. package/dist/type-checks/src/get-object-tag.mjs +2 -0
  34. package/dist/type-checks/src/get-object-tag.mjs.map +1 -0
  35. package/dist/type-checks/src/is-empty.cjs +1 -0
  36. package/dist/type-checks/src/is-empty.mjs +2 -0
  37. package/dist/type-checks/src/is-empty.mjs.map +1 -0
  38. package/dist/type-checks/src/is-non-null-object.cjs +1 -0
  39. package/dist/type-checks/src/is-non-null-object.mjs +2 -0
  40. package/dist/type-checks/src/is-non-null-object.mjs.map +1 -0
  41. package/dist/type-checks/src/is-null.cjs +1 -0
  42. package/dist/type-checks/src/is-null.mjs +2 -0
  43. package/dist/type-checks/src/is-null.mjs.map +1 -0
  44. package/dist/type-checks/src/is-number.cjs +1 -0
  45. package/dist/type-checks/src/is-number.mjs +2 -0
  46. package/dist/type-checks/src/is-number.mjs.map +1 -0
  47. package/dist/type-checks/src/is-object.cjs +1 -0
  48. package/dist/type-checks/src/is-object.mjs +2 -0
  49. package/dist/type-checks/src/is-object.mjs.map +1 -0
  50. package/dist/type-checks/src/is-plain-object.cjs +1 -0
  51. package/dist/type-checks/src/is-plain-object.mjs +2 -0
  52. package/dist/type-checks/src/is-plain-object.mjs.map +1 -0
  53. package/dist/type-checks/src/is-set-object.cjs +1 -0
  54. package/dist/type-checks/src/is-set-object.mjs +2 -0
  55. package/dist/type-checks/src/is-set-object.mjs.map +1 -0
  56. package/dist/type-checks/src/is-set.cjs +1 -0
  57. package/dist/type-checks/src/is-set.mjs +2 -0
  58. package/dist/type-checks/src/is-set.mjs.map +1 -0
  59. package/dist/{is-string-VB7nGKjX.mjs → type-checks/src/is-string.cjs} +1 -2
  60. package/dist/type-checks/src/is-string.mjs +2 -0
  61. package/dist/type-checks/src/is-string.mjs.map +1 -0
  62. package/dist/type-checks/src/is-undefined.cjs +1 -0
  63. package/dist/type-checks/src/is-undefined.mjs +2 -0
  64. package/dist/type-checks/src/is-undefined.mjs.map +1 -0
  65. package/dist/types/src/base.cjs +1 -0
  66. package/dist/types/src/base.mjs +2 -0
  67. package/dist/types/src/base.mjs.map +1 -0
  68. package/dist/types/src/json.d.cts +12 -0
  69. package/dist/types/src/json.d.cts.map +1 -0
  70. package/dist/types/src/json.d.mts +12 -0
  71. package/dist/types/src/json.d.mts.map +1 -0
  72. package/dist/types.d.cts +69 -2
  73. package/dist/types.d.cts.map +1 -0
  74. package/dist/types.d.mts +69 -2
  75. package/dist/types.d.mts.map +1 -0
  76. package/dist/utils/code-frames.cjs +3 -1
  77. package/dist/utils/code-frames.d.cts +17 -2
  78. package/dist/utils/code-frames.d.cts.map +1 -0
  79. package/dist/utils/code-frames.d.mts +17 -2
  80. package/dist/utils/code-frames.d.mts.map +1 -0
  81. package/dist/utils/code-frames.mjs +4 -1
  82. package/dist/utils/code-frames.mjs.map +1 -0
  83. package/dist/utils/index.cjs +1 -1
  84. package/dist/utils/index.d.cts +5 -5
  85. package/dist/utils/index.d.mts +5 -6
  86. package/dist/utils/index.mjs +1 -1
  87. package/dist/utils/parse-error.cjs +1 -1
  88. package/dist/utils/parse-error.d.cts +15 -2
  89. package/dist/utils/parse-error.d.cts.map +1 -0
  90. package/dist/utils/parse-error.d.mts +15 -2
  91. package/dist/utils/parse-error.d.mts.map +1 -0
  92. package/dist/utils/parse-error.mjs +2 -1
  93. package/dist/utils/parse-error.mjs.map +1 -0
  94. package/dist/utils/parse.cjs +1 -1
  95. package/dist/utils/parse.d.cts +9 -2
  96. package/dist/utils/parse.d.cts.map +1 -0
  97. package/dist/utils/parse.d.mts +9 -2
  98. package/dist/utils/parse.d.mts.map +1 -0
  99. package/dist/utils/parse.mjs +2 -1
  100. package/dist/utils/parse.mjs.map +1 -0
  101. package/dist/utils/stringify.cjs +1 -1
  102. package/dist/utils/stringify.d.cts +13 -2
  103. package/dist/utils/stringify.d.cts.map +1 -0
  104. package/dist/utils/stringify.d.mts +13 -2
  105. package/dist/utils/stringify.d.mts.map +1 -0
  106. package/dist/utils/stringify.mjs +2 -1
  107. package/dist/utils/stringify.mjs.map +1 -0
  108. package/dist/utils/strip-comments.cjs +4 -1
  109. package/dist/utils/strip-comments.d.cts +11 -2
  110. package/dist/utils/strip-comments.d.cts.map +1 -0
  111. package/dist/utils/strip-comments.d.mts +11 -2
  112. package/dist/utils/strip-comments.d.mts.map +1 -0
  113. package/dist/utils/strip-comments.mjs +5 -1
  114. package/dist/utils/strip-comments.mjs.map +1 -0
  115. package/package.json +3 -3
  116. package/dist/code-frames-BQI7PKd_.mjs +0 -4
  117. package/dist/code-frames-BQI7PKd_.mjs.map +0 -1
  118. package/dist/code-frames-CXX37tnR.d.mts +0 -17
  119. package/dist/code-frames-CXX37tnR.d.mts.map +0 -1
  120. package/dist/code-frames-DEWi5iIn.cjs +0 -3
  121. package/dist/code-frames-DViwqU8S.d.cts +0 -17
  122. package/dist/code-frames-DViwqU8S.d.cts.map +0 -1
  123. package/dist/find-reference-AvNORSzC.d.mts +0 -52
  124. package/dist/find-reference-AvNORSzC.d.mts.map +0 -1
  125. package/dist/find-reference-BUIYIOS4.mjs +0 -2
  126. package/dist/find-reference-BUIYIOS4.mjs.map +0 -1
  127. package/dist/find-reference-ChoPoDcB.d.cts +0 -52
  128. package/dist/find-reference-ChoPoDcB.d.cts.map +0 -1
  129. package/dist/find-reference-DQJK1LbJ.cjs +0 -1
  130. package/dist/index-CMuRFTR3.d.mts +0 -1
  131. package/dist/index-uTS5iDq_.d.cts +0 -1
  132. package/dist/is-number-CebQk_B0.mjs +0 -2
  133. package/dist/is-number-CebQk_B0.mjs.map +0 -1
  134. package/dist/is-number-wfNPC3Mj.cjs +0 -1
  135. package/dist/is-object-CGB7EeiA.cjs +0 -1
  136. package/dist/is-object-DDPbtSWR.mjs +0 -2
  137. package/dist/is-object-DDPbtSWR.mjs.map +0 -1
  138. package/dist/is-string-D5yKZC0U.cjs +0 -1
  139. package/dist/is-string-VB7nGKjX.mjs.map +0 -1
  140. package/dist/is-undefined-D6sfLkFq.mjs +0 -2
  141. package/dist/is-undefined-D6sfLkFq.mjs.map +0 -1
  142. package/dist/is-undefined-Pevixi0g.cjs +0 -1
  143. package/dist/parse-BYhuR8fo.mjs +0 -2
  144. package/dist/parse-BYhuR8fo.mjs.map +0 -1
  145. package/dist/parse-BpylFCf0.mjs +0 -2
  146. package/dist/parse-BpylFCf0.mjs.map +0 -1
  147. package/dist/parse-BwhwGAkA.cjs +0 -1
  148. package/dist/parse-D-7TqXVh.d.mts +0 -51
  149. package/dist/parse-D-7TqXVh.d.mts.map +0 -1
  150. package/dist/parse-DU-kIQN6.d.cts +0 -51
  151. package/dist/parse-DU-kIQN6.d.cts.map +0 -1
  152. package/dist/parse-DmriuGKI.cjs +0 -1
  153. package/dist/parse-error-0BAtatMf.cjs +0 -1
  154. package/dist/parse-error-CJTV0jdn.d.mts +0 -15
  155. package/dist/parse-error-CJTV0jdn.d.mts.map +0 -1
  156. package/dist/parse-error-DLuqEXmf.d.cts +0 -15
  157. package/dist/parse-error-DLuqEXmf.d.cts.map +0 -1
  158. package/dist/parse-error-DrJJkemH.mjs +0 -2
  159. package/dist/parse-error-DrJJkemH.mjs.map +0 -1
  160. package/dist/parse-fX7NFKdt.d.cts +0 -9
  161. package/dist/parse-fX7NFKdt.d.cts.map +0 -1
  162. package/dist/parse-xFkFesIF.d.mts +0 -9
  163. package/dist/parse-xFkFesIF.d.mts.map +0 -1
  164. package/dist/storm-json-BsdLpzM_.mjs +0 -2
  165. package/dist/storm-json-BsdLpzM_.mjs.map +0 -1
  166. package/dist/storm-json-CfqJ0KzG.d.mts +0 -70
  167. package/dist/storm-json-CfqJ0KzG.d.mts.map +0 -1
  168. package/dist/storm-json-DBxiMujR.cjs +0 -1
  169. package/dist/storm-json-Q1bOIv3-.d.cts +0 -70
  170. package/dist/storm-json-Q1bOIv3-.d.cts.map +0 -1
  171. package/dist/stringify-BpBMOhle.d.cts +0 -13
  172. package/dist/stringify-BpBMOhle.d.cts.map +0 -1
  173. package/dist/stringify-DjBDt8SC.mjs +0 -2
  174. package/dist/stringify-DjBDt8SC.mjs.map +0 -1
  175. package/dist/stringify-Dp0lF-wN.cjs +0 -1
  176. package/dist/stringify-ln223ZC9.d.mts +0 -13
  177. package/dist/stringify-ln223ZC9.d.mts.map +0 -1
  178. package/dist/strip-comments-BhdK_E8s.cjs +0 -4
  179. package/dist/strip-comments-CKLSXchM.d.cts +0 -11
  180. package/dist/strip-comments-CKLSXchM.d.cts.map +0 -1
  181. package/dist/strip-comments-DdsCzji6.d.mts +0 -11
  182. package/dist/strip-comments-DdsCzji6.d.mts.map +0 -1
  183. package/dist/strip-comments-LcqiBhvo.mjs +0 -5
  184. package/dist/strip-comments-LcqiBhvo.mjs.map +0 -1
  185. package/dist/types-CEiKQHlk.d.cts +0 -69
  186. package/dist/types-CEiKQHlk.d.cts.map +0 -1
  187. package/dist/types-CQHq94S4.d.mts +0 -69
  188. package/dist/types-CQHq94S4.d.mts.map +0 -1
  189. package/dist/utils-BkLHzBxb.mjs +0 -1
  190. package/dist/utils-DFU9Wltn.cjs +0 -0
package/CHANGELOG.md CHANGED
@@ -2,6 +2,20 @@
2
2
 
3
3
  # Changelog for Stryke - JSON
4
4
 
5
+ ## [0.9.27](https://github.com/storm-software/stryke/releases/tag/json%400.9.27) (12/08/2025)
6
+
7
+ ### Updated Dependencies
8
+
9
+ - Updated **type-checks** to **v0.5.9**
10
+ - Updated **types** to **v0.10.23**
11
+
12
+ ## [0.9.26](https://github.com/storm-software/stryke/releases/tag/json%400.9.26) (12/08/2025)
13
+
14
+ ### Updated Dependencies
15
+
16
+ - Updated **type-checks** to **v0.5.8**
17
+ - Updated **types** to **v0.10.22**
18
+
5
19
  ## [0.9.25](https://github.com/storm-software/stryke/releases/tag/json%400.9.25) (12/08/2025)
6
20
 
7
21
  ### Updated Dependencies
@@ -0,0 +1 @@
1
+ var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));exports.__toESM=s;
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- const e=require(`./storm-json-DBxiMujR.cjs`),t=require(`./strip-comments-BhdK_E8s.cjs`),n=require(`./parse-DmriuGKI.cjs`),r=require(`./code-frames-DEWi5iIn.cjs`),i=require(`./parse-error-0BAtatMf.cjs`),a=require(`./stringify-Dp0lF-wN.cjs`);require(`./types.cjs`),require(`./utils-DFU9Wltn.cjs`),exports.StormJSON=e.t,exports.codeFrameColumns=r.t,exports.formatParseError=i.t,exports.invalidKeyChars=a.t,exports.parse=n.t,exports.safeParse=n.n,exports.stringify=a.n,exports.stripComments=t.t;
1
+ const e=require(`./utils/strip-comments.cjs`),t=require(`./utils/parse.cjs`),n=require(`./utils/code-frames.cjs`),r=require(`./utils/parse-error.cjs`),i=require(`./utils/stringify.cjs`),a=require(`./storm-json.cjs`);require(`./utils/index.cjs`),exports.StormJSON=a.StormJSON,exports.codeFrameColumns=n.codeFrameColumns,exports.formatParseError=r.formatParseError,exports.invalidKeyChars=i.invalidKeyChars,exports.parse=t.parse,exports.safeParse=t.safeParse,exports.stringify=i.stringify,exports.stripComments=e.stripComments;
package/dist/index.d.cts CHANGED
@@ -1,8 +1,8 @@
1
- import { C as TypedArrayAnnotation, S as TypeAnnotation, _ as PrimitiveTypeAnnotation, a as CustomTypeAnnotation, b as SymbolTypeAnnotation, c as JsonObject, d as JsonParserResult, f as JsonSerializeOptions, g as PrimitiveJsonValue, h as LeafTypeAnnotation, i as CompositeTypeAnnotation, l as JsonParseOptions, m as Leaf, n as ClassInstance, o as InnerNode, p as JsonValue, r as ClassTypeAnnotation, s as JsonArray, t as Class, u as JsonParserInterface, v as SerializableJsonValue, x as Tree, y as SimpleTypeAnnotation } from "./types-CEiKQHlk.cjs";
2
- import { t as StormJSON } from "./storm-json-Q1bOIv3-.cjs";
3
- import { t as codeFrameColumns } from "./code-frames-DViwqU8S.cjs";
4
- import { n as parse, r as safeParse, t as Options } from "./parse-fX7NFKdt.cjs";
5
- import { t as formatParseError } from "./parse-error-DLuqEXmf.cjs";
6
- import { n as stringify, t as invalidKeyChars } from "./stringify-BpBMOhle.cjs";
7
- import { t as stripComments } from "./strip-comments-CKLSXchM.cjs";
1
+ import { Class, ClassInstance, ClassTypeAnnotation, CompositeTypeAnnotation, CustomTypeAnnotation, InnerNode, JsonArray, JsonObject, JsonParseOptions, JsonParserInterface, JsonParserResult, JsonSerializeOptions, JsonValue, Leaf, LeafTypeAnnotation, PrimitiveJsonValue, PrimitiveTypeAnnotation, SerializableJsonValue, SimpleTypeAnnotation, SymbolTypeAnnotation, Tree, TypeAnnotation, TypedArrayAnnotation } from "./types.cjs";
2
+ import { StormJSON } from "./storm-json.cjs";
3
+ import { codeFrameColumns } from "./utils/code-frames.cjs";
4
+ import { Options, parse, safeParse } from "./utils/parse.cjs";
5
+ import { formatParseError } from "./utils/parse-error.cjs";
6
+ import { invalidKeyChars, stringify } from "./utils/stringify.cjs";
7
+ import { stripComments } from "./utils/strip-comments.cjs";
8
8
  export { Class, ClassInstance, ClassTypeAnnotation, CompositeTypeAnnotation, CustomTypeAnnotation, InnerNode, JsonArray, JsonObject, JsonParseOptions, JsonParserInterface, JsonParserResult, JsonSerializeOptions, JsonValue, Leaf, LeafTypeAnnotation, Options, PrimitiveJsonValue, PrimitiveTypeAnnotation, SerializableJsonValue, SimpleTypeAnnotation, StormJSON, SymbolTypeAnnotation, Tree, TypeAnnotation, TypedArrayAnnotation, codeFrameColumns, formatParseError, invalidKeyChars, parse, safeParse, stringify, stripComments };
package/dist/index.d.mts CHANGED
@@ -1,9 +1,9 @@
1
- import { C as TypedArrayAnnotation, S as TypeAnnotation, _ as PrimitiveTypeAnnotation, a as CustomTypeAnnotation, b as SymbolTypeAnnotation, c as JsonObject, d as JsonParserResult, f as JsonSerializeOptions, g as PrimitiveJsonValue, h as LeafTypeAnnotation, i as CompositeTypeAnnotation, l as JsonParseOptions, m as Leaf, n as ClassInstance, o as InnerNode, p as JsonValue, r as ClassTypeAnnotation, s as JsonArray, t as Class, u as JsonParserInterface, v as SerializableJsonValue, x as Tree, y as SimpleTypeAnnotation } from "./types-CQHq94S4.mjs";
2
- import { t as StormJSON } from "./storm-json-CfqJ0KzG.mjs";
3
- import { t as codeFrameColumns } from "./code-frames-CXX37tnR.mjs";
4
- import { n as parse, r as safeParse, t as Options } from "./parse-xFkFesIF.mjs";
5
- import { t as formatParseError } from "./parse-error-CJTV0jdn.mjs";
6
- import { n as stringify, t as invalidKeyChars } from "./stringify-ln223ZC9.mjs";
7
- import { t as stripComments } from "./strip-comments-DdsCzji6.mjs";
8
- import "./index-CMuRFTR3.mjs";
1
+ import { Class, ClassInstance, ClassTypeAnnotation, CompositeTypeAnnotation, CustomTypeAnnotation, InnerNode, JsonArray, JsonObject, JsonParseOptions, JsonParserInterface, JsonParserResult, JsonSerializeOptions, JsonValue, Leaf, LeafTypeAnnotation, PrimitiveJsonValue, PrimitiveTypeAnnotation, SerializableJsonValue, SimpleTypeAnnotation, SymbolTypeAnnotation, Tree, TypeAnnotation, TypedArrayAnnotation } from "./types.mjs";
2
+ import { StormJSON } from "./storm-json.mjs";
3
+ import { codeFrameColumns } from "./utils/code-frames.mjs";
4
+ import { Options, parse, safeParse } from "./utils/parse.mjs";
5
+ import { formatParseError } from "./utils/parse-error.mjs";
6
+ import { invalidKeyChars, stringify } from "./utils/stringify.mjs";
7
+ import { stripComments } from "./utils/strip-comments.mjs";
8
+ import "./utils/index.mjs";
9
9
  export { Class, ClassInstance, ClassTypeAnnotation, CompositeTypeAnnotation, CustomTypeAnnotation, InnerNode, JsonArray, JsonObject, JsonParseOptions, JsonParserInterface, JsonParserResult, JsonSerializeOptions, JsonValue, Leaf, LeafTypeAnnotation, Options, PrimitiveJsonValue, PrimitiveTypeAnnotation, SerializableJsonValue, SimpleTypeAnnotation, StormJSON, SymbolTypeAnnotation, Tree, TypeAnnotation, TypedArrayAnnotation, codeFrameColumns, formatParseError, invalidKeyChars, parse, safeParse, stringify, stripComments };
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{t as e}from"./strip-comments-LcqiBhvo.mjs";import{n as t,t as n}from"./parse-BpylFCf0.mjs";import{t as r}from"./code-frames-BQI7PKd_.mjs";import{t as i}from"./parse-error-DrJJkemH.mjs";import{n as a,t as o}from"./stringify-DjBDt8SC.mjs";import{t as s}from"./storm-json-BsdLpzM_.mjs";import"./types.mjs";import"./utils-BkLHzBxb.mjs";export{s as StormJSON,r as codeFrameColumns,i as formatParseError,o as invalidKeyChars,n as parse,t as safeParse,a as stringify,e as stripComments};
1
+ import{stripComments as e}from"./utils/strip-comments.mjs";import{parse as t,safeParse as n}from"./utils/parse.mjs";import{codeFrameColumns as r}from"./utils/code-frames.mjs";import{formatParseError as i}from"./utils/parse-error.mjs";import{invalidKeyChars as a,stringify as o}from"./utils/stringify.mjs";import{StormJSON as s}from"./storm-json.mjs";import"./utils/index.mjs";export{s as StormJSON,r as codeFrameColumns,i as formatParseError,a as invalidKeyChars,t as parse,n as safeParse,o as stringify,e as stripComments};
@@ -1 +1 @@
1
- const e=require(`../find-reference-DQJK1LbJ.cjs`);exports.find=e.t,exports.isArrayEnd=e.n,exports.isArrayReference=e.r,exports.isObjectReference=e.i;
1
+ const e=require(`../type-checks/src/is-string.cjs`),t=require(`../type-checks/src/is-set-object.cjs`),{isArray:n}=Array,r=(r,i)=>{let a=i.length;if(!a)return{val:r};let o,s;for(let c=0;c<a;c++)if(o=r,s=i[c],n(o)){let t=o.length;if(s===`-`)s=t;else if(e.isString(s)){let e=Math.trunc(Number.parseInt(s));if(String(e)!==s||(s=e,s<0))throw Error(`INVALID_INDEX`)}s&&(r=o[s])}else if(t.isSetObject(o))r=s&&s in o?o[s]:void 0;else throw Error(`NOT_FOUND`);return{val:r,obj:o,key:s}},i=e=>n(e.obj)&&typeof e.key==`number`,a=e=>e.obj.length===e.key,o=e=>typeof e.obj==`object`&&typeof e.key==`string`;exports.find=r,exports.isArrayEnd=a,exports.isArrayReference=i,exports.isObjectReference=o;
@@ -1,2 +1,52 @@
1
- import { a as isArrayEnd, i as find, n as ObjectReference, o as isArrayReference, r as Reference, s as isObjectReference, t as ArrayReference } from "../find-reference-ChoPoDcB.cjs";
2
- export { ArrayReference, ObjectReference, Reference, find, isArrayEnd, isArrayReference, isObjectReference };
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 { ArrayReference, ObjectReference, Reference, find, isArrayEnd, isArrayReference, isObjectReference };
52
+ //# sourceMappingURL=find-reference.d.cts.map
@@ -0,0 +1 @@
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,2 +1,52 @@
1
- import { a as isArrayEnd, i as find, n as ObjectReference, o as isArrayReference, r as Reference, s as isObjectReference, t as ArrayReference } from "../find-reference-AvNORSzC.mjs";
2
- export { ArrayReference, ObjectReference, Reference, find, isArrayEnd, isArrayReference, isObjectReference };
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 { ArrayReference, ObjectReference, Reference, find, isArrayEnd, isArrayReference, isObjectReference };
52
+ //# sourceMappingURL=find-reference.d.mts.map
@@ -0,0 +1 @@
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 +1,2 @@
1
- import{i as e,n as t,r as n,t as r}from"../find-reference-BUIYIOS4.mjs";export{r as find,t as isArrayEnd,n as isArrayReference,e as isObjectReference};
1
+ import{isString as e}from"../type-checks/src/is-string.mjs";import{isSetObject as t}from"../type-checks/src/is-set-object.mjs";const{isArray:n}=Array,r=(r,i)=>{let a=i.length;if(!a)return{val:r};let o,s;for(let c=0;c<a;c++)if(o=r,s=i[c],n(o)){let t=o.length;if(s===`-`)s=t;else if(e(s)){let e=Math.trunc(Number.parseInt(s));if(String(e)!==s||(s=e,s<0))throw Error(`INVALID_INDEX`)}s&&(r=o[s])}else if(t(o))r=s&&s in o?o[s]:void 0;else throw Error(`NOT_FOUND`);return{val:r,obj:o,key:s}},i=e=>n(e.obj)&&typeof e.key==`number`,a=e=>e.obj.length===e.key,o=e=>typeof e.obj==`object`&&typeof e.key==`string`;export{r as find,a as isArrayEnd,i as isArrayReference,o as isObjectReference};
2
+ //# sourceMappingURL=find-reference.mjs.map
@@ -0,0 +1 @@
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":"+HA8BA,KAAM,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 +1 @@
1
- const e=require(`../find-reference-DQJK1LbJ.cjs`),t=require(`../parse-BwhwGAkA.cjs`);exports.escapePointerSegment=t.t,exports.find=e.t,exports.formatJsonPointer=t.n,exports.isArrayEnd=e.n,exports.isArrayReference=e.r,exports.isInteger=t.r,exports.isObjectReference=e.i,exports.isRoot=t.i,exports.isValidIndex=t.a,exports.parent=t.o,exports.parseJsonPointer=t.s,exports.unescapePointerSegment=t.c;
1
+ const e=require(`./find-reference.cjs`),t=require(`./parse.cjs`);exports.escapePointerSegment=t.escapePointerSegment,exports.find=e.find,exports.formatJsonPointer=t.formatJsonPointer,exports.isArrayEnd=e.isArrayEnd,exports.isArrayReference=e.isArrayReference,exports.isInteger=t.isInteger,exports.isObjectReference=e.isObjectReference,exports.isRoot=t.isRoot,exports.isValidIndex=t.isValidIndex,exports.parent=t.parent,exports.parseJsonPointer=t.parseJsonPointer,exports.unescapePointerSegment=t.unescapePointerSegment;
@@ -1,3 +1,3 @@
1
- import { a as isArrayEnd, i as find, n as ObjectReference, o as isArrayReference, r as Reference, s as isObjectReference, t as ArrayReference } from "../find-reference-ChoPoDcB.cjs";
2
- import { a as isValidIndex, c as unescapePointerSegment, i as isRoot, n as formatJsonPointer, o as parent, r as isInteger, s as parseJsonPointer, t as escapePointerSegment } from "../parse-DU-kIQN6.cjs";
1
+ import { ArrayReference, ObjectReference, Reference, find, isArrayEnd, isArrayReference, isObjectReference } from "./find-reference.cjs";
2
+ import { escapePointerSegment, formatJsonPointer, isInteger, isRoot, isValidIndex, parent, parseJsonPointer, unescapePointerSegment } from "./parse.cjs";
3
3
  export { ArrayReference, ObjectReference, Reference, escapePointerSegment, find, formatJsonPointer, isArrayEnd, isArrayReference, isInteger, isObjectReference, isRoot, isValidIndex, parent, parseJsonPointer, unescapePointerSegment };
@@ -1,3 +1,3 @@
1
- import { a as isArrayEnd, i as find, n as ObjectReference, o as isArrayReference, r as Reference, s as isObjectReference, t as ArrayReference } from "../find-reference-AvNORSzC.mjs";
2
- import { a as isValidIndex, c as unescapePointerSegment, i as isRoot, n as formatJsonPointer, o as parent, r as isInteger, s as parseJsonPointer, t as escapePointerSegment } from "../parse-D-7TqXVh.mjs";
1
+ import { ArrayReference, ObjectReference, Reference, find, isArrayEnd, isArrayReference, isObjectReference } from "./find-reference.mjs";
2
+ import { escapePointerSegment, formatJsonPointer, isInteger, isRoot, isValidIndex, parent, parseJsonPointer, unescapePointerSegment } from "./parse.mjs";
3
3
  export { ArrayReference, ObjectReference, Reference, escapePointerSegment, find, formatJsonPointer, isArrayEnd, isArrayReference, isInteger, isObjectReference, isRoot, isValidIndex, parent, parseJsonPointer, unescapePointerSegment };
@@ -1 +1 @@
1
- import{i as e,n as t,r as n,t as r}from"../find-reference-BUIYIOS4.mjs";import{a as i,c as a,i as o,n as s,o as c,r as l,s as u,t as d}from"../parse-BYhuR8fo.mjs";export{d as escapePointerSegment,r as find,s as formatJsonPointer,t as isArrayEnd,n as isArrayReference,l as isInteger,e as isObjectReference,o as isRoot,i as isValidIndex,c as parent,u as parseJsonPointer,a as unescapePointerSegment};
1
+ import{find as e,isArrayEnd as t,isArrayReference as n,isObjectReference as r}from"./find-reference.mjs";import{escapePointerSegment as i,formatJsonPointer as a,isInteger as o,isRoot as s,isValidIndex as c,parent as l,parseJsonPointer as u,unescapePointerSegment as d}from"./parse.mjs";export{i as escapePointerSegment,e as find,a as formatJsonPointer,t as isArrayEnd,n as isArrayReference,o as isInteger,r as isObjectReference,s as isRoot,c as isValidIndex,l as parent,u as parseJsonPointer,d as unescapePointerSegment};
@@ -1 +1 @@
1
- const e=require(`../parse-BwhwGAkA.cjs`);exports.escapePointerSegment=e.t,exports.formatJsonPointer=e.n,exports.isInteger=e.r,exports.isRoot=e.i,exports.isValidIndex=e.a,exports.parent=e.o,exports.parseJsonPointer=e.s,exports.unescapePointerSegment=e.c;
1
+ const e=require(`../type-checks/src/is-string.cjs`),t=require(`../type-checks/src/is-number.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=>e.isString(n)?n===``:t.isNumber(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(e){if(t.isNumber(e))return!0;let n=Number.parseInt(e,10);return String(n)===e&&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};exports.escapePointerSegment=o,exports.formatJsonPointer=l,exports.isInteger=p,exports.isRoot=u,exports.isValidIndex=f,exports.parent=d,exports.parseJsonPointer=c,exports.unescapePointerSegment=s;
@@ -1,2 +1,44 @@
1
- import { a as isValidIndex, c as unescapePointerSegment, i as isRoot, n as formatJsonPointer, o as parent, r as isInteger, s as parseJsonPointer, t as escapePointerSegment } from "../parse-DU-kIQN6.cjs";
2
- export { escapePointerSegment, formatJsonPointer, isInteger, isRoot, isValidIndex, parent, parseJsonPointer, unescapePointerSegment };
1
+ import { JsonPointerPath } from "../types/src/json.cjs";
2
+
3
+ //#region src/pointer/parse.d.ts
4
+
5
+ /**
6
+ * Escapes a JSON pointer path segment.
7
+ *
8
+ * @param segment - JSON pointer path segment.
9
+ * @returns Escaped JSON pointer path segment.
10
+ */
11
+ declare function escapePointerSegment(segment: string): string;
12
+ /**
13
+ * Unescapes a JSON pointer path segment.
14
+ *
15
+ * @param segment - JSON pointer path segment.
16
+ * @returns Unescaped JSON pointer path segment.
17
+ */
18
+ declare function unescapePointerSegment(segment: string): string;
19
+ /**
20
+ * Convert JSON pointer like "/foo/bar" to array like ["", "foo", "bar"], while
21
+ * also un-escaping reserved characters.
22
+ */
23
+ declare function parseJsonPointer(pointer: string): JsonPointerPath;
24
+ /**
25
+ * Escape and format a path array like ["", "foo", "bar"] to JSON pointer
26
+ * like "/foo/bar".
27
+ */
28
+ declare function formatJsonPointer(path: JsonPointerPath): string;
29
+ /**
30
+ * Returns true if JSON Pointer points to root value, false otherwise.
31
+ */
32
+ declare const isRoot: (path: string | number | JsonPointerPath) => boolean;
33
+ /**
34
+ * Returns parent path, e.g. for ['foo', 'bar', 'baz'] returns ['foo', 'bar'].
35
+ */
36
+ declare function parent(path: JsonPointerPath): JsonPointerPath;
37
+ /**
38
+ * Check if path component can be a valid array index.
39
+ */
40
+ declare function isValidIndex(index: string | number): boolean;
41
+ declare const isInteger: (str: string) => boolean;
42
+ //#endregion
43
+ export { escapePointerSegment, formatJsonPointer, isInteger, isRoot, isValidIndex, parent, parseJsonPointer, unescapePointerSegment };
44
+ //# sourceMappingURL=parse.d.cts.map
@@ -0,0 +1 @@
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,2 +1,44 @@
1
- import { a as isValidIndex, c as unescapePointerSegment, i as isRoot, n as formatJsonPointer, o as parent, r as isInteger, s as parseJsonPointer, t as escapePointerSegment } from "../parse-D-7TqXVh.mjs";
2
- export { escapePointerSegment, formatJsonPointer, isInteger, isRoot, isValidIndex, parent, parseJsonPointer, unescapePointerSegment };
1
+ import { JsonPointerPath } from "../types/src/json.mjs";
2
+
3
+ //#region src/pointer/parse.d.ts
4
+
5
+ /**
6
+ * Escapes a JSON pointer path segment.
7
+ *
8
+ * @param segment - JSON pointer path segment.
9
+ * @returns Escaped JSON pointer path segment.
10
+ */
11
+ declare function escapePointerSegment(segment: string): string;
12
+ /**
13
+ * Unescapes a JSON pointer path segment.
14
+ *
15
+ * @param segment - JSON pointer path segment.
16
+ * @returns Unescaped JSON pointer path segment.
17
+ */
18
+ declare function unescapePointerSegment(segment: string): string;
19
+ /**
20
+ * Convert JSON pointer like "/foo/bar" to array like ["", "foo", "bar"], while
21
+ * also un-escaping reserved characters.
22
+ */
23
+ declare function parseJsonPointer(pointer: string): JsonPointerPath;
24
+ /**
25
+ * Escape and format a path array like ["", "foo", "bar"] to JSON pointer
26
+ * like "/foo/bar".
27
+ */
28
+ declare function formatJsonPointer(path: JsonPointerPath): string;
29
+ /**
30
+ * Returns true if JSON Pointer points to root value, false otherwise.
31
+ */
32
+ declare const isRoot: (path: string | number | JsonPointerPath) => boolean;
33
+ /**
34
+ * Returns parent path, e.g. for ['foo', 'bar', 'baz'] returns ['foo', 'bar'].
35
+ */
36
+ declare function parent(path: JsonPointerPath): JsonPointerPath;
37
+ /**
38
+ * Check if path component can be a valid array index.
39
+ */
40
+ declare function isValidIndex(index: string | number): boolean;
41
+ declare const isInteger: (str: string) => boolean;
42
+ //#endregion
43
+ export { escapePointerSegment, formatJsonPointer, isInteger, isRoot, isValidIndex, parent, parseJsonPointer, unescapePointerSegment };
44
+ //# sourceMappingURL=parse.d.mts.map
@@ -0,0 +1 @@
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 +1,2 @@
1
- import{a as e,c as t,i as n,n as r,o as i,r as a,s as o,t as s}from"../parse-BYhuR8fo.mjs";export{s as escapePointerSegment,r as formatJsonPointer,a as isInteger,n as isRoot,e as isValidIndex,i as parent,o as parseJsonPointer,t as unescapePointerSegment};
1
+ import{isString as e}from"../type-checks/src/is-string.mjs";import{isNumber as t}from"../type-checks/src/is-number.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=>e(n)?n===``: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(e){if(t(e))return!0;let n=Number.parseInt(e,10);return String(n)===e&&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{o as escapePointerSegment,l as formatJsonPointer,p as isInteger,u as isRoot,f as isValidIndex,d as parent,c as parseJsonPointer,s as unescapePointerSegment};
2
+ //# sourceMappingURL=parse.mjs.map
@@ -0,0 +1 @@
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":"wHAsBA,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"}
@@ -1 +1 @@
1
- const e=require(`./storm-json-DBxiMujR.cjs`);require(`./parse-error-0BAtatMf.cjs`),exports.StormJSON=e.t;
1
+ const e=require(`./_virtual/rolldown_runtime.cjs`),t=require(`./type-checks/src/is-object.cjs`),n=require(`./type-checks/src/is-string.cjs`),r=require(`./utils/parse.cjs`),i=require(`./utils/parse-error.cjs`),a=require(`./utils/stringify.cjs`);let o=require(`jsonc-parser`),s=require(`node:buffer`),c=require(`superjson`);c=e.__toESM(c);var l=class e extends c.default{static#e;static get instance(){return e.#e||=new e,e.#e}static deserialize(t){return e.instance.deserialize(t)}static serialize(t){return e.instance.serialize(t)}static parse(e){return r.parse(e)}static stringify(t,n){let r=e.instance.customTransformerRegistry.findApplicable(t),i=t;return r&&r.isApplicable(t)&&(i=r.serialize(i)),a.stringify(i)}static parseJson(t,n){try{if(n?.expectComments===!1)return e.instance.parse(t)}catch{}let r=[],a=(0,o.parse)(t,r,{allowTrailingComma:!0,...n});if(r.length>0&&r[0])throw Error(i.formatParseError(t,r[0]));return a}static register(t,n,r,i){e.instance.registerCustom({isApplicable:i,serialize:n,deserialize:r},t)}static registerClass(r,i){e.instance.registerClass(r,{identifier:n.isString(i)?i:i?.identifier||r.name,allowProps:i&&t.isObject(i)&&i?.allowProps&&Array.isArray(i.allowProps)?i.allowProps:[`__typename`]})}constructor(){super({dedupe:!0})}};l.instance.registerCustom({isApplicable:e=>s.Buffer.isBuffer(e),serialize:e=>e.toString(`base64`),deserialize:e=>s.Buffer.from(e,`base64`)},`Bytes`),exports.StormJSON=l;
@@ -1,2 +1,70 @@
1
- import { t as StormJSON } from "./storm-json-Q1bOIv3-.cjs";
2
- export { StormJSON };
1
+ import { Class, JsonParseOptions, JsonParserResult, JsonSerializeOptions, JsonValue } from "./types.cjs";
2
+ import SuperJSON from "superjson";
3
+
4
+ //#region src/storm-json.d.ts
5
+
6
+ /**
7
+ * A static JSON parser class used by Storm Software to serialize and deserialize JSON data
8
+ *
9
+ * @remarks
10
+ * This class uses the [SuperJSON](https://github.com/blitz-js/superjson) library under the hood.
11
+ */
12
+ declare class StormJSON extends SuperJSON {
13
+ #private;
14
+ static get instance(): StormJSON;
15
+ /**
16
+ * Deserialize the given value with superjson using the given metadata
17
+ */
18
+ static deserialize<TData = unknown>(payload: JsonParserResult): TData;
19
+ /**
20
+ * Serialize the given value with superjson
21
+ */
22
+ static serialize(object: JsonValue): JsonParserResult;
23
+ /**
24
+ * Parse the given string value with superjson using the given metadata
25
+ *
26
+ * @param value - The string value to parse
27
+ * @returns The parsed data
28
+ */
29
+ static parse<TData = unknown>(value: string): TData;
30
+ /**
31
+ * Serializes the given data to a JSON string.
32
+ * By default the JSON string is formatted with a 2 space indentation to be easy readable.
33
+ *
34
+ * @param value - Object which should be serialized to JSON
35
+ * @param _options - JSON serialize options
36
+ * @returns the formatted JSON representation of the object
37
+ */
38
+ static stringify<T>(value: T, _options?: JsonSerializeOptions): string;
39
+ /**
40
+ * Parses the given JSON string and returns the object the JSON content represents.
41
+ * By default javascript-style comments and trailing commas are allowed.
42
+ *
43
+ * @param strData - JSON content as string
44
+ * @param options - JSON parse options
45
+ * @returns Object the JSON content represents
46
+ */
47
+ static parseJson<TData = unknown>(strData: string, options?: JsonParseOptions): TData;
48
+ /**
49
+ * Register a custom schema with superjson
50
+ *
51
+ * @param name - The name of the schema
52
+ * @param serialize - The function to serialize the schema
53
+ * @param deserialize - The function to deserialize the schema
54
+ * @param isApplicable - The function to check if the schema is applicable
55
+ */
56
+ static register<TData = any, TJsonObject extends JsonValue = JsonValue>(name: string, serialize: (data: TData) => TJsonObject, deserialize: (json: TJsonObject) => TData, isApplicable: (data: any) => data is TData): void;
57
+ /**
58
+ * Register a class with superjson
59
+ *
60
+ * @param classConstructor - The class constructor to register
61
+ */
62
+ static registerClass(classConstructor: Class, options?: {
63
+ identifier?: string;
64
+ allowProps?: string[];
65
+ } | string): void;
66
+ private constructor();
67
+ }
68
+ //#endregion
69
+ export { StormJSON };
70
+ //# sourceMappingURL=storm-json.d.cts.map
@@ -0,0 +1 @@
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,3 +1,70 @@
1
- import "./types-CQHq94S4.mjs";
2
- import { t as StormJSON } from "./storm-json-CfqJ0KzG.mjs";
3
- export { StormJSON };
1
+ import { Class, JsonParseOptions, JsonParserResult, JsonSerializeOptions, JsonValue } from "./types.mjs";
2
+ import SuperJSON from "superjson";
3
+
4
+ //#region src/storm-json.d.ts
5
+
6
+ /**
7
+ * A static JSON parser class used by Storm Software to serialize and deserialize JSON data
8
+ *
9
+ * @remarks
10
+ * This class uses the [SuperJSON](https://github.com/blitz-js/superjson) library under the hood.
11
+ */
12
+ declare class StormJSON extends SuperJSON {
13
+ #private;
14
+ static get instance(): StormJSON;
15
+ /**
16
+ * Deserialize the given value with superjson using the given metadata
17
+ */
18
+ static deserialize<TData = unknown>(payload: JsonParserResult): TData;
19
+ /**
20
+ * Serialize the given value with superjson
21
+ */
22
+ static serialize(object: JsonValue): JsonParserResult;
23
+ /**
24
+ * Parse the given string value with superjson using the given metadata
25
+ *
26
+ * @param value - The string value to parse
27
+ * @returns The parsed data
28
+ */
29
+ static parse<TData = unknown>(value: string): TData;
30
+ /**
31
+ * Serializes the given data to a JSON string.
32
+ * By default the JSON string is formatted with a 2 space indentation to be easy readable.
33
+ *
34
+ * @param value - Object which should be serialized to JSON
35
+ * @param _options - JSON serialize options
36
+ * @returns the formatted JSON representation of the object
37
+ */
38
+ static stringify<T>(value: T, _options?: JsonSerializeOptions): string;
39
+ /**
40
+ * Parses the given JSON string and returns the object the JSON content represents.
41
+ * By default javascript-style comments and trailing commas are allowed.
42
+ *
43
+ * @param strData - JSON content as string
44
+ * @param options - JSON parse options
45
+ * @returns Object the JSON content represents
46
+ */
47
+ static parseJson<TData = unknown>(strData: string, options?: JsonParseOptions): TData;
48
+ /**
49
+ * Register a custom schema with superjson
50
+ *
51
+ * @param name - The name of the schema
52
+ * @param serialize - The function to serialize the schema
53
+ * @param deserialize - The function to deserialize the schema
54
+ * @param isApplicable - The function to check if the schema is applicable
55
+ */
56
+ static register<TData = any, TJsonObject extends JsonValue = JsonValue>(name: string, serialize: (data: TData) => TJsonObject, deserialize: (json: TJsonObject) => TData, isApplicable: (data: any) => data is TData): void;
57
+ /**
58
+ * Register a class with superjson
59
+ *
60
+ * @param classConstructor - The class constructor to register
61
+ */
62
+ static registerClass(classConstructor: Class, options?: {
63
+ identifier?: string;
64
+ allowProps?: string[];
65
+ } | string): void;
66
+ private constructor();
67
+ }
68
+ //#endregion
69
+ export { StormJSON };
70
+ //# sourceMappingURL=storm-json.d.mts.map
@@ -0,0 +1 @@
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 +1,2 @@
1
- import"./parse-error-DrJJkemH.mjs";import{t as e}from"./storm-json-BsdLpzM_.mjs";export{e as StormJSON};
1
+ import{isObject as e}from"./type-checks/src/is-object.mjs";import{isString as t}from"./type-checks/src/is-string.mjs";import{parse as n}from"./utils/parse.mjs";import{formatParseError as r}from"./utils/parse-error.mjs";import{stringify as i}from"./utils/stringify.mjs";import{parse as a}from"jsonc-parser";import{Buffer as o}from"node:buffer";import s from"superjson";var c=class o extends s{static#e;static get instance(){return o.#e||=new o,o.#e}static deserialize(e){return o.instance.deserialize(e)}static serialize(e){return o.instance.serialize(e)}static parse(e){return n(e)}static stringify(e,t){let n=o.instance.customTransformerRegistry.findApplicable(e),r=e;return n&&n.isApplicable(e)&&(r=n.serialize(r)),i(r)}static parseJson(e,t){try{if(t?.expectComments===!1)return o.instance.parse(e)}catch{}let n=[],i=a(e,n,{allowTrailingComma:!0,...t});if(n.length>0&&n[0])throw Error(r(e,n[0]));return i}static register(e,t,n,r){o.instance.registerCustom({isApplicable:r,serialize:t,deserialize:n},e)}static registerClass(n,r){o.instance.registerClass(n,{identifier:t(r)?r:r?.identifier||n.name,allowProps:r&&e(r)&&r?.allowProps&&Array.isArray(r.allowProps)?r.allowProps:[`__typename`]})}constructor(){super({dedupe:!0})}};c.instance.registerCustom({isApplicable:e=>o.isBuffer(e),serialize:e=>e.toString(`base64`),deserialize:e=>o.from(e,`base64`)},`Bytes`);export{c as StormJSON};
2
+ //# sourceMappingURL=storm-json.mjs.map
@@ -0,0 +1 @@
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":"gXA0CA,IAAa,EAAb,MAAa,UAAkB,CAAU,CACvC,OAAA,EAEA,WAAkB,UAAsB,CAKtC,MAJA,CACE,GAAA,IAAsB,IAAI,EAGrB,GAAA,EAMT,OAAuB,YACrB,EACO,CACP,OAAO,EAAU,SAAS,YAAY,EAAQ,CAMhD,OAAuB,UAAU,EAAqC,CACpE,OAAO,EAAU,SAAS,UAAU,EAAO,CAS7C,OAAuB,MAAuB,EAAsB,CAClE,OAAOC,EAAW,EAAM,CAW1B,OAAuB,UACrB,EACA,EACQ,CACR,IAAM,EACJ,EAAU,SAAS,0BAA0B,eAAe,EAAM,CAEhE,EAAS,EAKb,OAJI,GAAqB,EAAkB,aAAa,EAAM,GAC5D,EAAS,EAAkB,UAAU,EAAO,EAGvCC,EAAe,EAAO,CAW/B,OAAc,UACZ,EACA,EACO,CACP,GAAI,CACF,GAAI,GAAS,iBAAmB,GAC9B,OAAO,EAAU,SAAS,MAAM,EAAQ,MAEpC,EAIR,IAAMC,EAAuB,EAAE,CAKzB,EAAS,EAAM,EAAS,EAJjB,CACX,mBAAoB,GACpB,GAAG,EACJ,CAC0C,CAE3C,GAAI,EAAO,OAAS,GAAK,EAAO,GAC9B,MAAU,MAAM,EAAiB,EAAS,EAAO,GAAG,CAAC,CAGvD,OAAO,EAWT,OAAc,SAIZ,EACA,EACA,EACA,EACA,CACA,EAAU,SAAS,eACjB,CACE,eACA,YACA,cACD,CACD,EACD,CAQH,OAAuB,cACrB,EACA,EACA,CACA,EAAU,SAAS,cAAc,EAAkB,CACjD,WAAY,EAAS,EAAQ,CACzB,EACA,GAAS,YAAc,EAAiB,KAC5C,WACE,GACA,EAAS,EAAQ,EACjB,GAAS,YACT,MAAM,QAAQ,EAAQ,WAAW,CAC7B,EAAQ,WACR,CAAC,aAAa,CACrB,CAAC,CAGJ,aAAsB,CACpB,MAAM,CAAE,OAAQ,GAAM,CAAC,GAI3B,EAAU,SAAS,eACjB,CACE,aAAe,GAAmB,EAAO,SAAS,EAAE,CACpD,UAAW,GAAK,EAAE,SAAS,SAAS,CACpC,YAAa,GAAK,EAAO,KAAK,EAAG,SAAS,CAC3C,CACD,QACD"}
@@ -0,0 +1 @@
1
+ const e=e=>e==null?e===void 0?`[object Undefined]`:`[object Null]`:Object.prototype.toString.call(e);exports.getObjectTag=e;
@@ -0,0 +1,2 @@
1
+ const e=e=>e==null?e===void 0?`[object Undefined]`:`[object Null]`:Object.prototype.toString.call(e);export{e as getObjectTag};
2
+ //# sourceMappingURL=get-object-tag.mjs.map
@@ -0,0 +1 @@
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,EAAgB,GACvB,GAAS,KACJ,IAAU,IAAA,GAAY,qBAAuB,gBAE/C,OAAO,UAAU,SAAS,KAAK,EAAM"}
@@ -0,0 +1 @@
1
+ const e=require(`./is-undefined.cjs`),t=require(`./is-null.cjs`),n=n=>{try{return e.isUndefined(n)||t.isNull(n)}catch{return!1}};exports.isEmpty=n;
@@ -0,0 +1,2 @@
1
+ import{isUndefined as e}from"./is-undefined.mjs";import{isNull as t}from"./is-null.mjs";const n=n=>{try{return e(n)||t(n)}catch{return!1}};export{n as isEmpty};
2
+ //# sourceMappingURL=is-empty.mjs.map
@@ -0,0 +1 @@
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":"wFA+BA,MAAa,EAAW,GAAmB,CACzC,GAAI,CACF,OAAO,EAAY,EAAM,EAAI,EAAO,EAAM,MACpC,CACN,MAAO"}