1.0.1 • Published 3 years ago

erlpackjs v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

erlpackjs

ErlpackJS is a fast encoder and decoder for the Erlang Term Format (version 131) for JavaScript based on erlpack supporting the browser and node.

npm npm CircleCI Maintenance

Installation

$ yarn add erlpackjs

Things that can be packed

  • Null
  • Booleans
  • Strings
  • Atoms
  • Unicode Strings
  • Floats
  • Integers
  • Longs
  • Longs over 64 bits
  • Objects
  • Arrays
  • Tuples
  • PIDs
  • Ports
  • Exports
  • References

Usage

How to pack

import { pack } from 'erlpackjs';

const packed = pack({ a: true, list: ['of', 3, 'things', 'to', 'pack'] });

console.log(packed);

How to unpack

Note: Unpacking requires the binary data be a Uint8Array or Buffer.

import { unpack } from 'erlpackjs';

const packed = Buffer.from('', 'binary');
let unpacked = null;

try {
    unpacked = unpack(packed);

    console.log(unpacked);
} catch (err) {
    // Got an exception parsing
    console.log(err);
}