A general-purpose interface for a byte array to manipulate individual bits.
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 ] ]
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";