main
Last change
on this file since d565449 was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
690 bytes
|
Line | |
---|
1 | /*! (c) Andrea Giammarchi - ISC */
|
---|
2 |
|
---|
3 | import {deserialize} from './deserialize.js';
|
---|
4 | import {serialize} from './serialize.js';
|
---|
5 |
|
---|
6 | const {parse: $parse, stringify: $stringify} = JSON;
|
---|
7 | const options = {json: true, lossy: true};
|
---|
8 |
|
---|
9 | /**
|
---|
10 | * Revive a previously stringified structured clone.
|
---|
11 | * @param {string} str previously stringified data as string.
|
---|
12 | * @returns {any} whatever was previously stringified as clone.
|
---|
13 | */
|
---|
14 | export const parse = str => deserialize($parse(str));
|
---|
15 |
|
---|
16 | /**
|
---|
17 | * Represent a structured clone value as string.
|
---|
18 | * @param {any} any some clone-able value to stringify.
|
---|
19 | * @returns {string} the value stringified.
|
---|
20 | */
|
---|
21 | export const stringify = any => $stringify(serialize(any, options));
|
---|
Note:
See
TracBrowser
for help on using the repository browser.