JSPM

stringify-parse

1.0.2
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 150
  • Score
    100M100P100Q84907F
  • License ISC

A tool like JSON.string and JSON.parse but can convert the type Function and RegExp in js object

Package Exports

  • stringify-parse

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (stringify-parse) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

js-full

A tool like JSON.stringify and JSON.parse but can convert the type Function and RegExp in the js object.

.eg

let o = {
  name: 'js-full',
  method: function() {
    console.log('this is a function');
  },
  reg: /\w+/
}

Now, I want to convert the object into string, if we use JSON.stringify, it will lost the property method and reg

{"name":"demo","reg":{}}

This is not what we want. Now we can use the tool js-full

const jsfull = require('js-full');
console.log(jsfull(o));

output:

{"name":"demo","method":function() {
    console.log('this is a function');
  },"reg":/\w+/

Then we can use the method jsfull.parse to convert the json string into object.

let str = `{"name":"demo","method":function() {
    console.log('this is a function');
  },"reg":/\w+/
 `;
console.log(jsfull.parse(str));