Socket
Socket
Sign inDemoInstall

num-record-packer

Package Overview
Dependencies
13
Maintainers
2
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    num-record-packer

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


Version published
Weekly downloads
0
decreased by-100%
Maintainers
2
Install size
1.15 MB
Created
Weekly downloads
 

Readme

Source

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

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

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));```

FAQs

Last updated on 26 Apr 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc