Scan your whole stack
Are you using balloc?
Find out what’s in your code.
Scan your apps free in minutes (opens in a new tab)Latest version: v2.0.0
balloc was last scanned on 29 Nov 2026 at version 2.0.0. Risk score 0 of 100. No malicious behavior was detected.
| Version | Published | Status |
|---|---|---|
| 2.0.0 LATEST | 29 Nov 2026 | No rules fired |
| 1.4.0 | 25 Nov 2026 | No rules fired |
| 1.3.1 | 20 Nov 2026 | No rules fired |
| 1.3.0 | 19 Nov 2026 | Not shown |
| 1.0.1 | 18 Oct 2026 | Not shown |
Findings for v2.0.0. The score is a capped sum of the weights of the rules that fired — not CVSS, not exploitability, and not a probability. It is not comparable across packages with different scan coverage.
The score describes 2.0.0; other versions have their own rules, not their own score.
The publisher’s own README, as collected from the registry.
Balloc is a typed memory-block allocator for JavaScript. It stores each allocation in its own ArrayBuffer, exposes blocks through numeric handles, and tracks the number of occupied elements separately from physical capacity.
Version: 2.0.0
Balloc 2.0.0 is an architectural redesign and is not backward-compatible with the 1.x series. It is not a drop-in upgrade. Applications written for 1.x must be reviewed and adapted before upgrading.
The memory-management model has changed fundamentally:
| Version 1.x | Version 2.0.0 |
|---|---|
| Shared heap managed by the allocator. | Each allocation owns an independent ArrayBuffer. |
| Bump allocation and region-oriented memory management. | Independent blocks addressed by numeric handles. |
| Allocation metadata and heap-oriented operations. | Per-block typed-array capacity and logical occupancy. |
| Region recycling and heap compaction/garbage-collection workflows. | Explicit block lifecycle through alloc(), realloc(), shrink(), and free(). |
The public programming model has changed along with the storage architecture. Do not assume that 1.x methods, internal structures, handles, allocation assumptions, or existing application code map directly to the 2.0.0 API. In particular, code coupled to the former shared heap, metadata, allocation regions, recycling, or compaction must be redesigned around independent blocks and the 2.0.0 public API.
Upgrade guidance: treat the move from 1.x to 2.0.0 as a major migration. Review all Balloc integration points and adapt allocation, access, lifetime, and serialization logic to the 2.0.0 contracts before deploying. A package-version change alone is not a sufficient migration.
See the Balloc 1.x to 2.0.0 migration guide before upgrading an existing application.
TypedArray instances.realloc() and shrink().withView().loadData().Each block owns an independent ArrayBuffer. Balloc does not use a shared bump-allocation heap, region recycling, or a heap-compaction routine.
Node.js:
npm install balloc
Bun:
bun add balloc
Deno:
deno add npm:balloc
Yarn:
yarn add balloc
import Balloc from "balloc";
const memory = new Balloc();
const { Balloc } = require("balloc");
const memory = new Balloc();
The package provides a browser bundle through the package CDN entry:
<script src="https://unpkg.com/balloc"></script>
The bundle exposes the allocator as window.Balloc.
The constructor accepts a maximum allocation size in bytes and an optional default element type.
import Balloc from "balloc";
const memory = new Balloc();
const handler = memory.alloc(64, "32u");
memory.push(handler, 10);
memory.push(handler, 20);
memory.push(handler, 30);
console.log(memory.occupied(handler)); // 3
console.log(memory.length(handler)); // 16
console.log(memory.pick(handler)); // Uint32Array [10, 20, 30]
memory.free(handler);
The alloc() size is expressed in bytes. The resulting typed array contains as many elements as fit in that buffer. The default allocation size is 16 bytes and the default element type is 32u.
new Balloc(maxByteSize, bucketSize)
| Parameter | Type | Default | Description |
|---|---|---|---|
maxByteSize |
number |
0x80000000 |
Upper bound used to validate allocation sizes, in bytes. |
bucketSize |
`BucketType | null` | null |
maxByteSize must be a safe integer in the range [2, 0x80000000].
The element type uses the format [bit width][type]:
| Signed integer | Unsigned integer | Floating point |
|---|---|---|
8i |
8u |
— |
16i |
16u |
16f |
32i |
32u |
32f |
64i |
64u |
64f |
These identifiers map to the corresponding JavaScript typed arrays: Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array, BigInt64Array, BigUint64Array, Float16Array, Float32Array, and Float64Array.
The runtime must provide the corresponding typed-array constructor for the selected type. The 64-bit integer types use bigint values.
const handler = memory.alloc(size, bucketType);
| Argument | Type | Default | Description |
|---|---|---|---|
size |
number |
16 |
Allocation size in bytes. Must be aligned to the selected element width. |
bucketType |
BucketType |
"32u" |
Element type used by the block, unless the constructor defines a default type. |
Each successful allocation receives a new numeric handle. Handles increase monotonically and are not reused after free().
Balloc distinguishes physical capacity from logical occupancy:
| Method | Meaning |
|---|---|
length(handler) |
Physical capacity in elements. |
occupied(handler) |
Number of occupied elements. |
byteSize(handler) |
Physical capacity in bytes. |
isFull(handler) |
Whether occupancy equals physical capacity. |
An allocation can have unused capacity. Operations that add elements update occupancy; reading or replacing an existing element does not.
| Method | Description |
|---|---|
realloc(handler, newSize) |
Replaces the block storage with a larger buffer. newSize is expressed in elements; when omitted, capacity doubles. |
shrink(handler) |
Replaces the buffer with the smallest power-of-two capacity that can hold the occupied elements, with a minimum of two elements. If that capacity is not smaller than the current capacity, no change is made. |
free(handler) |
Removes the block and invalidates its handle. |
Resizing copies the occupied elements to the new buffer. A block cannot be resized or freed while it is borrowed by withView().
| Method | Description |
|---|---|
push(handler, value) |
Adds an element at the end. Returns false if the block is full. |
pop(handler) |
Removes and returns the last occupied element. Returns undefined when empty. |
peek(handler) |
Reads the last occupied element without removing it. |
| Method | Description |
|---|---|
nudge(handler, value) |
Inserts an element at the beginning, shifting occupied elements toward the end. Returns false if full. |
pull(handler) |
Removes and returns the first element, shifting the remaining occupied elements toward the beginning. |
head(handler) |
Reads the first slot without changing occupancy. |
| Method | Description |
|---|---|
get(handler, index) |
Reads an occupied element. Returns undefined for an index outside the occupied range. |
set(handler, index, value) |
Replaces an occupied element. Returns false when the index is outside the occupied range. |
has(handler, value) |
Checks whether a value occurs in the occupied range. |
indexOf(handler, value, fromIndex) |
Finds the first occurrence. |
lastIndexOf(handler, value, fromIndex) |
Finds the last occurrence. |
| Method | Description |
|---|---|
clear(handler, value = 0) |
Fills the entire block and resets occupancy to zero. |
fill(handler, value, start, end) |
Fills the specified range and updates occupancy to include its end. |
fillAll(handler, value) |
Fills every slot and marks the entire block as occupied. |
put(handler, data) |
Copies an Array or TypedArray to the beginning of the block, up to its capacity. |
pick(handler) |
Returns a copy of the occupied elements as a typed array. |
| Method | Description |
|---|---|
copy(source, destination, slots) |
Copies occupied elements from one block to another, up to the destination capacity and optional slot limit. |
copyWithin(handler, target, start, length) |
Copies a range within the same block, supporting overlapping regions. |
append(target, source) |
Appends as many occupied source elements as fit in the target block. Returns the number appended. |
clone(handler) |
Creates an independent block containing a copy of the source block. |
swap(source, target) |
Swaps the block objects associated with two handles without changing the handles. |
loadData(adapter) delegates synchronous ingestion to an adapter with a load(allocator) method. The adapter receives the current Balloc instance, performs its allocations through the public API, and its return value is passed through unchanged.
const handler = memory.loadData({
load(allocator) {
const block = allocator.alloc(4, "8u");
allocator.put(block, new Uint8Array([255, 0, 0, 255]));
return block;
}
});
Balloc does not manage adapter transactions. If an adapter creates multiple blocks and a later operation fails, cleanup of those allocations is the adapter's responsibility.
withView() provides synchronous, zero-copy access to the occupied elements of one or more blocks. The callback receives typed-array subviews that share the blocks' storage.
memory.withView(handler, view => {
view[0] = 42;
view[1] = 84;
});
Multiple blocks can be borrowed in one call. The callback receives one view per handle, in argument order:
memory.withView(source, target, (sourceView, targetView) => {
targetView.set(sourceView.subarray(0, targetView.length));
});
Borrowing is scoped to the synchronous callback. Balloc releases the borrow in a finally block, including when the callback throws. Do not retain, return, or use a borrowed view after the callback finishes. An asynchronous callback does not extend the borrow until its promise settles.
Operations that could invalidate or structurally modify a borrowed block are rejected while the callback is running.
dump(handler) serializes a block into a CBOR version 2 envelope. The envelope stores the bucket type, capacity, occupancy, and occupied payload.
load(serialized) accepts an ArrayBuffer or Uint8Array, validates the envelope, and creates a new block. If the allocator was constructed with a fixed bucketSize, the serialized block must use the same type.
const encoded = memory.dump(handler);
const restoredHandler = memory.load(encoded);
The TypeScript declarations are available at types/en/balloc.d.mts. The implementation is available at src/en/balloc.mjs.
If you like this project and want to support its development:
| Pix QR Code | Copy-and-Paste / Random Key |
|---|---|
![]() |
Random Key: e87d773a-0b97-4410-8fc3-f7ec04cce6a2 |
MIT
Find threats in your stack.
OX Radar can check high-priority threats, like critical package CVEs, against your context.
Each incident is marked Detected or Not Detected with a remediation plan and proof all tracked in the Response Center.
The probe returned only these fields for this server — auth requirement, protocol and tool list weren’t observed, so they’re not shown (never guessed).
The publisher’s own links, as the registry reports them. These are not sources for the assessment on this page.