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 🙏

© 2024 – Pkg Stats / Ryan Hefner

extensible-bit-vector

v1.0.7

Published

An extensible bit-vector class for Javascript

Downloads

7

Readme

extensible-bit-vector

An extensible bit-vector implementation for Javascript.

Usage

import BitVector from 'extensible-bit-vector';

const vector = new BitVector(32);
vector.set(2);
vector.set(7);
vector.set(31);

const b1 = vector.get(2);   // true
const b2 = vector.get(3);   // false
const b3 = vector.get(7);   // true

vector.set(42);             // automatically grows bitvector to fit.
vector.clear(2);
vector.clear(3);

const b4 = vector.get(2);   // false
const b5 = vector.get(3);   // false

const str = vector.serialize(); // compressed bitvector in Base64 format
// Store str in db here
const newVector = new BitVector(str);   // re-hydrate bitvector from database.

const b6 = newVector.get(2);    // false
const b7 = newVector.get(31);   // true

You get the idea.

This is a bitvector that only works on Node, not the browser. The reason is that it relies on the Node Buffer class for serialization to and from strings. If you never do any serialization then it will work in the browser, but I don't recommend it.

In memory, the data is stored as a Uint8Array vector, and every 8 bits are stored as each byte. I would have used Uint32Array but it's much easier to convert to and from Base64 using Uint8Array.

The serialization method is designed to produce an optimized storage implementation of the bitvector, using as little memory as possible while still being storable in your average document database. I'm sure there are better ways to optimize the storage, but none are going to be as compatible as this.