Skip to content

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

License

Notifications You must be signed in to change notification settings

iluha168/jsr-bitset

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 ] ]

About

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

Topics

Resources

License

Stars

Watchers

Forks