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

bitveckit

v0.1.0

Published

Zero-dependency TypeScript BitSet (bit vector). and/or/xor/not, cardinality (popcount), nextSetBit, ranges, serialization. Port of Java BitSet / Python bitarray / C# BitArray.

Readme

bitveckit

All Contributors

Zero-dependency TypeScript BitSet (bit vector). Full bitwise ops, popcount, nextSetBit/previousSetBit, ranges, serialization. Port of Java java.util.BitSet / Python bitarray / C# BitArray.

npm License: MIT

Backed by Uint32Array, auto-grows on demand, O(1) get/set, O(popcount) iteration.

Install

npm install bitveckit

Quick start

import { BitSet } from "bitveckit";

const bs = new BitSet();
bs.set(0).set(5).set(31).set(100);

bs.get(5);           // true
bs.cardinality();    // 4  (popcount)
bs.nextSetBit(1);    // 5
bs.toArray();        // [0, 5, 31, 100]

// Set operations
const a = BitSet.fromArray([1, 3, 5, 7]);
const b = BitSet.fromArray([3, 5, 9]);

a.andWith(b).toArray();    // [3, 5]  — intersection (non-mutating)
a.orWith(b).toArray();     // [1, 3, 5, 7, 9]  — union
a.xorWith(b).toArray();    // [1, 7, 9]  — symmetric difference
a.andNotWith(b).toArray(); // [1, 7]  — set difference (a minus b)

Sieve of Eratosthenes

import { BitSet } from "bitveckit";

const limit = 1_000_000;
const sieve = new BitSet(limit + 1);
sieve.setRange(2, limit + 1);

for (let i = 2; i * i <= limit; i++) {
  if (sieve.get(i)) {
    for (let j = i * i; j <= limit; j += i) sieve.clear(j);
  }
}

// Iterate all primes — O(primes), not O(limit)
for (const prime of sieve) console.log(prime);

Bitwise operations

All mutating ops return this for chaining. All have a non-mutating *With variant that returns a new BitSet.

bs.and(other)    // intersection — in-place
bs.or(other)     // union
bs.xor(other)    // symmetric difference
bs.andNot(other) // set difference (this minus other)
bs.not(length?)  // invert bits [0, length); length defaults to current internal size
bs.flip(index)   // toggle single bit

bs.andWith(other)    // → new BitSet
bs.orWith(other)     // → new BitSet
bs.xorWith(other)    // → new BitSet
bs.andNotWith(other) // → new BitSet

Range operations

bs.setRange(from, to)    // set bits [from, to)
bs.clearRange(from, to)  // clear bits [from, to)
bs.flipRange(from, to)   // toggle bits [from, to)

Searching

bs.nextSetBit(from?)      // next set bit ≥ from, or -1
bs.nextClearBit(from?)    // next clear bit ≥ from
bs.previousSetBit(from)   // previous set bit ≤ from, or -1

Full API

new BitSet(initialCapacityBits?: number)

// Single-bit ops
.set(index, value?: boolean): this
.clear(index?: number): this      // clear one bit, or all if no arg
.flip(index): this
.get(index): boolean

// Range ops
.setRange(from, to): this
.clearRange(from, to): this
.flipRange(from, to): this

// Bitwise (in-place)
.and(other) .or(other) .xor(other) .andNot(other) .not(length?): this

// Bitwise (non-mutating)
.andWith(other) .orWith(other) .xorWith(other) .andNotWith(other): BitSet

// Counting
.cardinality(): number    // popcount — O(words)
.isEmpty(): boolean
.intersects(other): boolean
.length(): number         // highest set bit + 1

// Iteration
.nextSetBit(from?): number
.nextClearBit(from?): number
.previousSetBit(from): number
[Symbol.iterator](): Iterator<number>  // yields set bit indices
.toArray(): number[]

// Equality
.equals(other): boolean
.clone(): BitSet
.compact(): this          // trim trailing zero words

// Serialization
.toHex(): string
.toBinaryString(length?): string
.toString(): string        // "BitSet{1,3,5}"

static fromArray(bits: number[]): BitSet
static fromHex(hex: string): BitSet
static fromBinaryString(s: string): BitSet

Comparison

| | bitveckit | bitset (BitSet.js) | typedfastbitset | |---|---|---|---| | TypeScript-first | ✅ | bundled .d.ts since 2024 | partial | | AND/OR/XOR/NOT | ✅ | AND/OR/XOR/NOT | union/intersect/diff (no NOT) | | nextSetBit / previousSetBit | ✅ | lsb / msb | ❌ | | Range ops | ✅ | slice | ❌ | | fromBinaryString | ✅ | ❌ | ❌ | | Zero deps | ✅ | ✅ | ✅ |

Contributors ✨

This project follows the all-contributors specification. Contributions of any kind are welcome — code, docs, bug reports, ideas, reviews! See the emoji key for how each contribution is recognized, and open a PR or issue to get involved.

Thanks goes to these wonderful people:

License

MIT © trananhtung