pull-leb128

0.0.1 • Public • Published

SYNOPSIS

NPM Package Build Status Coverage Status

js-standard-style

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

unsigned.js:53-65

Writes a number as an unsigned leb128 to an instance of pull-pushable

Parameters

unsigned.read

unsigned.js:4-8

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

unsigned.js:24-46

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

signed.js:56-78

Writes a number as a signed leb128 to an instance of pull-pushable

Parameters

signed.read

signed.js:4-8

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

signed.js:24-49

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

LICENSE

MPL-2.0

/pull-leb128/

    Package Sidebar

    Install

    npm i pull-leb128

    Weekly Downloads

    0

    Version

    0.0.1

    License

    MPL-2.0

    Unpacked Size

    28.8 kB

    Total Files

    8

    Last publish

    Collaborators

    • null_radix