TypedArray
May 24, 2026 ยท View on GitHub
Class Napi::TypedArray inherits from class Napi::Object.
The Napi::TypedArray class corresponds to the
JavaScript TypedArray
class.
Methods
Constructor
Initializes an empty instance of the Napi::TypedArray class.
Napi::TypedArray::TypedArray();
Constructor
Initializes a wrapper instance of an existing Napi::TypedArray instance.
Napi::TypedArray::TypedArray(napi_env env, napi_value value);
[in] env: The environment in which to create theNapi::TypedArrayinstance.[in] value: TheNapi::TypedArrayreference to wrap.
TypedArrayType
napi_typedarray_type Napi::TypedArray::TypedArrayType() const;
Returns the type of this instance.
ArrayBuffer
Napi::ArrayBuffer Napi::TypedArray::ArrayBuffer() const;
Returns the backing array buffer.
NOTE: If the Napi::TypedArray is not backed by an Napi::ArrayBuffer,
this method will terminate the process with a fatal error when using
NODE_ADDON_API_ENABLE_TYPE_CHECK_ON_AS or exhibit undefined behavior
otherwise. Use Buffer() instead to get the backing buffer without assuming its
type.
Buffer
Napi::Value Napi::TypedArray::Buffer() const;
Returns the backing array buffer as a generic Napi::Value, allowing optional
type-checking with Is*() and type-casting with As<>() methods.
ElementSize
uint8_t Napi::TypedArray::ElementSize() const;
Returns the size of one element, in bytes.
ElementLength
size_t Napi::TypedArray::ElementLength() const;
Returns the number of elements.
ByteOffset
size_t Napi::TypedArray::ByteOffset() const;
Returns the offset into the Napi::ArrayBuffer where the array starts, in bytes.
ByteLength
size_t Napi::TypedArray::ByteLength() const;
Returns the length of the array, in bytes.