jayjay
v1.0.3
Published
Encodes JavaScript values as JavaScript values
Downloads
3
Maintainers
Readme
jayjay
Encodes JavaScript values as JavaScript values.
Use
const jayjay = require('jayjay');
jayjay(opts)
Creates a new encoder/decoder
Available opts
are:
opts.rules
array of rules to use
Rules are objects with the following members:
name
string, should be unique within therules
arraycondition
fn(value) -> boolean, checks if the rule appliesencode
fn(value) -> *, encodes the valuedecode
fn(*) -> value, decodes the value
Returns an object with two members:
encode
fn(*) -> *, encodes javascript values into javascript valuesdecode
fn(*) -> *, decodes javascript values into javasctipt values
Examples
See test.js
to get started.
Install
With npm do:
npm install jayjay
License
MIT