Skip to content

This site describes solve-engine as it is on main: 2.43.0, which npm does not have yet. npm installs 2.40.0, so a page may show an answer that version does not give yet.

checkedArray

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

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

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.