# num-record-packer

> A JSON to JSON mapper in TypeScript for compacting NUM objects according to an unpacker spec.

Latest version **0.0.7** (published 2022-04-26) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install num-record-packer
pnpm add num-record-packer
yarn add num-record-packer
bun add num-record-packer
```

## Health

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

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

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.7 |
| Published | 2022-04-26 |
| First published | 2021-07-28 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 54.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | NUM Technology Ltd |
| Maintainers | frednum, twalmsley |

## Links

- npm: https://www.npmjs.com/package/num-record-packer
- Repository: https://github.com/NUMtechnology/num-record-packer
- Homepage: https://github.com/NUMtechnology/num-record-packer#readme
- Issues: https://github.com/NUMtechnology/num-record-packer/issues
- npm.io page: https://npm.io/package/num-record-packer

## Dependencies (1)

- [object-unpacker](https://npm.io/package/object-unpacker.md) ^0.0.22

## Recent versions

- 0.0.7 (latest) — 2022-04-26
- 0.0.6 — 2022-04-22
- 0.0.5 — 2022-02-09
- 0.0.4 — 2022-02-09
- 0.0.2 — 2021-08-09
- 0.0.1 — 2021-07-28

## README

# TypeScript NUM Record Packer

This program takes a JSON object and convertes it to a more compact JSON object using a mapping specification, also written as JSON.

## Running the example code in a web browser

1. Clone the repository using `git clone git@github.com:NUMtechnology/num-record-packer.git`.
2. `cd num-record-packer`
3. Run `npm install -g webpack`
4. Run `npm install -g webpack-cli`
5. Run `npm install`
6. Open the `test/index.html` file using a web browser (Only tested using Brave browser)
7. Paste your JSON into the first two text areas and click `Pack` to see the result.
   
## Use the Packer in JavaScript
```javascript
const api = require('num-record-packer');

const mapperData = {
  phonetic: {
    assignKeys: ['a', 'b', 'c'],
  },
};

const data = {
  phonetic: {
    a: 'alpha',
    b: 'bravo',
    c: 'charlie',
  },
};

const packed = api.mapper.pack(data, mapperData);

console.log(JSON.stringify(packed));
```

## Use the Packer in TypeScript
```typescript
import { createNumRecordPacker } from 'num-record-packer';

const mapperData = {
  phonetic: {
    assignKeys: ['a', 'b', 'c'],
  },
};

const data: object = {
  phonetic: {
    a: 'alpha',
    b: 'bravo',
    c: 'charlie',
  },
};

const packer = createNumRecordPacker();
const packed: object = packer.pack(data, mapperData);
console.log(JSON.stringify(packed));```

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