Skip to main content

Built and signed on GitHub Actions

A general-purpose array of bits.

This package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers
This package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Bun
This package works with Browsers
JSR Score
100%
Published
2 months ago (1.1.0)

JSR Deno TypeScript CI License: MIT

BitSet

A general-purpose interface for a byte array to manipulate individual bits.

Example

import { BitSet } from "jsr:@iluha168/bitset";

const bits = new BitSet(new ArrayBuffer(2))

bits.set(2, 1)
bits.set(3, 1)
bits.invert(4)

console.log(`${bits}`)
// Expected output: "BitSet(16) { 0b00011100 00000000 }"

console.log(bits.get(4))
// Expected output: 1

console.log(bits.get(1))
// Expected output: 0

console.log(Array.from(bits).join(''))
// Expected output: 0011100000000000

console.log(Array.from(bits.entries().take(3)))
// Expected output: [ [ 0, 0 ], [ 1, 0 ], [ 2, 1 ] ]
Built and signed on
GitHub Actions
View transparency log

Add Package

deno add jsr:@iluha168/bitset

Import symbol

import * as bitset from "@iluha168/bitset";

---- OR ----

Import directly with a jsr specifier

import * as bitset from "jsr:@iluha168/bitset";

Add Package

npx jsr add @iluha168/bitset

Import symbol

import * as bitset from "@iluha168/bitset";

Add Package

yarn dlx jsr add @iluha168/bitset

Import symbol

import * as bitset from "@iluha168/bitset";

Add Package

pnpm dlx jsr add @iluha168/bitset

Import symbol

import * as bitset from "@iluha168/bitset";

Add Package

bunx jsr add @iluha168/bitset

Import symbol

import * as bitset from "@iluha168/bitset";