Skip to main content
Home

Built and signed on GitHub Actions

Works with
It is unknown whether this package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers
It is unknown whether this package works with Cloudflare Workers
It is unknown whether this package works with Node.js
It is unknown whether this package works with Deno
It is unknown whether this package works with Bun
It is unknown whether this package works with Browsers
JSR Score88%
Publisheda year ago (0.0.2)
class Bitfield

A bitfield is a simple way of storing multiple boolean values in a single number using binary. Each bit position represents a different boolean flag.

Type Parameters

T extends number = number
  • The type of bit positions, must extend number

Properties

writeonly
value: number
readonly
value: number

Methods

get(bit: T): boolean

Gets the state of a specific bit in the bitfield

set(
bit: T,
state?: boolean,
): Bitfield<T>

Sets the state of a specific bit in the bitfield

Static Methods

fromValue<
X extends number,
T extends Bitfield,
>
(
this: T,
value: number,
): InstanceType<T>

Creates a new bitfield instance with the specified value

See

Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@bronti/bitfield

Import symbol

import { Bitfield } from "@bronti/bitfield";
or

Import directly with a jsr specifier

import { Bitfield } from "jsr:@bronti/bitfield";

Add Package

pnpm i jsr:@bronti/bitfield
or (using pnpm 10.8 or older)
pnpm dlx jsr add @bronti/bitfield

Import symbol

import { Bitfield } from "@bronti/bitfield";

Add Package

yarn add jsr:@bronti/bitfield
or (using Yarn 4.8 or older)
yarn dlx jsr add @bronti/bitfield

Import symbol

import { Bitfield } from "@bronti/bitfield";

Add Package

vlt install jsr:@bronti/bitfield

Import symbol

import { Bitfield } from "@bronti/bitfield";

Add Package

npx jsr add @bronti/bitfield

Import symbol

import { Bitfield } from "@bronti/bitfield";

Add Package

bunx jsr add @bronti/bitfield

Import symbol

import { Bitfield } from "@bronti/bitfield";