@brillout/json-serializer 0.5.9 → 0.5.10
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/cjs/parse.d.ts +2 -0
- package/dist/cjs/parse.js +5 -4
- package/dist/esm/parse.d.ts +2 -0
- package/dist/esm/parse.js +4 -3
- package/package.json +1 -1
- package/parse.js +1 -0
package/dist/cjs/parse.d.ts
CHANGED
package/dist/cjs/parse.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parse = void 0;
|
|
3
|
+
exports.parseTransform = exports.parse = void 0;
|
|
4
4
|
const types_1 = require("./types");
|
|
5
5
|
function parse(str) {
|
|
6
6
|
// We don't use the reviver option in `JSON.parse(str, reviver)` because it doesn't support `undefined` values
|
|
7
7
|
const value = JSON.parse(str);
|
|
8
|
-
return
|
|
8
|
+
return parseTransform(value);
|
|
9
9
|
}
|
|
10
10
|
exports.parse = parse;
|
|
11
|
-
function
|
|
11
|
+
function parseTransform(value) {
|
|
12
12
|
if (typeof value === 'string') {
|
|
13
13
|
return reviver(value);
|
|
14
14
|
}
|
|
@@ -18,11 +18,12 @@ function modifier(value) {
|
|
|
18
18
|
value !== null) {
|
|
19
19
|
Object.entries(value).forEach(([key, val]) => {
|
|
20
20
|
;
|
|
21
|
-
value[key] =
|
|
21
|
+
value[key] = parseTransform(val);
|
|
22
22
|
});
|
|
23
23
|
}
|
|
24
24
|
return value;
|
|
25
25
|
}
|
|
26
|
+
exports.parseTransform = parseTransform;
|
|
26
27
|
function reviver(value) {
|
|
27
28
|
for (const { match, deserialize } of types_1.types) {
|
|
28
29
|
if (match(value)) {
|
package/dist/esm/parse.d.ts
CHANGED
package/dist/esm/parse.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
export { parse };
|
|
2
|
+
export { parseTransform };
|
|
2
3
|
import { types } from './types';
|
|
3
4
|
function parse(str) {
|
|
4
5
|
// We don't use the reviver option in `JSON.parse(str, reviver)` because it doesn't support `undefined` values
|
|
5
6
|
const value = JSON.parse(str);
|
|
6
|
-
return
|
|
7
|
+
return parseTransform(value);
|
|
7
8
|
}
|
|
8
|
-
function
|
|
9
|
+
function parseTransform(value) {
|
|
9
10
|
if (typeof value === 'string') {
|
|
10
11
|
return reviver(value);
|
|
11
12
|
}
|
|
@@ -15,7 +16,7 @@ function modifier(value) {
|
|
|
15
16
|
value !== null) {
|
|
16
17
|
Object.entries(value).forEach(([key, val]) => {
|
|
17
18
|
;
|
|
18
|
-
value[key] =
|
|
19
|
+
value[key] = parseTransform(val);
|
|
19
20
|
});
|
|
20
21
|
}
|
|
21
22
|
return value;
|
package/package.json
CHANGED
package/parse.js
CHANGED