Skip to content

Commit

Permalink
Added JSDoc for json export
Browse files Browse the repository at this point in the history
  • Loading branch information
WebReflection committed May 11, 2022
1 parent 9ab44fa commit 491a105
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
12 changes: 11 additions & 1 deletion cjs/json.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,18 @@ const {serialize} = require('./serialize.js');
const {parse: $parse, stringify: $stringify} = JSON;
const options = {json: true, lossy: true};

/**
* Revive a previously stringified structured clone.
* @param {string} str previously stringified data as string.
* @returns {any} whatever was previously stringified as clone.
*/
const parse = str => deserialize($parse(str));
exports.parse = parse;

const stringify = str => $stringify(serialize(str, options));
/**
* Represent a structured clone value as string.
* @param {any} any some clone-able value to stringify.
* @returns {string} the value stringified.
*/
const stringify = any => $stringify(serialize(any, options));
exports.stringify = stringify;
12 changes: 11 additions & 1 deletion esm/json.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@ import {serialize} from './serialize.js';
const {parse: $parse, stringify: $stringify} = JSON;
const options = {json: true, lossy: true};

/**
* Revive a previously stringified structured clone.
* @param {string} str previously stringified data as string.
* @returns {any} whatever was previously stringified as clone.
*/
export const parse = str => deserialize($parse(str));

export const stringify = str => $stringify(serialize(str, options));
/**
* Represent a structured clone value as string.
* @param {any} any some clone-able value to stringify.
* @returns {string} the value stringified.
*/
export const stringify = any => $stringify(serialize(any, options));

0 comments on commit 491a105

Please sign in to comment.