2.1.0 • Published 6 years ago
srlp v2.1.0
SYNOPSIS
Recursive Length Prefix Encoding for node.js.
INSTALL
npm install srlp
install with -g if you want to use the cli.
USAGE
var SRLP = require('srlp');
var assert = require('assert');
var nestedList = [ [], [[]], [ [], [[]] ] ];
var encoded = SRLP.encode(nestedList);
var decoded = SRLP.decode(encoded);
assert.deepEqual(nestedList, decoded);API
srlp.encode(plain) - SRLP encodes an Array, Buffer or String and returns a Buffer.
srlp.decode(encoded, [skipRemainderCheck=false]) - Decodes an SRLP encoded Buffer, Array or String and returns a Buffer or an Array of Buffers. If skipRemainderCheck is enabled, srlp will just decode the first srlp sequence in the buffer. By default, it would throw an error if there are more bytes in Buffer than used by srlp sequence.
CLI
srlp decode <hex string>srlp encode <json String>
TESTS
Test uses mocha. To run npm test
CODE COVERAGE
Install dev dependencies
npm install
Run
npm run coverage
The results are at
coverage/lcov-report/index.html