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

bitwise-array

v0.1.14

Published

Class that represents immutable bitwise array

Readme

JavaScript Bitwise Array Class

The Immutable Class supports operations:

  • getting, setting, unsetting and toggling of individual bits
  • bitwise operations with other bitwise array such as OR, XOR and AND
  • counting the number of "on" bits
  • comparison of two bitwise arrays
  • clearing or inverting all bits of bitwise array
  • selecting of items of an ordinary array based on the "on" bits of the bitwise array

Usage

Install

If you're using Node.js type:

npm install --save bitwise-array

or

yarn add bitwise-array

Require

const { default: BitwiseArray, createBitwiseArray } = require('bitwise-array');

or

import BitwiseArray, { createBitwiseArray } from 'bitwise-array';

Instantiate a Class

const a = createBitwiseArray(5); // with length of array
a.toString(); // '00000'

const b = createBitwiseArray('010011'); // with '0s & 1s" string
b.toString(); // '010011'

const c = createBitwiseArray(b); // with another bitwise array
c.toString(); // '010011'

const colors = ['RED', 'ORANGE', 'YELLOW', 'GREEN', 'BLUE', 'INDIGO', 'VIOLET'];
const selectedColors = ['GREEN', 'INDIGO', 'ORANGE'];
// with 1st arg: all items array, 2nd arg: selected items array
const d = createBitwiseArray(colors, selectedColors);
d.toString(); // '0101010'

or

const a = new BitwiseArray(5); // with length of array
a.toString(); // '00000'

const b = new BitwiseArray('010011'); // with '0s & 1s" string
b.toString(); // '010011'

const c = new BitwiseArray(b); // with another bitwise array
c.toString(); // '01000'

const colors = ['RED', 'ORANGE', 'YELLOW', 'GREEN', 'BLUE', 'INDIGO', 'VIOLET'];
const selectedColors = ['GREEN', 'INDIGO', 'ORANGE'];
// with 1st arg: all items array, 2nd arg: selected items array
const d = new BitwiseArray(colors, selectedColors);
d.toString(); // '0101010'

API

Property

length: number

Example:

const colors = ['RED', 'ORANGE', 'YELLOW', 'GREEN', 'BLUE', 'INDIGO', 'VIOLET'];
const selectedColors = ['GREEN', 'INDIGO', 'ORANGE'];
const a = createBitwiseArray(colors, selectedColors);
a.length; // 7

Methods

toString(radix?: 35): string

Example:

const a = createBitwiseArray(35);
a.toString(); // '00000000000000000000000000000000000'
a.toString(32); // '0'

const b = createBitwiseArray('00000000000000000000000000000000001');
b.toString(); // '00000000000000000000000000000000001'
b.toString(32); // '1'

const c = createBitwiseArray('00000000000000000000000000000001001');
c.toString(); // '00000000000000000000000000000001001'
c.toString(32); // '9'

const d = createBitwiseArray('00000000000000000000100000000001001');
d.toString(); // '00000000000000000000100000000001001'
d.toString(32); // 'g09'

const e = createBitwiseArray('00000010000000000000100000000001001');
e.toString(); // '00000010000000000000100000000001001'
e.toString(32); // '800g09'

set(pos: number): BitwiseArray

Example:

const a = createBitwiseArray(35);
a.toString(); // '00000000000000000000000000000000000'

a.set(0).toString(); // '10000000000000000000000000000000000'

a.set(0).set(34).toString(); // '10000000000000000000000000000000001'

a.set(0).set(34).set(4).toString(); // '10001000000000000000000000000000001'

toggle(pos: number): BitwiseArray

Example:

const a = createBitwiseArray(35);
a.toString(); // '00000000000000000000000000000000000'

a.toggle(0).toString(); // '10000000000000000000000000000000000'

a.toggle(0).toggle(0).toString(); // '00000000000000000000000000000000000'

a.toggle(0).toggle(0).toggle(0).toString(); // '10000000000000000000000000000000000'

get(pos: number): boolean

Example:

const a = createBitwiseArray('10100');
a.toString(); // '10100'

a.get(0); // true
a.get(1); // false
a.get(2); // true
a.get(3); // false
a.get(4); // false

clear(): BitwiseArray

Example:

const a = createBitwiseArray('11101');
a.toString(); // '11101'

a.clear().toString(); // '00000'

invert(): BitwiseArray

Example:

const a = createBitwiseArray('10010');
a.toString(); // '10010'

a.invert().toString(); // '01101'

and(secondBitwiseArray: BitwiseArray): BitwiseArray

Example:

const a = createBitwiseArray(5);
a.toString(); // '00000'

const b = a.set(0).set(2);
b.toString(); // '10100'

const c = a.set(2).set(4);
c.toString(); // '00101'

b.and(c).toString(); // '00100'

or(secondBitwiseArray: BitwiseArray): BitwiseArray

Example:

const a = createBitwiseArray(5);
a.toString(); // '00000'

const b = a.set(0).set(2);
b.toString(); // '10100'

const c = a.set(2).set(4);
c.toString(); // '00101'

b.or(c).toString(); // '10101'

xor(secondBitwiseArray: BitwiseArray): BitwiseArray

Example:

const a = createBitwiseArray(5);
a.toString(); // '00000'

const b = a.set(0).set(2);
b.toString(); // '10100'

const c = a.set(2).set(4);
c.toString(); // '00101'

b.xor(c).toString(); // '10001'

isEqual(secondBitwiseArray: BitwiseArray): boolean

Example:

const a = createBitwiseArray('10100');
a.toString(); // '10100'

const b = createBitwiseArray('10100');
b.toString(); // '10100'

a.isEqual(b); // true

const c = createBitwiseArray('10110');
c.toString(); // '10110'

a.isEqual(c); // false

select(arr: Array): Array

Example:

const a = createBitwiseArray(7);
a.set(1).set(3).set(5);
a.toString(); // '0101010'
const colors = ['RED', 'ORANGE', 'YELLOW', 'GREEN', 'BLUE', 'INDIGO', 'VIOLET'];

a.select(colors); // ['ORANGE', 'GREEN', 'INDIGO'];