Registry / devops / biguint-format2

biguint-format2

JSON →
library1.0.0jsnpmunverified

An arbitrary length unsigned integer formatter library for Node.js (v1.0.0, stable). Converts Buffer, byte array, or hex string to decimal, binary, hex, or octal without losing precision beyond JavaScript's 53-bit integer limit. Supports endianness, grouping, padding, and prefixes. Lightweight, zero dependencies, actively maintained on GitHub.

npm install biguint-format2
INSTALL
IMPORT
SIG · BIGUINT-FORMAT2
B
biguint-format2
devopsjavascriptv1.0.0
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.

default
import format from 'biguint-format2'
const { format } = require('biguint-format2')
The module exports a single function as default. CommonJS require works as const format = require('biguint-format2').
default
const format = require('biguint-format2')
const format = require('biguint-format2').default
In CommonJS, require returns the function directly; .default is undefined.
default with TypeScript
import format from 'biguint-format2'
import * as format from 'biguint-format2'
TypeScript users should use default import (esModuleInterop or synthetic defaults). Namespace import works but is atypical.

Shows converting a Buffer, hex string, and byte array to decimal/hex with grouping.

const format = require('biguint-format2'); // From Buffer const buf = Buffer.from('1ff0a', 'hex'); console.log(format(buf, 'dec')); // '130826' // From hex string console.log(format('0x1FF', 'dec')); // '511' // From array of bytes const bytes = [0x1, 0x23, 0x45]; console.log(format(bytes, 'hex', { prefix: true })); // '0x12345' // With grouping console.log(format('0x1234567890abcdef', 'hex', { groupsize: 4, delimiter: '_' })); // '0x1234_5678_90ab_cdef'
Debug
Known issues
gotchaInput as hex string must not have leading zeros if using 'hex' format? Actually it's fine.
fix
No issue, but note that hex string is interpreted as big-endian by default.
affects: >=1.0.0
gotchaThe 'prefix' option only works for 'hex', 'bin', 'oct' formats, not 'dec'.
fix
Use prefix only with non-decimal formats.
affects: >=1.0.0
gotchaThe 'trim' option only works with 'bin' format.
fix
Do not set trim for other formats.
affects: >=1.0.0
breakingVersion 1.0.0 is the first stable release; no breaking changes from previous versions because there were none.
fix
No migration needed.
affects: <1.0.0
Errors
Common errors & fixes
TypeError: format is not a function
Importing the module incorrectly, e.g. using named import or destructuring.
fix
const format = require('biguint-format2');  // or import format from 'biguint-format2'
ReferenceError: Buffer is not defined
Trying to use Buffer in a browser environment where biguint-format2 relies on Node's Buffer.
fix
Use array of bytes or hex string instead; or use a polyfill like buffer package.
RangeError: Invalid array length
Passing an array with values outside 0-255.
fix
Ensure all byte values are integers between 0 and 255.
Upgrade
Version history
1.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

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