Alpha-serializer
- Serializer with support for multiple serialization formats
- Allows symmetric serialization
- Support serialization of custom types
- Properly serializes Map, Set and Date (more in future)
Install
npm install --save alpha-serializer
Usage with global functions
Simples possible example
const serialize deserialize = ; const object = map: 'key' 'value' set: 'value1' 'value2' date: foo: 'bar'; const serialized = ;// send serialized data to the browser or somewhere else const result = ; resultmap instanceof Map; // trueresultset instanceof Set; // trueresultdate instanceof Date; // trueresultfoo; // 'bar' const Serializable registerNormalization = ;@ // same as above;
Usage as object
Using global object
const serializer = ; const s = serializer;serializer;
Use cases
alpha-serializer is particularly usefull when you need to serialize:
- Simple errors or errors with special properties
- Value objects (for example ObjectId, Money or Date)
- Maps, sets and other data structures