Recursive Length Prefix Encoding
Recursive Length prefix encoding implementation in Reason.
Install
npm install reason-rlp
Install with -g
if you want to use the cli.
Usage
var RLP = require('reason-rlp');
var assert = require('assert');
var nestedList = [ [], [[]], [ [], [[]] ] ];
var encoded = RLP.encode(nestedList);
var decoded = RLP.decode(encoded);
assert.deepEquals(nestedList, decoded);
API
rlp.encode(plain)
- RLP encoded an Array
, Buffer
or String
and returns a Buffer
WIP rlp.decode(encoded, [skipRemainderCheck=false])
- Decodes an RLP encoded Buffer
, Array
or String
and returns a Buffer
or an Array
of Buffer
s. If skipRemainderCheck
is enabled
rlp
will just decode the first rlp sequence in the buffer. By default it would through an error
if there is more bytes in Buffer than used by the rlp sequence.
Tests
Tests use mocha. To run npm test