erlpackjs
v1.0.1
Published
JavaScript library for Erlang External Term Format
Downloads
72
Readme
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.
Installation
$ yarn add erlpackjs
Things that can be packed
- [x] Null
- [x] Booleans
- [x] Strings
- [ ] Atoms
- [x] Unicode Strings
- [x] Floats
- [x] Integers
- [ ] Longs
- [ ] Longs over 64 bits
- [x] Objects
- [x] 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);
}