Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mvaldesdeleon/jayjay
Encodes JavaScript values as JavaScript values
https://github.com/mvaldesdeleon/jayjay
Last synced: about 6 hours ago
JSON representation
Encodes JavaScript values as JavaScript values
- Host: GitHub
- URL: https://github.com/mvaldesdeleon/jayjay
- Owner: mvaldesdeleon
- License: other
- Created: 2018-07-21T18:19:34.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-07-21T22:01:54.000Z (over 6 years ago)
- Last Synced: 2024-11-07T03:03:37.211Z (10 days ago)
- Language: JavaScript
- Size: 16.6 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
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 the `rules` array
* `condition` fn(value) -> boolean, checks if the rule applies
* `encode` fn(value) -> \*, encodes the value
* `decode` fn(\*) -> value, decodes the valueReturns an object with two members:
* `encode` fn(\*) -> \*, encodes javascript values into javascript values
* `decode` fn(\*) -> \*, decodes javascript values into javasctipt values# Examples
See `test.js` to get started.
# Install
With [npm](https://npmjs.org) do:```
npm install jayjay
```# License
MIT