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

PartitionedBuffer

A high-performance PartitionedBuffer 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/partitionedbuffer for complete documentation.

Installation

Node

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

Deno

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

Bun

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

Usage

deno task example will run a complete example.

// Create a buffer with 1024 bytes and 64 entities (slots) per partition
const buffer = new PartitionedBuffer(1024, 64);

type Vec2 = { x: number, y: number };
const schema: Schema<Vec2> = { x: Float32Array, y: Float32Array };

// Add a partition with a schema
const position = buffer.addPartition({ name: "position", schema });

// Set the first entity's x and y values
position.partitions.x[0] = 1;
position.partitions.y[0] = 2;

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

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

© 2024 The PartitionedBuffer 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/partitionedbuffer

Import symbol

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

---- OR ----

Import directly with a jsr specifier

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

Add Package

npx jsr add @phughesmcr/partitionedbuffer

Import symbol

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

Add Package

yarn dlx jsr add @phughesmcr/partitionedbuffer

Import symbol

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

Add Package

pnpm dlx jsr add @phughesmcr/partitionedbuffer

Import symbol

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

Add Package

bunx jsr add @phughesmcr/partitionedbuffer

Import symbol

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