租房小程序前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
754 B

3 months ago
  1. 'use strict';
  2. /*! (c) Andrea Giammarchi - ISC */
  3. const {deserialize} = require('./deserialize.js');
  4. const {serialize} = require('./serialize.js');
  5. const {parse: $parse, stringify: $stringify} = JSON;
  6. const options = {json: true, lossy: true};
  7. /**
  8. * Revive a previously stringified structured clone.
  9. * @param {string} str previously stringified data as string.
  10. * @returns {any} whatever was previously stringified as clone.
  11. */
  12. const parse = str => deserialize($parse(str));
  13. exports.parse = parse;
  14. /**
  15. * Represent a structured clone value as string.
  16. * @param {any} any some clone-able value to stringify.
  17. * @returns {string} the value stringified.
  18. */
  19. const stringify = any => $stringify(serialize(any, options));
  20. exports.stringify = stringify;