Serializable class in ES6
Use case
Its common scenario in javscript development where we want to store js object into file/string. Js provides a powerfull built-in format JSON. However by default json format cannot contain arbitary type of object. Also restoring of original object needs little bit of work. Serializable class help you in this regard- serlizing and deserializing of javascript object in json format.
General Use
var ast = {}; { return ast; } { super; thisargument = left; thisoperator = operator; } astexpression = expression;var str = JSON; //Deserialzingvar createdExpression = Object;createdExpression;
Alternate to subclassing
{ return ast; } Serializable;
With explcit attributes for serialization.
{ super; thisargument = left; thisoperator = operator; } { return super; }
Unit Tests
For now, a basic test has been implmneted using ast/expression as example.
npm test
TODO
- Support for cyclic object reference
- Add more test cases