Skip to content

JavaScript library for Erlang External Term Format

License

Notifications You must be signed in to change notification settings

JasonDevTech/erlpackjs

Repository files navigation

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

About

JavaScript library for Erlang External Term Format

Topics

Resources

License

Stars

Watchers

Forks