Skip to main content

Built and signed on GitHub Actions

A Hyper-Performant GC-Minimizing UInt32Array-Backed Pool of Bits in Typescript

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 weeks ago (0.3.2)

BitPool

A high-performance BitPool implementation backed by Uint32Array for efficient memory usage and fast bitwise operations.

MIT License Written in Typescript Deno version Bun version Node version

See jsr.io/@phughesmcr/bitpool for complete documentation.

Installation

Node

npx jsr add @phughesmcr/bitpool
import { BitPool } from "@phughesmcr/bitpool";

Deno

deno add jsr:@phughesmcr/bitpool
import { BitPool } from "@phughesmcr/bitpool";

Bun

bunx jsr add @phughesmcr/bitpool
import { BitPool } from "@phughesmcr/bitpool";

Usage

deno task example will run a complete example.

const pool = new BitPool(1000); // 0 - 999

const entity_1 = pool.acquire();
const entity_2 = pool.acquire();

console.log(pool.isOccupied(entity_1));
console.log(pool.isOccupied(entity_2));
console.log(pool.isOccupied(999));

pool.release(entity_1);
pool.release(entity_2);

console.log(pool.isOccupied(entity_1));
console.log(pool.isOccupied(entity_2));
console.log(pool.isOccupied(999));

Contributing

Contributions are welcome. The aim of the project is performance - both in terms of speed and GC allocation pressure.

Please run deno test and deno task prep to run the tests before committing.

License

BitPool is released under the MIT license. See LICENSE for further details.

© 2024 The BitPool Authors. All rights reserved.

See AUTHORS.md for author details.

Built and signed on
GitHub Actions
View transparency log

Add Package

deno add jsr:@phughesmcr/bitpool

Import symbol

import * as bitpool from "@phughesmcr/bitpool";

---- OR ----

Import directly with a jsr specifier

import * as bitpool from "jsr:@phughesmcr/bitpool";

Add Package

npx jsr add @phughesmcr/bitpool

Import symbol

import * as bitpool from "@phughesmcr/bitpool";

Add Package

yarn dlx jsr add @phughesmcr/bitpool

Import symbol

import * as bitpool from "@phughesmcr/bitpool";

Add Package

pnpm dlx jsr add @phughesmcr/bitpool

Import symbol

import * as bitpool from "@phughesmcr/bitpool";

Add Package

bunx jsr add @phughesmcr/bitpool

Import symbol

import * as bitpool from "@phughesmcr/bitpool";