0.5.6 • Published 4 years ago

alpha-serializer v0.5.6

Weekly downloads
94
License
MIT
Repository
github
Last release
4 years ago

Alpha-serializer

CircleCI Coverage Status

  • 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} = require('alpha-serializer');

const object = {
    map: new Map([['key', 'value']]),
    set: new Set(['value1', 'value2']),
    date: new Date(),
    foo: 'bar'
};

const serialized = serialize(object);
// send serialized data to the browser or somewhere else

const result = deserialize(object);

result.map instanceof Map; // true
result.set instanceof Set; // true
result.date instanceof Date; // true
result.foo; // 'bar'


const {Serializable, registerNormalization} = require('alpha-serializer');
@Serializable()
class Foo {
    
}

// same as above
registerNormalization({clazz: Foo});

Usage as object

Using global object

const {serializer} = require('alpha-serializer');

const s = serializer.serialize(new Date());
serializer.deserialize(s);

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

More

0.5.4

4 years ago

0.5.6

4 years ago

0.5.1

4 years ago

0.4.1

5 years ago

0.4.0

6 years ago

0.3.0

6 years ago

0.2.0

6 years ago

0.1.9

6 years ago

0.1.8

6 years ago

0.1.7

6 years ago

0.1.6

6 years ago

0.1.5

6 years ago

0.1.4

6 years ago

0.1.3

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago