Closed
Description
In https://nodejs.org/dist/latest-v9.x/docs/api/n-api.html#n_api_napi_typedarray_type
[out] data: The data buffer underlying the typed array.
[out] byte_offset: The byte offset within the data buffer from which to start projecting the TypedArray.
It seems that the data is started from &data[byte_offset]
,
but actually in node_api.cc
,
if (data != nullptr) {
*data = static_cast<uint8_t*>(buffer->GetContents().Data()) +
array->ByteOffset();
}
if (byte_offset != nullptr) {
*byte_offset = array->ByteOffset();
}
So, the doc should clarify that the out arg data
actually points to &data[byte_offset]
.
Metadata
Metadata
Assignees
Labels
No labels