New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

alpha-serializer

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

alpha-serializer

Configurable serializer with generic interface

latest
Source
npmnpm
Version
0.5.6
Version published
Weekly downloads
685
59.67%
Maintainers
1
Weekly downloads
 
Created
Source

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

Keywords

serializer

FAQs

Package last updated on 23 Jan 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts