Skip to main content

Built and signed on GitHub Actions

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

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 (0.2.8)
class PartitionedBuffer
extends ArrayBuffer

A PartitionedBuffer is an ArrayBuffer with named storage partitions.

Constructors

new
PartitionedBuffer(
size: number,
maxEntitiesPerPartition?: number,
)

Create a new PartitionedBuffer

Properties

The length of each row in the buffer

Methods

addPartition<T extends SchemaSpec<T> | null = null>(partition: Partition<T>): PartitionStorage<T>

Add a partition to the buffer

clear(): this

Clear the buffer and release references

The amount of free space in bytes in the underlying ArrayBuffer

Get the current offset into the underlying ArrayBuffer

getPartition<T extends SchemaSpec<T> | null = null>(key: Partition<T> | string): PartitionStorage<T> | undefined

Get a partition by name or spec

hasPartition<T extends SchemaSpec<T> | null = null>(key: PartitionSpec<T> | string): boolean

Check if a partition exists

Static Properties

readonly
MAX_PARTITION_SIZE: 1073741824

Maximum safe partition size to prevent allocation errors

readonly
MIN_ALIGNMENT: 8

Minimum alignment in bytes for TypedArrays

Add Package

deno add jsr:@phughesmcr/partitionedbuffer

Import symbol

import { PartitionedBuffer } from "@phughesmcr/partitionedbuffer";

---- OR ----

Import directly with a jsr specifier

import { PartitionedBuffer } from "jsr:@phughesmcr/partitionedbuffer";

Add Package

npx jsr add @phughesmcr/partitionedbuffer

Import symbol

import { PartitionedBuffer } from "@phughesmcr/partitionedbuffer";

Add Package

yarn dlx jsr add @phughesmcr/partitionedbuffer

Import symbol

import { PartitionedBuffer } from "@phughesmcr/partitionedbuffer";

Add Package

pnpm dlx jsr add @phughesmcr/partitionedbuffer

Import symbol

import { PartitionedBuffer } from "@phughesmcr/partitionedbuffer";

Add Package

bunx jsr add @phughesmcr/partitionedbuffer

Import symbol

import { PartitionedBuffer } from "@phughesmcr/partitionedbuffer";