Skip to content
napi-bindings

Search

Search pages, projects and the Node-API reference

Browse Node-APIshow

napi_get_buffer_info

functionv1node_api.h

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.

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_value representing the node::Buffer or Uint8Array being queried.
  • [out] data: The underlying data buffer of the node::Buffer or Uint8Array. If length is 0, this may be NULL or 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.

View in the official Node.js documentation