array()
Function in Runtime
A storage array of the structs of cls that data holds, a Buffer; or, with a typed array, a Buffer of its scalars that keeps it on the device across calls (Amendment A1: array(xs) replaces resident(xs); Amendment A10, Q-I): a Buffer<f32> for a Float32Array or a number[], and so on; or, with a length and an element, a zeroed Buffer of scalars.
import { array } from 'typeshade/runtime'
The signature, the description and the examples come from the compiler's own source at commit af54ddad5.
Syntax
function array<T extends object>( cls: ResourceClass<T, 'set'>, data: readonly Some<T>[],): Buffer<T>;function array<T extends ScalarArray>(value: T): Buffer<ElementOfTyped<T>>;function array(value: readonly number[]): Buffer<number>;function array<E extends ZeroedElement>( length: number, element: E,): Buffer<ZeroedBufferElement<E>>;Parameters
clsResourceClass<T, 'set'>datareadonly Some<T>[]
Return value
Buffer<T>
a Buffer<T>.
Exceptions
TypeErrorTypeErroraszerosdoes, fordatathat is no array, for a value that is not an array (Amendment A11, Q3: writeuniform(Class, init), or pass the value to the call), and for an array that holds anything but numbers (A11, Q4: writearray(Class, data)for structs).
Description
What
it makes belongs to the device in use (using _ = device.use()), or to the default owner when
none is in use (R3): a Buffer of scalars is the one device.array() makes.
In the guide
See also
Source
src/runtime/resource.ts, line 1056, at commit af54ddad5