typedArrayBytes method

Bytes typedArrayBytes()

Returns a temporary pointer to the backing store of a JavaScript Typed Array object. The pointer returned by this function is temporary and is not guaranteed to remain valid across JavaScriptCore API calls. 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

Bytes typedArrayBytes() {
  final JSException exception1 = JSException.create(context);
  final JSException exception2 = JSException.create(context);
  final Pointer<Void> bytes = JSObjectGetTypedArrayBytesPtr(
    context.ref,
    _ref,
    exception1.ref,
  );
  if (exception1.shouldThrow) throw exception1.error;
  final int length = JSObjectGetTypedArrayLength(
    context.ref,
    _ref,
    exception2.ref,
  );
  if (exception2.shouldThrow) throw exception2.error;
  return Bytes(bytes.toUint8List(length), length);
}