Skip to content

misleading description in doc about napi_get_typedarray_info #244

Closed
@yw662

Description

@yw662

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions