Skip to content

Commit

Permalink
doc: clarify use of Uint8Array for n-api
Browse files Browse the repository at this point in the history
`napi_get_buffer_info` always supported receiving `Uint8Array` as a
`value` argument because `node::Buffer` is a subclass of `Uint8Array`
and the underlying V8 APIs don't distinguish between two. With this
change we mark both types as supported by the API so that the user code
doesn't have to unknowingly use oficially unsupported type of the
`value` argument.
  • Loading branch information
indutny committed Jul 12, 2023
1 parent 0e9138d commit 3d03df1
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions doc/api/n-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -3122,9 +3122,10 @@ napi_status napi_get_buffer_info(napi_env env,
```

* `[in] env`: The environment that the API is invoked under.
* `[in] value`: `napi_value` representing the `node::Buffer` being queried.
* `[out] data`: The underlying data buffer of the `node::Buffer`.
If length is `0`, this may be `NULL` or any other pointer value.
* `[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.
Expand Down

0 comments on commit 3d03df1

Please sign in to comment.