https://github.com/aionnetwork/aion_rlp.js
Aion flavoured RLP encoding
https://github.com/aionnetwork/aion_rlp.js
aion rlp serialization
Last synced: about 2 months ago
JSON representation
Aion flavoured RLP encoding
- Host: GitHub
- URL: https://github.com/aionnetwork/aion_rlp.js
- Owner: aionnetwork
- License: mit
- Created: 2018-08-22T14:08:59.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2019-01-21T17:07:07.000Z (over 7 years ago)
- Last Synced: 2025-06-23T15:51:03.734Z (about 1 year ago)
- Topics: aion, rlp, serialization
- Language: JavaScript
- Homepage: https://aion.network/
- Size: 13.7 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
## SYNOPSIS
## INSTALL
`npm install aion-rlp`
install with `-g` if you want to use the cli.
## USAGE
~~~~javascript
var RLP = require('aion-rlp');
var assert = require('assert');
var nestedList = [ [], [[]], [ [], [[]] ] ];
var encoded = RLP.encode(nestedList);
var decoded = RLP.decode(encoded);
assert.deepEqual(nestedList, decoded);
~~~~
## API
`rlp.encode(plain)` - RLP encodes an `Array`, `Buffer` or `String` and returns a `Buffer`.
`rlp.decode(encoded, [skipRemainderCheck=false])` - Decodes an RLP encoded `Buffer`, `Array` or `String` and returns a `Buffer` or an `Array` of `Buffers`. If `skipRemainderCheck` is enabled, `rlp` will just decode the first rlp sequence in the buffer. By default, it would throw an error if there are more bytes in Buffer than used by rlp sequence.
The difference between ``aion-rlp`` and ``rlp`` is the alternative encoding of longs, therefore `rlp.encode(plain)` accepts an extra type `AionLong`, in addition to the base supported types.
## CLI
`rlp decode `
`rlp encode `
## 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`