srlp
TypeScript icon, indicating that this package has built-in type declarations

2.1.0 • Public • Published

SYNOPSIS

NPM Package Build Status Coverage Status Gitter or #sophonjs on freenode

js-standard-style

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

Readme

Keywords

Package Sidebar

Install

npm i srlp

Weekly Downloads

1

Version

2.1.0

License

MPL-2.0

Unpacked Size

27.1 kB

Total Files

8

Last publish

Collaborators

  • superstring