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

bitconcat

v0.3.1

Published

Binary streams

Readme

bitconcat

A simple Javascript library to append and prepend up to 25 bits at a time to a bitstream. It will group bits together into bytes whenever possible. Useful for compression and stream algorithms. More documentation and a lot of information about this project is available here.

Installation

Node

npm install bitconcat

Browser

bower install bitconcat

or

<script src="bitconcat.min.js" type="text/javascript"></script>

Usage

Begin by creating an instance of bitconcat.

// If Node
var bitconcat = require("bitconcat");

var bc = new bitconcat();

That instance can now be thought of as the efficient, mathematical equivalent of a string containing ones and zeroes.

Now append or prepend data to it:

bc.append(9, 4); //1001

That appends 1001 to the stream. That's 4 bits, repesenting the number 9 in binary. Our string would be "1001".

bc.prepend(15, 4); //1111

Now the instance contains 11111001, which is enough to form a full byte. getData() is used to retrieve all the available full bytes.

bc.getData(); //Returns [249]

Calling pad() will append just enough zeroes to create an additional full byte, only if there's a number of bits not divisible by 8.

getNbBits() returns the number of bits in the instance.

Note: Due to Javascript's limitations, it is not possible to append or prepend more than 25 bits at a time without losing data. Call prepend() and append() multiple times instead.

Note: For optimal performance, when prepending bits, only call getData() once after prepending everything. Basically, do not alternate between calling prepend() and getData().

Example

bc = new bitconcat();
bc.append(46, 6);   //Appends 101110
bc.append(5, 4);    //Appends 0101
bc.append(0, 4);    //Appends 0000
bc.append(819, 10); //Appends 1100110011

The instance now contains 24 bits (6+4+4+10). Calling getData() will return an array containing 3 bytes.

bc.getData(); //Returns [185, 67, 51]

// 10111001 01000011 00110011
// 185      67       51

A lot more examples and documentation is available here.