1.0.0 • Published 5 years ago

stringify-full v1.0.0

Weekly downloads
1
License
ISC
Repository
-
Last release
5 years ago

stringify-full

a tool which can stringify the Function and RegExp in the js object

.eg

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

Now, I want to convert the object o 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 stringify-full

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

output:

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