@stryke/json 0.5.4 → 0.5.6
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 +3 -3
- package/dist/storm-json.d.ts +2 -2
- package/dist/storm-json.mjs +1 -1
- package/package.json +3 -3
package/dist/storm-json.cjs
CHANGED
|
@@ -10,7 +10,6 @@ var _buffer = require("buffer/");
|
|
|
10
10
|
var _jsoncParser = require("jsonc-parser");
|
|
11
11
|
var _superjson = _interopRequireDefault(require("superjson"));
|
|
12
12
|
var _parseError = require("./utils/parse-error.cjs");
|
|
13
|
-
var _stringify = require("./utils/stringify.cjs");
|
|
14
13
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
15
14
|
class StormJSON extends _superjson.default {
|
|
16
15
|
static #e;
|
|
@@ -29,10 +28,11 @@ class StormJSON extends _superjson.default {
|
|
|
29
28
|
static stringify(e, r) {
|
|
30
29
|
const s = StormJSON.instance.customTransformerRegistry.findApplicable(e);
|
|
31
30
|
let t = e;
|
|
32
|
-
return s && (t = s.serialize(t)),
|
|
31
|
+
return s && (t = s.serialize(t)), this.stringifyBase(t);
|
|
33
32
|
}
|
|
34
33
|
static stringifyBase(e) {
|
|
35
|
-
|
|
34
|
+
const r = StormJSON.instance.stringify(e);
|
|
35
|
+
return r.substring(r.indexOf('{"json":'), r.lastIndexOf("}"));
|
|
36
36
|
}
|
|
37
37
|
static parseJson(e, r) {
|
|
38
38
|
try {
|
package/dist/storm-json.d.ts
CHANGED
|
@@ -31,10 +31,10 @@ export declare class StormJSON extends SuperJSON {
|
|
|
31
31
|
* By default the JSON string is formatted with a 2 space indentation to be easy readable.
|
|
32
32
|
*
|
|
33
33
|
* @param value - Object which should be serialized to JSON
|
|
34
|
-
* @param
|
|
34
|
+
* @param _options - JSON serialize options
|
|
35
35
|
* @returns the formatted JSON representation of the object
|
|
36
36
|
*/
|
|
37
|
-
static stringify<T>(value: T,
|
|
37
|
+
static stringify<T>(value: T, _options?: JsonSerializeOptions): string;
|
|
38
38
|
/**
|
|
39
39
|
* Stringify the given value with superjson
|
|
40
40
|
*
|
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";
|
|
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.substring(r.indexOf('{"json":'),r.lastIndexOf("}"))}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");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stryke/json",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A package containing JSON parsing/stringify utilities used by Storm Software.",
|
|
6
6
|
"repository": {
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
"jsonc-parser": "3.3.1",
|
|
15
15
|
"lines-and-columns": "2.0.4",
|
|
16
16
|
"superjson": "2.2.2",
|
|
17
|
-
"@stryke/type-checks": "
|
|
18
|
-
"@stryke/types": "
|
|
17
|
+
"@stryke/type-checks": "^0.1.4",
|
|
18
|
+
"@stryke/types": "^0.7.4"
|
|
19
19
|
},
|
|
20
20
|
"publishConfig": { "access": "public" },
|
|
21
21
|
"devDependencies": {},
|