serialize-javascript
serialize-javascript copied to clipboard
Serialize JavaScript to a superset of JSON that includes regular expressions and functions.

There is a group of people on GitHub trying to draft a new standard of JSON called JSON5. It might be a good idea to take a look at it...
Input: ```js const options = { file: 'test5.js', input: '/******/ function hello(a) {console.log(a)}', terserOptions: { output: { comments: 'all', }, }, extractComments: { condition: 'should be extracted', filename: (file) =>...
The regexp pattern can be controlled by overwriting `Math.random()`, check it before replacing. ```javascript Math.random = function () { return 1 } var data = { '@__F-1-0__@': function () {}...
Add support for serialization and deserialization of custom objects via `Object.assign` and `Object.create` For example: ```javascript class A { a = 1 } serialize(A, { classes: { A } })...
It's very nice if support extracting same refs of object, for example ```javascript var obj = {} serialize({b: obj, c: obj}) ``` get ```javascript (function() { var a = {};...
It would be handy for a use case I have for this package to support a feature that could inject code verbatim if it appears in a JavaScript object. To...
Would be nice to have an option to remove unnecessary whitespace in stringified functions