1 |
|
2 | import typeson from './typeson.js';
|
3 |
|
4 | import { structuredCloningThrowing } from 'typeson-registry';
|
5 | import blob from './blob.js';
|
6 | import file from './file.js';
|
7 | import filelist from './filelist.js';
|
8 | const { Typeson } = typeson;
|
9 | const structuredCloningThrowingPatched = structuredCloningThrowing
|
10 | .filter((x) => !x.file && !x.blob)
|
11 | .concat([blob, file, filelist]);
|
12 | const Structured = new Typeson().register([structuredCloningThrowingPatched]);
|
13 | export function parse(s) {
|
14 | return Structured.revive(JSON.parse(s));
|
15 | }
|
16 | export function stringify(value) {
|
17 | return Structured.stringifySync(value);
|
18 | }
|
19 | export function stringifyAsync(value) {
|
20 | return Structured.stringifyAsync(value);
|
21 | }
|
22 | export function toJSON(value) {
|
23 | return Structured.encapsulateSync(value);
|
24 | }
|
25 | export function toJSONAsync(value) {
|
26 | return Structured.encapsulateAsync(value);
|
27 | }
|
28 | export function fromJSON(json) {
|
29 | return Structured.revive(json);
|
30 | }
|
31 | export { toJSON as toJSONValue, fromJSON as fromJSONValue, fromJSON as revive, toJSON as encapsulate, toJSONAsync as encapsulateAsync, };
|
32 |
|
\ | No newline at end of file |