napi_create_typedarray

Function napi_create_typedarray 

Source
pub unsafe extern "C" fn napi_create_typedarray(
    env: napi_env,
    type_: napi_typedarray_type,
    length: usize,
    arraybuffer: napi_value,
    byte_offset: usize,
    result: *mut napi_value,
) -> napi_status
Available on crate feature napi only.
Expand description

Creates an ArkTS TypeArray from an existing ArrayBuffer.

§Arguments

  • env - Current running virtual machine context.

  • type - The element datatype of the TypedArray.

  • length - Number of elements in the TypedArray.

  • arraybuffer - The underlying ArrayBuffer that supports the TypedArray.

  • byte_offset - The byte offset within the ArrayBuffer from which to start projecting the TypedArray.

  • result - A napi_value representing an ArkTS TypedArray.

§Returns

  • Returns the function execution status. [napi_ok] If the function executed successfully.

[napi_invalid_arg] If the param env, arraybuffer and(or) result is nullptr;

If param type is not a valid napi_typedarray_type.

[napi_arraybuffer_expected] If a non-arraybuffer ArkTS value passed in it.

[napi_pending_exception] There is an uncaught exception occurred before(in) execution.

Available since API-level: 10