@stryke/json 0.5.5 → 0.5.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/storm-json.cjs +2 -1
- package/dist/storm-json.mjs +1 -1
- package/package.json +1 -1
package/dist/storm-json.cjs
CHANGED
|
@@ -31,7 +31,8 @@ class StormJSON extends _superjson.default {
|
|
|
31
31
|
return s && (t = s.serialize(t)), this.stringifyBase(t);
|
|
32
32
|
}
|
|
33
33
|
static stringifyBase(e) {
|
|
34
|
-
|
|
34
|
+
const r = StormJSON.instance.stringify(e);
|
|
35
|
+
return r.startsWith('{"json":') ? r.substring(8, -1) : r;
|
|
35
36
|
}
|
|
36
37
|
static parseJson(e, r) {
|
|
37
38
|
try {
|
package/dist/storm-json.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isObject as o}from"@stryke/type-checks/is-object";import{isString as l}from"@stryke/type-checks/is-string";import{Buffer as a}from"buffer/";import{parse as c}from"jsonc-parser";import u from"superjson";import{formatParseError as p}from"./utils/parse-error";export class StormJSON extends u{static#e;static get instance(){return StormJSON.#e||(StormJSON.#e=new StormJSON),StormJSON.#e}static deserialize(e){return StormJSON.instance.deserialize(e)}static serialize(e){return StormJSON.instance.serialize(e)}static parse(e){return StormJSON.instance.parse(e)}static stringify(e,r){const s=StormJSON.instance.customTransformerRegistry.findApplicable(e);let t=e;return s&&(t=s.serialize(t)),this.stringifyBase(t)}static stringifyBase(e){
|
|
1
|
+
import{isObject as o}from"@stryke/type-checks/is-object";import{isString as l}from"@stryke/type-checks/is-string";import{Buffer as a}from"buffer/";import{parse as c}from"jsonc-parser";import u from"superjson";import{formatParseError as p}from"./utils/parse-error";export class StormJSON extends u{static#e;static get instance(){return StormJSON.#e||(StormJSON.#e=new StormJSON),StormJSON.#e}static deserialize(e){return StormJSON.instance.deserialize(e)}static serialize(e){return StormJSON.instance.serialize(e)}static parse(e){return StormJSON.instance.parse(e)}static stringify(e,r){const s=StormJSON.instance.customTransformerRegistry.findApplicable(e);let t=e;return s&&(t=s.serialize(t)),this.stringifyBase(t)}static stringifyBase(e){const r=StormJSON.instance.stringify(e);return r.startsWith('{"json":')?r.substring(8,-1):r}static parseJson(e,r){try{if(r?.expectComments===!1)return StormJSON.instance.parse(e)}catch{}const s=[],t={allowTrailingComma:!0,...r},n=c(e,s,t);if(s.length>0&&s[0])throw new Error(p(e,s[0]));return n}static register(e,r,s,t){StormJSON.instance.registerCustom({isApplicable:t,serialize:r,deserialize:s},e)}static registerClass(e,r){StormJSON.instance.registerClass(e,{identifier:l(r)?r:r?.identifier||e.name,allowProps:r&&o(r)&&r?.allowProps&&Array.isArray(r.allowProps)?r.allowProps:["__typename"]})}constructor(){super({dedupe:!0})}}StormJSON.instance.registerCustom({isApplicable:i=>a.isBuffer(i),serialize:i=>i.toString("base64"),deserialize:i=>a.from(i,"base64")},"Bytes");
|