pull-leb128 v0.0.1
SYNOPSIS
LEB128 encoding and decoding for signed and unsinged intergers. Supports arbitary length intergers larger then Number.MAX_SAFE_INTEGER
INSTALL
npm install pull-leb128
USAGE
const leb = require('leb128')
const pull = require('pull-stream')
const Pushable = require('pull-pushable')
const Reader = require('pull-reader')
const writer = Pushable()
const reader = Reader()
pull(writer, reader)
leb.unsigned.encode('9019283812387', writer)
leb.unsigned.read(reader).then(decoded => {
console.log(decoded)
// 9019283812387
})
API
Use require('leb128/signed')
for signed encoding and decoding and
require('leb128/unsigned')
for unsigned methods
unsigned.write
Writes a number as an unsigned leb128 to an instance of pull-pushable
Parameters
unsigned.read
Reads an unsigned leb128 from an instance of pull-read
Parameters
reader
pull-read
Returns Promise the promise resolves with a string containing the decoded integer
unsigned.readBn
Reads an unsigned leb128 from an instance of pull-read
Parameters
reader
pull-read
Returns Promise the promise resolves with a bn.js containing the decoded integer
signed.write
Writes a number as a signed leb128 to an instance of pull-pushable
Parameters
signed.read
Reads a signed leb128 from an instance of pull-read
Parameters
reader
pull-read
Returns Promise the promise resolves with a string containing the decoded integer
signed.readBn
Reads a signed leb128 from an instance of pull-read
Parameters
reader
pull-read
Returns Promise the promise resolves with a bn.js containing the decoded integer