rlp-kind
v1.1.1
Published
Bindings for Kind's implementation of RLP encoding.
Downloads
2
Readme
rlp-kind
Node.js wrapper for the RLP Encoding library written in Kind.
We provide a proof to ensure that all encoded RLPs will be correctly decoded in the underlying implementation.
DEMO.
Install
npm install --save rlp-kind
yarn add rlp-kind
Install globally if you want to use the CLI:
npm install -g rlp-kind
yarn global add rlp-kind
Usage
API
import * as assert from 'assert'
import * as rlp from 'rlp-kind'
const nestedList = [[], [[]], [[], [[]]]]
const encoded = rlp.encode(nestedList)
const decoded = rlp.decode(encoded)
assert.deepEqual(nestedList, decoded)
encode
encode(input: InputTree): Buffer
RLP encodes a tree of data (Buffer
s, String
s etc) and returns a Buffer
.
decode
decode(input: Input): BufferTree
Decodes an RLP encoded Buffer
, String
etc and returns a tree of Buffer
s.
The input will be converted to a buffer.
Types
type Input =
| Buffer
| string
| number
| bigint
| Uint8Array
| BN
| null
type InputTree =
| InputTree[]
| Input
type BufferTree = Buffer | BufferTree[]
CLI
$ rlp encode '[ 5 ]'
c105
$ rlp decode '0xc105'
[ '05' ]