JSObject.makeTypedArray constructor
JSObject.makeTypedArray(
- JSContext context, {
- required JSTypedArrayType arrayType,
- required int length,
- bool autoDispose = true,
Creates a JavaScript Typed Array object with the given number of elements.
arrayType
A value JSTypedArrayType identifying the type of array to create. If arrayType is kJSTypedArrayTypeNone or kJSTypedArrayTypeArrayBuffer then NULL will be returned.
length
(size_t) The number of elements to be in the new Typed Array.
exception
(JSValueRef*) A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
Implementation
JSObject.makeTypedArray(
this.context, {
required JSTypedArrayType arrayType,
required int length,
bool autoDispose = true,
}) {
final JSException exception = JSException.create(context);
_ref = JSObjectMakeTypedArray(
context.ref,
JSTypedArrayType.values.indexOf(arrayType),
length,
exception.ref,
);
if (exception.shouldThrow) throw exception.error;
attach(calloc.nativeFree, _ref.cast(), autoDispose: autoDispose);
}