napi_get_buffer_info
functionv1node_api.hThis method returns the identical data and byte_length as napi_get_typedarray_info. And napi_get_typedarray_info accepts a node::Buffer (a Uint8Array) as the value too.
napi_status napi_get_buffer_info(napi_env env,
napi_value value,
void** data,
size_t* length)
[in] env: The environment that the API is invoked under.[in] value:napi_valuerepresenting thenode::BufferorUint8Arraybeing queried.[out] data: The underlying data buffer of thenode::BufferorUint8Array. If length is0, this may beNULLor any other pointer value.[out] length: Length in bytes of the underlying data buffer.
Returns napi_ok if the API succeeded.
This method returns the identical data and byte_length as
napi_get_typedarray_info. And napi_get_typedarray_info accepts a
node::Buffer (a Uint8Array) as the value too.
This API is used to retrieve the underlying data buffer of a node::Buffer
and its length.
Warning: Use caution while using this API since the underlying data buffer's lifetime is not guaranteed if it's managed by the VM.