JSObject.makeTypedArrayWithBytesNoCopy constructor

JSObject.makeTypedArrayWithBytesNoCopy(
  1. JSContext context, {
  2. required JSTypedArrayType arrayType,
  3. required JSTypedArrayBytes bytes,
  4. Pointer<NativeFunction<JSTypedArrayBytesDeallocator>>? bytesDeallocator,
  5. required Pointer<Void> deallocatorContext,
})

Implementation

factory JSObject.makeTypedArrayWithBytesNoCopy(
  JSContext context, {
  required JSTypedArrayType arrayType,
  required JSTypedArrayBytes bytes,
  Pointer<NativeFunction<js_bd.JSTypedArrayBytesDeallocator>>? bytesDeallocator,
  required Pointer<Void> deallocatorContext,
}) {
  final JSException exception = JSException.create(context);
  try {
    final JSObject object = JSObject(
      context,
      js_bd.JSObjectMakeTypedArrayWithBytesNoCopy(
        context.ref,
        JSTypedArrayType.values.indexOf(arrayType),
        bytes.bytes,
        bytes.length,
        bytesDeallocator ?? nullptr,
        deallocatorContext,
        exception.ref,
      ),
    );
    if (exception.shouldThrow) {
      throw exception.error;
    }
    return object;
  } finally {
    exception.release();
  }
}