🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

@nxtedition/slice

Package Overview
Dependencies
Maintainers
12
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nxtedition/slice - npm Package Compare versions

Comparing version
1.1.15
to
2.0.0
+38
-23
lib/index.d.ts
import util from 'node:util';
import type { WithImplicitCoercion } from 'node:buffer';
export type SliceLike = {
export interface SliceLike {
readonly buffer: Buffer;
readonly byteOffset: number;
readonly byteLength: number;
}
declare abstract class BaseSlice implements SliceLike {
abstract readonly buffer: Buffer;
abstract readonly byteOffset: number;
abstract readonly byteLength: number;
get length(): number;
copy(target: Uint8Array | Slice | PoolSlice, targetStart?: number, sourceStart?: number, sourceEnd?: number): number;
compare(target: Uint8Array | Slice | PoolSlice, targetStart?: number, targetEnd?: number, sourceStart?: number, sourceEnd?: number): -1 | 0 | 1;
write(string: string, offset?: number, length?: number, encoding?: BufferEncoding): number;
set(source: Buffer | Slice | PoolSlice | null | undefined, offset?: number): void;
at(index: number): number;
test(expr: {
test: (buffer: Buffer, byteOffset: number, byteLength: number) => boolean;
}): boolean;
toString(encoding?: BufferEncoding, start?: number, end?: number): string;
toBuffer(start?: number, end?: number): Buffer;
get [Symbol.toStringTag](): string;
[util.inspect.custom](): string;
}
export declare class Slice extends BaseSlice implements SliceLike {
buffer: Buffer;
byteOffset: number;
byteLength: number;
};
export declare class Slice implements SliceLike {
buffer: Buffer;
byteOffset: number;
byteLength: number;
maxByteLength: number;
static get EMPTY_BUF(): Buffer;

@@ -19,17 +36,14 @@ static fromBuffer(buffer: Buffer, byteOffset?: number, byteLength?: number): Slice;

static from(string: WithImplicitCoercion<string>, encoding?: BufferEncoding): Slice;
constructor(buffer?: Buffer<ArrayBufferLike>, byteOffset?: number, byteLength?: number, maxByteLength?: number);
static from(arrayOrString: WithImplicitCoercion<ArrayLike<number> | string>): Slice;
constructor(buffer?: Buffer<ArrayBufferLike>, byteOffset?: number, byteLength?: number);
reset(): void;
get length(): number;
copy(target: Uint8Array | Slice, targetStart?: number, sourceStart?: number, sourceEnd?: number): number;
compare(target: Uint8Array | Slice, targetStart?: number, targetEnd?: number, sourceStart?: number, sourceEnd?: number): -1 | 0 | 1;
write(string: string, offset?: number, length?: number, encoding?: BufferEncoding): number;
set(source: Buffer | Slice | null | undefined, offset?: number): void;
at(index: number): number;
test(expr: {
test: (buffer: Buffer, byteOffset: number, byteLength: number) => boolean;
}): boolean;
toString(encoding?: BufferEncoding, start?: number, end?: number): string;
toBuffer(start?: number, end?: number): Buffer;
}
export declare class PoolSlice extends BaseSlice implements SliceLike {
private readonly poolSliceBrand;
readonly buffer: Buffer;
readonly byteOffset: number;
readonly byteLength: number;
readonly maxByteLength: number;
private constructor();
get [Symbol.toStringTag](): string;
[util.inspect.custom](): string;
}

@@ -40,5 +54,5 @@ export declare class PoolAllocator {

get size(): number;
isFromPool(slice: Slice | null | undefined): boolean;
realloc(byteLength: number): Slice;
realloc(slice: Slice, byteLength: number): Slice;
isFromPool(slice: SliceLike | null | undefined): boolean;
realloc(byteLength: number): PoolSlice;
realloc(slice: PoolSlice, byteLength: number): PoolSlice;
get stats(): {

@@ -59,2 +73,3 @@ size: number;

}
export {};
//# sourceMappingURL=index.d.ts.map

@@ -1,1 +0,1 @@

{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAIvD,MAAM,MAAM,SAAS,GAAG;IACtB,MAAM,EAAE,MAAM,CAAA;IACd,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,qBAAa,KAAM,YAAW,SAAS;IACrC,MAAM,EAAE,MAAM,CAAY;IAC1B,UAAU,EAAE,MAAM,CAAI;IACtB,UAAU,EAAE,MAAM,CAAI;IACt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MAAM,0BAAkB,EACxB,UAAU,SAAI,EACd,UAAU,SAAiC,EAM5C;IAED,KAAK,IAAI,IAAI,CAIZ;CACF;AAED,qBAAa,SAAU,SAAQ,SAAU,YAAW,SAAS;IAC3D,iBAAyB,cAAc,CAAM;IAE7C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAY;IACnC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAI;IAC/B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAI;IAC/B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAI;IAElC,OAAO,eAEN;IAED,IAAa,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,MAAM,CAE1C;CACF;AAWD,qBAAa,aAAa;;IAWxB,YACE,iBAAiB,GAAE,MAAM,GAAG,eAAe,GAAG,WAAW,GAAG,iBAAiB,GAAG,MAE1E,EA2CP;IAED,IAAI,IAAI,WAEP;IAED,UAAU,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,CAEvD;IAED,OAAO,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,CAAA;IACtC,OAAO,CAAC,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,GAAG,SAAS,CAAA;IAwJxD,IAAI,KAAK;QAEL,IAAI;QACJ,OAAO;QACP,KAAK;QACL,SAAS;QACT,QAAQ;QACR,QAAQ;QACR,SAAS;QACT,OAAO;;;;;MAMV;CACF"}
import util from 'node:util';
const EMPTY_BUF = Buffer.alloc(0);
export class Slice {
buffer = EMPTY_BUF;
byteOffset = 0;
byteLength = 0;
maxByteLength = 0;
static get EMPTY_BUF() {
return EMPTY_BUF;
}
static fromBuffer(buffer, byteOffset = 0, byteLength = buffer.byteLength - byteOffset) {
if (!(buffer instanceof Buffer)) {
throw new TypeError('buffer must be a Buffer');
}
if (byteOffset < 0 || !Number.isInteger(byteOffset)) {
throw new RangeError(`Invalid byteOffset: ${byteOffset}`);
}
if (byteLength < 0 || !Number.isInteger(byteLength)) {
throw new RangeError(`Invalid byteLength: ${byteLength}`);
}
if (byteOffset + byteLength > buffer.byteLength) {
throw new RangeError(`byteOffset + byteLength (${byteOffset + byteLength}) exceeds buffer size (${buffer.byteLength})`);
}
return new Slice(buffer, byteOffset, byteLength);
}
static fromString(string, encoding) {
return Slice.fromBuffer(Buffer.from(string, encoding));
}
static from(value, offsetOrEncoding, length) {
return Slice.fromBuffer(typeof offsetOrEncoding === 'string'
? Buffer.from(value, offsetOrEncoding)
: Buffer.from(value, offsetOrEncoding, length));
}
constructor(buffer = Slice.EMPTY_BUF, byteOffset = 0, byteLength = buffer.byteLength - byteOffset, maxByteLength = byteLength) {
this.buffer = buffer;
this.byteOffset = byteOffset;
this.byteLength = byteLength;
this.maxByteLength = maxByteLength;
}
reset() {
this.buffer = Slice.EMPTY_BUF;
this.byteOffset = 0;
this.byteLength = 0;
this.maxByteLength = 0;
}
class BaseSlice {
get length() {

@@ -84,3 +42,3 @@ return this.byteLength;

}
if (target instanceof Slice) {
if (target instanceof BaseSlice) {
const targetEnd = target.byteOffset + target.byteLength;

@@ -123,3 +81,3 @@ if (targetStart === undefined) {

const sliceEnd = this.byteOffset + this.byteLength;
if (target instanceof Slice) {
if (target instanceof BaseSlice) {
const targetSliceEnd = target.byteOffset + target.byteLength;

@@ -327,5 +285,73 @@ if (targetStart === undefined) {

const truncated = shown < len ? '…' : '';
return `Slice(${len}): "${str}${truncated}" <${hex}>`;
return `${this[Symbol.toStringTag]}(${len}): "${str}${truncated}" <${hex}>`;
}
}
export class Slice extends BaseSlice {
buffer = EMPTY_BUF;
byteOffset = 0;
byteLength = 0;
static get EMPTY_BUF() {
return EMPTY_BUF;
}
static fromBuffer(buffer, byteOffset = 0, byteLength) {
if (!(buffer instanceof Buffer)) {
throw new TypeError('buffer must be a Buffer');
}
if (byteOffset < 0 || !Number.isInteger(byteOffset)) {
throw new RangeError(`Invalid byteOffset: ${byteOffset}`);
}
if (byteLength === undefined) {
byteLength = buffer.byteLength - byteOffset;
}
if (byteLength < 0 || !Number.isInteger(byteLength)) {
throw new RangeError(`Invalid byteLength: ${byteLength}`);
}
if (byteOffset + byteLength > buffer.byteLength) {
throw new RangeError(`byteOffset + byteLength (${byteOffset + byteLength}) exceeds buffer size (${buffer.byteLength})`);
}
return new Slice(buffer, byteOffset, byteLength);
}
static fromString(string, encoding) {
return Slice.fromBuffer(Buffer.from(string, encoding));
}
static from(value, offsetOrEncoding, length) {
if (Buffer.isBuffer(value)) {
return Slice.fromBuffer(value);
}
if (ArrayBuffer.isView(value)) {
return Slice.fromBuffer(Buffer.from(value.buffer, value.byteOffset, value.byteLength));
}
const buffer = typeof offsetOrEncoding === 'string'
? Buffer.from(value, offsetOrEncoding)
: Buffer.from(value, offsetOrEncoding, length);
return Slice.fromBuffer(buffer);
}
constructor(buffer = Slice.EMPTY_BUF, byteOffset = 0, byteLength = buffer.byteLength - byteOffset) {
super();
this.buffer = buffer;
this.byteOffset = byteOffset;
this.byteLength = byteLength;
}
reset() {
this.buffer = Slice.EMPTY_BUF;
this.byteOffset = 0;
this.byteLength = 0;
}
}
export class PoolSlice extends BaseSlice {
buffer = EMPTY_BUF;
byteOffset = 0;
byteLength = 0;
maxByteLength = 0;
constructor() {
super();
}
get [Symbol.toStringTag]() {
return 'PoolSlice';
}
}
// TypeScript has no friend constructors. Keep construction private in the
// public declaration while giving the allocator a direct, monomorphic `new`
// target with no per-instance ownership field or factory closure.
const InternalPoolSlice = PoolSlice;
export class PoolAllocator {

@@ -357,3 +383,9 @@ #size = 0;

else if (poolTotalOrBuffer instanceof Buffer) {
this.#poolBuffer = poolTotalOrBuffer;
// EMPTY_BUF is also the backing buffer of every empty slice. Reusing that
// singleton as a zero-capacity pool would make those unrelated slices look
// pool-owned and send realloc() through the pool free path. Keep an
// identity-distinct empty backing buffer so a zero-size pool falls back to
// standalone allocations just like PoolAllocator(0).
this.#poolBuffer =
poolTotalOrBuffer === EMPTY_BUF ? Buffer.allocUnsafeSlow(0) : poolTotalOrBuffer;
}

@@ -384,4 +416,5 @@ else if (ArrayBuffer.isView(poolTotalOrBuffer)) {

byteLength = slice;
slice = new Slice();
slice = new InternalPoolSlice();
}
const writableSlice = slice;
if (byteLength == null || !Number.isInteger(byteLength) || byteLength < 0) {

@@ -401,2 +434,8 @@ throw new TypeError(`Invalid byteLength: ${byteLength}`);

const maxByteLength = 1 << dstIdx;
// Prefer moving a heap slice into the pool whenever the destination bucket
// has either a recycled slot or enough uncarved backing-buffer space.
const dstPool = this.#poolsBucket[dstIdx];
const hasRecycledDstSlot = dstPool !== undefined && dstPool.length !== 0;
const canCarveDstSlot = dstPool !== undefined && this.#poolOffset + maxByteLength <= this.#poolBuffer.byteLength;
let replacementBuffer;
if (slice.buffer === this.#poolBuffer) {

@@ -413,3 +452,3 @@ const srcMaxByteLength = slice.maxByteLength;

this.#padding += slice.byteLength - byteLength;
slice.byteLength = byteLength;
writableSlice.byteLength = byteLength;
return slice;

@@ -427,3 +466,3 @@ }

// already at 0 means this slot was never handed out by this allocator
// (double-free through an aliasing Slice, or a slice from another
// (double-free through a forged handle, or a slice from another
// allocator over the same backing buffer) — freeing it would push a

@@ -438,2 +477,11 @@ // duplicate/foreign offset onto the free list and later hand out two

}
// Releasing the source slot before a heap fallback is not exception-safe:
// if Buffer allocation throws, the Slice still points at its old region
// while that same region is already back on the free list. Allocate the
// standalone replacement first. Freeing the source cannot make the
// destination pool-allocatable because same-bucket resizes returned above;
// the released slot therefore belongs to a different bucket.
if (byteLength !== 0 && !hasRecycledDstSlot && !canCarveDstSlot) {
replacementBuffer = Buffer.allocUnsafeSlow(byteLength);
}
this.#size -= srcMaxByteLength;

@@ -445,3 +493,5 @@ this.#padding -= srcMaxByteLength - slice.byteLength;

}
else if (dstIdx >= this.#poolsBucket.length &&
else if (byteLength !== 0 &&
!hasRecycledDstSlot &&
!canCarveDstSlot &&
byteLength <= slice.maxByteLength &&

@@ -452,26 +502,26 @@ slice.maxByteLength <= maxByteLength &&

slice.maxByteLength <= slice.buffer.byteLength - slice.byteOffset) {
// In-place resize of a heap (non-pool) slice. The request is above the
// top pool bucket (so it can never rejoin the pool) and fits the slice's
// existing capacity, so reallocating ~300KB+ of backing store for a size
// change would be pure waste. Retained capacity is bounded by the
// power-of-two ceiling of the request (< 2x), so a shrink from a much
// larger allocation still releases its memory. The byteOffset/window
// checks keep a hand-constructed slice's resize inside its real buffer
// (a negative or fractional byteOffset would inflate the window
// arithmetic) — but they cannot detect a foreign buffer that aliases
// other memory; passing such a slice is documented misuse. Contents are
// incidentally retained but remain undefined per realloc's malloc
// semantics.
slice.byteLength = byteLength;
// The pool cannot serve this destination size, but the request fits this
// heap slice's existing capacity, so replacing its backing store would be
// pure allocation and GC churn. Retained capacity is bounded by
// the power-of-two ceiling of the request (< 2x), so a shrink from a much
// larger allocation still releases its memory. The byteOffset/window checks
// keep a forged JavaScript handle's resize inside its real buffer, but they
// cannot detect a foreign buffer that aliases other memory; passing such a
// handle is unsupported. Contents are incidentally retained but remain
// undefined per realloc's malloc semantics.
writableSlice.byteLength = byteLength;
return slice;
}
if (byteLength === 0) {
slice.reset();
writableSlice.buffer = EMPTY_BUF;
writableSlice.byteOffset = 0;
writableSlice.byteLength = 0;
writableSlice.maxByteLength = 0;
return slice;
}
if (dstIdx < this.#poolsBucket.length && this.#poolsBucket[dstIdx].length) {
slice.buffer = this.#poolBuffer;
slice.byteOffset = this.#poolsBucket[dstIdx].pop();
slice.byteLength = byteLength;
slice.maxByteLength = maxByteLength;
if (hasRecycledDstSlot) {
writableSlice.buffer = this.#poolBuffer;
writableSlice.byteOffset = dstPool.pop();
writableSlice.byteLength = byteLength;
writableSlice.maxByteLength = maxByteLength;
this.#poolsBucketUsed[dstIdx] += 1;

@@ -482,8 +532,7 @@ this.#poolSize += maxByteLength;

}
else if (dstIdx < this.#poolsBucket.length &&
this.#poolOffset + maxByteLength <= this.#poolBuffer.byteLength) {
slice.buffer = this.#poolBuffer;
slice.byteOffset = this.#poolOffset;
slice.byteLength = byteLength;
slice.maxByteLength = maxByteLength;
else if (canCarveDstSlot) {
writableSlice.buffer = this.#poolBuffer;
writableSlice.byteOffset = this.#poolOffset;
writableSlice.byteLength = byteLength;
writableSlice.maxByteLength = maxByteLength;
this.#poolOffset += maxByteLength;

@@ -497,6 +546,6 @@ this.#poolCount += 1;

else {
slice.buffer = Buffer.allocUnsafeSlow(byteLength);
slice.byteOffset = 0;
slice.byteLength = byteLength;
slice.maxByteLength = byteLength;
writableSlice.buffer = replacementBuffer ?? Buffer.allocUnsafeSlow(byteLength);
writableSlice.byteOffset = 0;
writableSlice.byteLength = byteLength;
writableSlice.maxByteLength = byteLength;
}

@@ -503,0 +552,0 @@ return slice;

@@ -1,1 +0,1 @@

{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAA;AAG5B,MAAM,SAAS,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;AAQjC,MAAM,OAAO,KAAK;IAChB,MAAM,GAAW,SAAS,CAAA;IAC1B,UAAU,GAAW,CAAC,CAAA;IACtB,UAAU,GAAW,CAAC,CAAA;IACtB,aAAa,GAAW,CAAC,CAAA;IAEzB,MAAM,KAAK,SAAS;QAClB,OAAO,SAAS,CAAA;IAClB,CAAC;IAED,MAAM,CAAC,UAAU,CACf,MAAc,EACd,UAAU,GAAG,CAAC,EACd,UAAU,GAAG,MAAM,CAAC,UAAU,GAAG,UAAU;QAE3C,IAAI,CAAC,CAAC,MAAM,YAAY,MAAM,CAAC,EAAE,CAAC;YAChC,MAAM,IAAI,SAAS,CAAC,yBAAyB,CAAC,CAAA;QAChD,CAAC;QAED,IAAI,UAAU,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,UAAU,CAAC,EAAE,CAAC;YACpD,MAAM,IAAI,UAAU,CAAC,uBAAuB,UAAU,EAAE,CAAC,CAAA;QAC3D,CAAC;QAED,IAAI,UAAU,GAAG,CAAC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AAY,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;gBAC3C,IAAI,EAAE,IAAI,CAAC,MAAM;gBACjB,IAAI,EAAE,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC;gBAC9B,IAAI,EAAE,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC;aAC7C,CAAC,CAAC;SACJ,CAAA;IACH,CAAC;CACF"}
{
"name": "@nxtedition/slice",
"version": "1.1.15",
"version": "2.0.0",
"type": "module",

@@ -18,5 +18,5 @@ "main": "lib/index.js",

"build": "rimraf lib && tsc -p tsconfig.build.json",
"typecheck": "tsc --noEmit",
"typecheck": "tsc -p tsconfig.json",
"test": "yarn build && node --test",
"test:ci": "yarn build && node --test",
"test:ci": "node --test && tsd",
"test:coverage": "node --test --experimental-test-coverage",

@@ -26,10 +26,8 @@ "test:types": "tsd"

"devDependencies": {
"@types/node": "^25.9.4",
"@types/node": "^26.1.1",
"mitata": "^1.0.34",
"oxlint-tsgolint": "^0.23.0",
"rimraf": "^6.1.3",
"tsd": "^0.33.0",
"typescript": "^5.9.3"
"tsd": "^0.33.0"
},
"gitHead": "44032308de159c06fc694c901a12c35a8bd628ea"
"gitHead": "756528b231bf3618493c73d7aeaf05ed31ac9f05"
}
+67
-35

@@ -13,3 +13,3 @@ # @nxtedition/slice

`PoolAllocator` takes this further. Like Node's internal pool, it has management overhead — but for in-pool sizes it never allocates new backing stores (only allocations larger than the 256 KB top bucket, or made once the contiguous pool is exhausted, fall back to a standalone `Buffer`), and because `Slice` is a plain object rather than a typed array, resizing or freeing a slice doesn't produce garbage for V8 to collect. It pre-allocates a large contiguous buffer and hands out regions using power-of-2 bucketing. When a slice is freed, its slot is recycled. When a slice is resized within the same bucket, no data moves at all — just a field update. This gives you `malloc`/`realloc`/`free` semantics with near-zero overhead per operation. The trade-off is upfront memory allocation and internal fragmentation from power-of-2 rounding — a 10-byte allocation uses a 16-byte slot. Buckets are also independent: a freed 16-byte slot cannot satisfy a 32-byte request, so the pool can become fragmented if allocation sizes are uneven. Use `stats` to monitor pool utilization and tune the pool size for your workload.
`PoolAllocator` takes this further. Like Node's internal pool, it has management overhead — but for in-pool sizes it never allocates new backing stores (only allocations larger than the 256 KB top bucket, or made once the contiguous pool is exhausted, fall back to a standalone `Buffer`). It pre-allocates a large contiguous buffer and hands out regions through lightweight `PoolSlice` handles using power-of-2 bucketing. When a slice is freed, its slot is recycled. When an existing slice is resized within the same bucket, no data moves and no new handle is created — only its allocator-owned metadata changes. This gives you `malloc`/`realloc`/`free` semantics with near-zero overhead per operation. The trade-off is upfront memory allocation and internal fragmentation from power-of-2 rounding — a 10-byte allocation uses a 16-byte slot. Buckets are also independent: a freed 16-byte slot cannot satisfy a 32-byte request, so the pool can become fragmented if allocation sizes are uneven. Use `stats` to monitor pool utilization and tune the pool size for your workload.

@@ -34,5 +34,3 @@ ## Install

const pool = new PoolAllocator()
const s = new Slice()
pool.realloc(s, 64) // allocate 64 bytes from pool
const s = pool.realloc(64) // returns a PoolSlice
s.write('hello')

@@ -46,3 +44,3 @@ pool.realloc(s, 128) // grow — moves to the 128-byte bucket (contents not preserved)

Measured on Apple M3 Pro, Node.js v25.6.1. Every `PoolAllocator` iteration performs a real alloc + free pair (a bare repeated `realloc(slice, N)` would hit the same-size early return and measure a no-op).
The tables are a historical Apple M3 Pro, Node.js v25.6.1 snapshot of the pre-`PoolSlice` implementation, retained for directional context rather than presented as current measurements. The project targets Node.js 26; run `node packages/slice/src/index.bench.ts` from the repository root for current results on your hardware. In the Allocation groups, every `PoolAllocator` iteration performs a real alloc + free pair (a bare repeated `realloc(slice, N)` would hit the same-size early return and measure a no-op).

@@ -66,3 +64,3 @@ ### Allocation (alloc + free per iteration)

Under GC pressure the advantage grows — up to **~21x** — because `PoolAllocator` reuses slots from a pre-allocated buffer and never creates objects for V8 to trace. Speedup is computed against the faster of the two `Buffer` variants.
In that implementation, the GC-pressure advantage reached **~21x** because two-argument `realloc` reused both a pre-allocated slot and its existing handle. The current API preserves that reuse through `PoolAllocator.realloc(existingPoolSlice, size)`; its single-argument form intentionally creates a fresh `PoolSlice`. Historical speedup is computed against the faster of the two `Buffer` variants.

@@ -81,15 +79,29 @@ ### Slice creation vs `Buffer.subarray`

| Operation | `Buffer` | `PoolAllocator` | Speedup |
| ------------------------------------- | --------: | --------------: | ------: |
| new Slice + alloc/free 64 bytes | 25.54 ns | **15.44 ns** | 1.7x |
| new Slice + alloc/free 64 bytes (GC) | 116.92 ns | **61.42 ns** | 1.9x |
| new Slice + alloc/free 256 bytes | 29.62 ns | **15.38 ns** | 1.9x |
| realloc churn (64 → 128 → 64) | 48.76 ns | **17.30 ns** | 2.8x |
| realloc in-place (grow within bucket) | 48.39 ns | **6.84 ns** | 7.1x |
| 10 concurrent allocs then free | 307.90 ns | **176.16 ns** | 1.7x |
| 10 concurrent allocs then free (GC) | 470.07 ns | **372.63 ns** | 1.3x |
| 10 concurrent allocs then free ×2 | 635.30 ns | **345.13 ns** | 1.8x |
| Operation | `Buffer` | `PoolAllocator` | Speedup |
| --------------------------------------- | --------: | --------------: | ------: |
| fresh handle + alloc/free 64 bytes | 25.54 ns | **15.44 ns** | 1.7x |
| fresh handle + alloc/free 64 bytes (GC) | 116.92 ns | **61.42 ns** | 1.9x |
| fresh handle + alloc/free 256 bytes | 29.62 ns | **15.38 ns** | 1.9x |
| realloc churn (64 → 128 → 64) | 48.76 ns | **17.30 ns** | 2.8x |
| realloc in-place (grow within bucket) | 48.39 ns | **6.84 ns** | 7.1x |
| 10 concurrent allocs then free | 307.90 ns | **176.16 ns** | 1.7x |
| 10 concurrent allocs then free (GC) | 470.07 ns | **372.63 ns** | 1.3x |
| 10 concurrent allocs then free ×2 | 635.30 ns | **345.13 ns** | 1.8x |
## API
### `SliceLike`
The shared read-only structural interface implemented by both `Slice` and `PoolSlice`:
```ts
interface SliceLike {
readonly buffer: Buffer
readonly byteOffset: number
readonly byteLength: number
}
```
The interface makes view metadata read-only to generic consumers. It is shallow: callers can still read and write bytes through `buffer`.
### `Slice`

@@ -99,3 +111,3 @@

#### `new Slice(buffer?: Buffer, byteOffset?: number, byteLength?: number, maxByteLength?: number)`
#### `new Slice(buffer?: Buffer, byteOffset?: number, byteLength?: number)`

@@ -108,3 +120,3 @@ Creates a new slice. All parameters are optional — defaults to an empty slice. `byteLength` defaults to the remaining bytes (`buffer.byteLength - byteOffset`), matching `Slice.fromBuffer` and typed-array conventions. The constructor does **no** validation; pass only consistent values, or use `Slice.fromBuffer` for a checked construction.

> **Note:** In earlier versions this method was named `Slice.from`. `Slice.from` now mirrors `Buffer.from` (see below) — migrate zero-copy call sites to `Slice.fromBuffer`.
> **Note:** In earlier versions this method was named `Slice.from`. Use `Slice.fromBuffer` when you need its explicit bounds validation or a byte window within an existing `Buffer`.

@@ -117,10 +129,9 @@ #### `Slice.fromString(string: string, encoding?: BufferEncoding): Slice`

Mirrors `Buffer.from` — always **allocates a fresh `Buffer`** (copying the input) and wraps it. Accepts the same forms as `Buffer.from`: an array/`Uint8Array` of bytes, an `ArrayBuffer`/`SharedArrayBuffer` with optional `byteOffset` and `length`, or a `string` with optional `encoding`. Use `Slice.fromBuffer` instead when you want a zero-copy window over an existing `Buffer`.
Accepts the same input forms as `Buffer.from`, while preserving `Slice`'s view semantics: direct `Buffer`, typed-array, `ArrayBuffer`, and `SharedArrayBuffer` inputs remain zero-copy views of their original byte window. Plain arrays and strings have no backing byte buffer to view, so those forms allocate a new `Buffer`. The `ArrayBuffer` forms accept optional `byteOffset` and `length` arguments.
#### Properties
- `buffer: Buffer` — The underlying `Buffer`
- `byteOffset: number` — Start offset into the buffer
- `byteLength: number` — Current length in bytes
- `maxByteLength: number` — For a pool-allocated slice, the power-of-2 bucket capacity (always `>= byteLength`). For a heap-fallback slice it tracks the allocation's capacity (the high-water `byteLength`), which `realloc` uses to resize large slices in place. For a manually-constructed slice it defaults to `byteLength` and no `Slice` method bounds reads or writes against it (those are validated/clamped against `byteLength`) — but `realloc` treats any non-pool slice's `maxByteLength` as its capacity if such a slice is passed to it.
- `buffer: Buffer` — The underlying `Buffer` (mutable)
- `byteOffset: number` — Start offset into the buffer (mutable)
- `byteLength: number` — Current length in bytes (mutable)
- `length: number` — Alias for `byteLength`

@@ -130,7 +141,7 @@

- `reset(): void` — Clear the slice back to empty state. **Note:** this does not return the slot to the `PoolAllocator`. To free pool memory call `realloc(slice, 0)` — and do **not** `reset()` first: `reset()` detaches the slice from the pool buffer, so a subsequent `realloc(slice, 0)` can no longer locate the slot and the slot leaks.
- `copy(target: Uint8Array | Slice, targetStart?: number, sourceStart?: number, sourceEnd?: number): number` — Copy data to a `Uint8Array`/`Buffer` or `Slice`. Returns bytes copied.
- `compare(target: Uint8Array | Slice, targetStart?: number, targetEnd?: number, sourceStart?: number, sourceEnd?: number): -1 | 0 | 1` — Compare with a `Uint8Array`/`Buffer` or `Slice`
- `reset(): void` — Clear the manually managed slice back to empty state.
- `copy(target: Uint8Array | Slice | PoolSlice, targetStart?: number, sourceStart?: number, sourceEnd?: number): number` — Copy data to a `Uint8Array`/`Buffer`, `Slice`, or `PoolSlice`. Returns bytes copied.
- `compare(target: Uint8Array | Slice | PoolSlice, targetStart?: number, targetEnd?: number, sourceStart?: number, sourceEnd?: number): -1 | 0 | 1` — Compare with a `Uint8Array`/`Buffer`, `Slice`, or `PoolSlice`.
- `write(string: string, offset?: number, length?: number, encoding?: BufferEncoding): number` — Write a string into the slice. Returns bytes written.
- `set(source: Buffer | Slice | null | undefined, offset?: number): void` — Copy from a `Buffer` or `Slice` into this slice. (A plain `Uint8Array` source is not accepted — it has no `copy` method.)
- `set(source: Buffer | Slice | PoolSlice | null | undefined, offset?: number): void` — Copy from a `Buffer`, `Slice`, or `PoolSlice` into this slice. (A plain `Uint8Array` source is not accepted — it has no `copy` method.)
- `at(index: number): number` — Read byte at integer index (supports negative indexing)

@@ -143,3 +154,3 @@ - `test(expr: { test(buffer: Buffer, byteOffset: number, byteLength: number): boolean }): boolean` — Test the slice against an expression object

All offsets are **relative to the slice** (i.e. `0` is `byteOffset`). For a `Slice` target, target offsets are relative to that slice; for a raw `Buffer`/`Uint8Array` target they are absolute (passed straight through to the underlying `Buffer` method).
All offsets are **relative to the slice** (i.e. `0` is `byteOffset`). For a `Slice` or `PoolSlice` target, target offsets are relative to that slice; for a raw `Buffer`/`Uint8Array` target they are absolute (passed straight through to the underlying `Buffer` method).

@@ -151,3 +162,3 @@ The rule is consistent across the API:

- **`write`'s `length` is hybrid** — a negative or non-integer `length` throws `RangeError`, but a too-large `length` is clamped to the bytes available in the slice (it behaves like an end argument, not a strict start argument).
- For a raw `Buffer`/`Uint8Array` target, `targetStart`/`targetEnd` (and a non-`Slice` `compare` target's range) are passed straight through to the underlying `Buffer` method, so they follow `Buffer`'s own coercion/validation rather than the rules above.
- For a raw `Buffer`/`Uint8Array` target, `targetStart`/`targetEnd` (and a raw `compare` target's range) are passed straight through to the underlying `Buffer` method, so they follow `Buffer`'s own coercion/validation rather than the rules above.

@@ -158,5 +169,26 @@ #### Static

### `PoolSlice`
The allocator-owned sibling of `Slice`. `PoolAllocator.realloc(byteLength)` creates it; callers resize or free the same handle by passing it back to the allocator. It provides the same buffer-view methods as `Slice`, but deliberately has no `reset()` method. It is a separate class, so an allocated handle is a `PoolSlice`, not an `instanceof Slice`.
#### Properties
- `readonly buffer: Buffer` — The current backing buffer
- `readonly byteOffset: number` — Start offset into the buffer
- `readonly byteLength: number` — Current logical length
- `readonly maxByteLength: number` — Allocator capacity: the power-of-2 bucket size for a pool allocation, or retained capacity for a heap fallback
- `length: number` — Alias for `byteLength`
Only `PoolAllocator` changes these four metadata properties. The read-only fields and private constructor enforce that contract in TypeScript without adding per-instance ownership fields or runtime guards. They are intentionally shallow and compile-time-only: buffer bytes remain writable, and constructing or mutating a `PoolSlice` from plain JavaScript is unsupported.
This is a breaking allocator-handle change. To migrate:
- Replace `const slice = new Slice(); pool.realloc(slice, size)` with `const slice = pool.realloc(size)`.
- Change stored allocator-handle and parameter types from `Slice` to `PoolSlice`.
- Use `SliceLike` when code only needs a shared read-only view of either class.
- Remove manual `Slice.maxByteLength` usage; capacity exists only on `PoolSlice`.
### `PoolAllocator`
Pre-allocates a contiguous memory pool and manages slices using power-of-2 bucketing.
Pre-allocates a contiguous memory pool and manages `PoolSlice` handles using power-of-2 bucketing.

@@ -167,11 +199,11 @@ #### `new PoolAllocator(poolTotalOrBuffer?: number | Buffer | ArrayBufferView | ArrayBuffer | SharedArrayBuffer)`

> **Single-owner.** The allocator's bookkeeping lives in the instance, not in the backing buffer. When you supply your own buffer, that buffer must be owned exclusively by this allocator: do not build your own `Slice` views over it, do not share it with a second `PoolAllocator`, and (for a `SharedArrayBuffer`) do not allocate from more than one thread — the metadata is not shared or atomic, so doing any of these silently produces overlapping allocations.
> **Single-owner.** The allocator's bookkeeping lives in the instance, not in the backing buffer. When you supply your own buffer, that buffer must be owned exclusively by this allocator: do not share it with a second `PoolAllocator`, and (for a `SharedArrayBuffer`) do not allocate from more than one thread — the metadata is not shared or atomic, so doing either can produce overlapping allocations.
#### Methods
- `realloc(byteLength: number): Slice` — Allocate a fresh slice.
- `realloc(slice: Slice, byteLength: number): Slice` — Resize a slice, or free it by passing `0`. **Contents are not preserved** — `realloc` has `malloc` semantics, not C `realloc` semantics; after a resize the bytes are undefined (a same-bucket or in-place resize happens to keep them in place, but do not rely on it). Only call `realloc` with a slice that belongs to this allocator (or a fresh/empty `Slice`); passing a slice from another pool over the same backing buffer, or freeing the same pool slot through two aliasing `Slice` objects, throws `Invalid pool state` when the corruption is detectable (a bucket's live count would go negative) — but do not rely on detection: an aliasing free while other slices remain live in the same bucket silently corrupts the accounting. (Calling `realloc(slice, 0)` twice on the _same_ object is a harmless no-op — the first free empties the slice, so the second returns immediately.)
- `isFromPool(slice: Slice | null | undefined): boolean` — Check if a slice's buffer is this pool's backing buffer. Note this is an identity check; it returns `true` for any slice over the same buffer, not only ones this allocator handed out.
- `realloc(byteLength: number): PoolSlice` — Allocate and return a fresh allocator-owned handle.
- `realloc(slice: PoolSlice, byteLength: number): PoolSlice` — Resize a handle returned by this allocator, or free it by passing `0`. **Contents are not preserved** — `realloc` has `malloc` semantics, not C `realloc` semantics; after a resize the bytes are undefined (a same-bucket or in-place resize happens to keep them in place, but do not rely on it). Do not pass a handle from another allocator. Calling `realloc(slice, 0)` twice on the same object is a harmless no-op.
- `isFromPool(slice: SliceLike | null | undefined): boolean` — Check whether a slice-like view's buffer is this pool's backing buffer. This is an identity check, not an ownership proof.
Allocations larger than 256 KB (the largest bucket), or made when the contiguous pool is exhausted, fall back to a fresh standalone `Buffer` (`isFromPool` returns `false`) and are excluded from `size`/`stats`. Resizing such a slice while the request stays above 256 KB reuses the existing backing store in place when it fits — capacity is retained up to the power-of-2 ceiling of the request (< 2× waste), so size churn **within the retained capacity** does not reallocate (churn spanning a wider than 2× band still reallocates); shrinking below that bound, or to a pool-eligible size, allocates anew (rejoining the pool when possible). Note the in-place path keeps whatever backing buffer the slice already has — including a hand-constructed one — so do not use `realloc` to detach a slice from caller-shared memory.
Allocations larger than 256 KB (the largest bucket), or made when the contiguous pool is exhausted, fall back to a fresh standalone `Buffer` (`isFromPool` returns `false`) and are excluded from `size`/`stats`. Resizing a standalone `PoolSlice` reuses its existing backing store when the request fits and no destination pool slot is available. Capacity is retained only up to the power-of-2 ceiling of the request (< 2× waste), so size churn **within retained capacity** does not reallocate; a wider shrink releases the oversized buffer. A free or uncarved destination pool slot takes priority, so an eligible standalone slice rejoins the pool when space becomes available.

@@ -178,0 +210,0 @@ #### Properties