biguintle
Encode / decode unsigned BigInt as little endian
Last updated a year ago by emilbayes .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install biguintle 
SYNC missed versions from official npm registry.

biguintle

Build Status abstract-encoding

Encode / decode unsigned BigInt as little endian

Usage

var bigUintLE = require('biguintle')

var bigUint = 2n ** 64n - 1n // UINT64_MAX

assert(bigUintLE.encodingLength(bigUint) === 8)
var buf = bigUintLE.encode(bigUint)
assert(bigUintLE.encode.bytes === 8 && buf.byteLength === 8)

var num = bigUintLE.decode()

API

var buf = bigUintLE.encode(bu, [buf, [byteOffset]])

Write BigInt bu to optional Buffer or TypedArray buf at optional Number byteOffset. If buf is not set a new Buffer is allocated the size of the byte width of bu. byteOffset defaults to 0.

var bytes = bigUintLE.encode.bytes

Number of bytes last encoded

var bigUint = bigUintLE.decode(buf, [byteOffset], [byteLength])

Read BigInt from Buffer or TypedArray buf at optional Number byteOffset for optional Number byteLength bytes. Note that if you do not give a byteLength all of buf will be decoded, since BigInts do not have a natural width.

var bytes = bigUintLE.decode.bytes

Number of bytes last decoded

var bytes = bigUintLE.encodingLength(bu)

Number of bytes required to encode BigInt bu

Install

npm install biguintle

License

ISC

Current Tags

  • 1.0.3                                ...           latest (a year ago)

3 Versions

  • 1.0.3                                ...           a year ago
  • 1.0.1                                ...           3 years ago
  • 1.0.0                                ...           3 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (1)
Dev Dependencies (2)

Copyright 2014 - 2016 © taobao.org |