# binarynator

> Convert JSON data to binary and back

Latest version **0.0.4** (published 2020-03-09) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.4 |
| Published | 2020-03-09 |
| First published | 2020-03-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 20.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Wessel van der Linden |
| Maintainers | wessel |

## Links

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

## Dependencies (1)

- [bytebuffer](https://npm.io/package/bytebuffer.md) ^5.0.1

## Recent versions

- 0.0.4 (latest) — 2020-03-09
- 0.0.3 — 2020-03-05
- 0.0.2 — 2020-03-03
- 0.0.1 — 2020-03-03
- 0.0.0 — 2020-03-03

## README

# Binarynator

Just a simple "transcoder" which converts JSON structures, defined by a schema, to binary and back.

## Why?
Why not?

## Example

```javascript
import { encode, decode, object, string, int32, array } from 'binarynator';

const schema = object({
  word: string(),
  number: int32().nullable(),
  optional_number: int32().optional(),
  nested: object({
    child: string(),
  }),
  array: array(int32()),
});

const input = {
  word: 'something',
  number: null,
  optional_number: 1337,
  nested: {
    child: 'hello!',
  },
  array: [1, 2, 3, 4],
}

const encoded = encode(schema, input);
// encoded is now a Buffer, use this to write to a file or something...

const decoded = decode(schema, encoded);
// decoded is in the exact structure as defined by the schema, filled with the decoded data
```


## TODO
* include a version number of the schema in the binary
* InferType on arrays and oneOf doesn't work yet
* Improve error handling & messaging

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