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:
754 bytes
|
Line | |
---|
1 | 'use strict';
|
---|
2 | /*! (c) Andrea Giammarchi - ISC */
|
---|
3 |
|
---|
4 | const {deserialize} = require('./deserialize.js');
|
---|
5 | const {serialize} = require('./serialize.js');
|
---|
6 |
|
---|
7 | const {parse: $parse, stringify: $stringify} = JSON;
|
---|
8 | const options = {json: true, lossy: true};
|
---|
9 |
|
---|
10 | /**
|
---|
11 | * Revive a previously stringified structured clone.
|
---|
12 | * @param {string} str previously stringified data as string.
|
---|
13 | * @returns {any} whatever was previously stringified as clone.
|
---|
14 | */
|
---|
15 | const parse = str => deserialize($parse(str));
|
---|
16 | exports.parse = parse;
|
---|
17 |
|
---|
18 | /**
|
---|
19 | * Represent a structured clone value as string.
|
---|
20 | * @param {any} any some clone-able value to stringify.
|
---|
21 | * @returns {string} the value stringified.
|
---|
22 | */
|
---|
23 | const stringify = any => $stringify(serialize(any, options));
|
---|
24 | exports.stringify = stringify;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.