# jayjay

> Encodes JavaScript values as JavaScript values

Latest version **1.0.3** (published 2018-07-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install jayjay
pnpm add jayjay
yarn add jayjay
bun add jayjay
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2018-07-21 |
| First published | 2018-07-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 10 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Martin Valdes de Leon |
| Maintainers | mvaldesdeleon |
| Keywords | encode, decode, javascript |

## Links

- npm: https://www.npmjs.com/package/jayjay
- Repository: https://github.com/mvaldesdeleon/jayjay
- Homepage: https://github.com/mvaldesdeleon/jayjay#readme
- Issues: https://github.com/mvaldesdeleon/jayjay/issues
- npm.io page: https://npm.io/package/jayjay

## Alternatives

- [flatbuffers](https://npm.io/package/flatbuffers.md) — 6.0M weekly downloads
- [jwt-simple](https://npm.io/package/jwt-simple.md) — 259.5K weekly downloads
- [@exodus/patch-broken-hermes-typed-arrays](https://npm.io/package/@exodus/patch-broken-hermes-typed-arrays.md) — 28.5K weekly downloads
- [@native-to-anchor/buffer-layout](https://npm.io/package/@native-to-anchor/buffer-layout.md) — 12.2K weekly downloads
- [binary-parser-encoder](https://npm.io/package/binary-parser-encoder.md) — 5.3K weekly downloads

## Recent versions

- 1.0.3 (latest) — 2018-07-21
- 1.0.2 — 2018-07-21
- 1.0.1 — 2018-07-21
- 1.0.0 — 2018-07-21

## 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 value

Returns 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

---
_Source: https://npm.io/package/jayjay · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
