Registry / devops / biguint-format

biguint-format

JSON →
library1.0.2jsnpmunverified

An arbitrary length unsigned integer formatter library for Node.js (v1.0.2, last updated 2016). It converts Buffer, byte arrays, or hex strings to decimal, binary, hex, or octal strings without precision loss, unlike JavaScript's native Number.toString(). Features include endianness control, grouping, padding, and prefix options. Only maintained, not actively developed.

npm install biguint-format
INSTALL
IMPORT
SIG · BIGUINT-FORMAT
B
biguint-format
devopsjavascriptv1.0.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

format
import format from 'biguint-format'
const { format } = require('biguint-format')
The module exports a single function via default export in ESM; require returns the function directly, not an object.
format (require)
const format = require('biguint-format')
const { format } = require('biguint-format')
CommonJS require returns the function directly, not an object with a format property.
types
import type { FormatOptions } from 'biguint-format'
TypeScript types are bundled; you can also use JSDoc with @type.

Demonstrates converting byte arrays, hex strings, and Buffers to decimal, binary, and hex with options like grouping, prefix, and endianness.

import format from 'biguint-format'; // From byte array to decimal const dec = format([0x1, 0x23, 0x45, 0x67], 'dec'); console.log(dec); // '19088743' // From hex string to binary with grouping const bin = format('0x1FF', 'bin', { groupsize: 4, delimiter: ' ' }); console.log(bin); // '0001 1111 1111' // From Buffer to hex with uppercase prefix const buf = Buffer.from([0xDE, 0xAD, 0xBE, 0xEF]); const hex = format(buf, 'hex', { prefix: '0x' }); console.log(hex); // '0xDEADBEEF' // Little-endian input const le = format([0xEF, 0xBE, 0xAD, 0xDE], 'hex', { format: 'LE', prefix: '0x' }); console.log(le); // '0xDEADBEEF'
Debug
Known issues
gotchaInput number can be a Buffer, array of bytes, or hex string. Plain numbers are not accepted.
fix
Ensure input is one of the supported types: Buffer, Array<0-255>, or hex string.
affects: >= 0.0.0
gotchaDefault endianness is Big Endian (BE). Little Endian input must be explicitly set with { format: 'LE' }.
fix
Pass options.format: 'LE' when input bytes are in little-endian order.
affects: >= 0.0.0
gotchaThe prefix option is ignored for decimal (dec) format.
fix
Do not use prefix with dec; use hex or bin if prefix is needed.
affects: >= 0.0.0
gotchaThe module uses a synchronous API. Large numbers may cause blocking on the event loop.
fix
Consider offloading to Worker threads or using async alternatives for very large inputs.
affects: >= 0.0.0
gotchatrim: true only works with bin format. It will be ignored for other formats.
fix
Only use trim with format: 'bin'.
affects: >= 0.0.0
Errors
Common errors & fixes
TypeError: number is not a buffer, array or string
Passing a plain number or invalid type as first argument.
fix
Convert the number to a hex string, Buffer, or byte array. For example: format(0x1FF.toString(16), 'dec')
RangeError: invalid array length
Input array contains values outside 0-255 range.
fix
Ensure each byte is an integer between 0 and 255 inclusive.
TypeError: format is not a function
Using destructured require or import incorrectly.
fix
Use 'const format = require('biguint-format')' (CJS) or 'import format from 'biguint-format'' (ESM).
RangeError: The first argument must be of type string or an instance of Buffer, TypedArray, or DataView.
Using new Buffer() deprecated; passing unsupported typed array.
fix
Convert input to Buffer using Buffer.from() or pass as byte array.
Upgrade
Version history
1.0.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
7 hits · last 30 days
node
6
Resources
biguint-format — npm install biguint-format · libregistry