npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@vekexasia/bigint-buffer2

v1.1.0

Published

Fast BigInt/Buffer conversion with Rust native bindings and JS fallback

Readme

@vekexasia/bigint-buffer2: Fast BigInt/Buffer conversion

This project is part of the bigint-swissknife project. It provides fast BigInt/Buffer conversion with Rust native bindings and a pure JS fallback for browsers.

Why?

The original bigint-buffer library provided a solid foundation for working with BigInts, offering efficient conversion to and from buffers. However, it has several known issues (#40, #59, #22, #12) and lacks browser support.

This library addresses those limitations by providing:

  • Native performance via Rust napi-rs bindings for Node.js
  • Pure JS fallback for browsers and environments without native support
  • Signed BigInt support with two's complement encoding
  • Cross-platform native binaries built via CI (linux-x64, linux-arm64, darwin-x64, darwin-arm64, win32-x64)
  • Drop-in replacement for the original bigint-buffer

Documentation

You can find typedoc documentation here.

Installation

Add the library to your project:

npm install @vekexasia/bigint-buffer2

or

yarn add @vekexasia/bigint-buffer2

Usage

import { toBigIntBE, toBigIntLE, toBufferBE, toBufferLE } from '@vekexasia/bigint-buffer2';

// Buffer to BigInt
const buffer = new Uint8Array([0x01, 0x02, 0x03, 0x04]);
const bigEndian = toBigIntBE(buffer);   // 16909060n
const littleEndian = toBigIntLE(buffer); // 67305985n

// BigInt to Buffer
const be = toBufferBE(16909060n, 4);  // Uint8Array [0x01, 0x02, 0x03, 0x04]
const le = toBufferLE(67305985n, 4);  // Uint8Array [0x01, 0x02, 0x03, 0x04]

Signed BigInt Support

import { toBigIntBESigned, toBigIntLESigned } from '@vekexasia/bigint-buffer2';

const buffer = new Uint8Array([0xff, 0xff]); // -1 in 2 bytes (two's complement)
const signed = toBigIntBESigned(buffer); // -1n

Implementation Detection

import { getImplementation } from '@vekexasia/bigint-buffer2';

console.log(getImplementation()); // 'native' or 'js'

Explicit Implementation Selection

For benchmarking or specific use cases, you can import implementations directly:

// Force JS fallback
import { toBigIntBE } from '@vekexasia/bigint-buffer2/js';

// Force native (Node.js only)
import { toBigIntBE } from '@vekexasia/bigint-buffer2/native';

TypeScript

The library is entirely written in TypeScript and comes with its own type definitions.

Performance

The toBufferInto methods provide 30-40% speedup over the original bigint-buffer library by avoiding buffer allocation:

Speedup Chart

Detailed Comparison

toBufferBE Performance

The green line shows toBufferBEInto which writes directly into a pre-allocated buffer, eliminating allocation overhead.

Run Benchmarks

npm run benchmark

# Generate charts (requires chart.js)
npx tsx scripts/generate-charts.ts

License

This project is licensed under the MIT License - see the LICENSE file for details.