Skip to content

checkedArray

function checkedArray<T>(count, what): T[];

Defined in: packages/engine/src/vm/AllocationBudget.ts:173

Check that an array is affordable, then allocate it.

The intended way to build any user-sized array inside the VM whose contents end up inside a Value that charges on birth, so that “ask before you take” is a property of the allocator rather than something each new opcode has to be told.

Type Parameter
T
ParameterTypeDescription
countnumberElement count, checked before a single element exists.
whatstringWhat the elements are, in the plural. See chargeAllocation.

T[]

An empty array of that length.

ALLOCATION_LIMIT_EXCEEDED before allocating anything, when the evaluation cannot afford it.