GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — doc: clarify use of Uint8Array for n-api · nodejs/node@f9c2a3f

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • doc/api
    • n-api.md
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎doc/api/n-api.md‎

Copy file name to clipboardExpand all lines: doc/api/n-api.md
+15-6Lines changed: 15 additions & 6 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -3066,13 +3066,18 @@ napi_status napi_get_buffer_info(napi_env env,
30663066
```
30673067

30683068
* `[in] env`: The environment that the API is invoked under.
3069-
* `[in] value`: `napi_value` representing the `node::Buffer` being queried.
3070-
* `[out] data`: The underlying data buffer of the `node::Buffer`.
3071-
If length is `0`, this may be `NULL` or any other pointer value.
3069+
* `[in] value`: `napi_value` representing the `node::Buffer` or `Uint8Array`
3070+
being queried.
3071+
* `[out] data`: The underlying data buffer of the `node::Buffer` or
3072+
`Uint8Array`. If length is `0`, this may be `NULL` or any other pointer value.
30723073
* `[out] length`: Length in bytes of the underlying data buffer.
30733074

30743075
Returns `napi_ok` if the API succeeded.
30753076

3077+
This method returns the identical `data` and `byte_length` as
3078+
[`napi_get_typedarray_info`][]. And `napi_get_typedarray_info` accepts a
3079+
`node::Buffer` (a Uint8Array) as the value too.
3080+
30763081
This API is used to retrieve the underlying data buffer of a `node::Buffer`
30773082
and its length.
30783083

@@ -3823,12 +3828,14 @@ napi_status napi_is_buffer(napi_env env, napi_value value, bool* result)
38233828

38243829
* `[in] env`: The environment that the API is invoked under.
38253830
* `[in] value`: The JavaScript value to check.
3826-
* `[out] result`: Whether the given `napi_value` represents a `node::Buffer`
3827-
object.
3831+
* `[out] result`: Whether the given `napi_value` represents a `node::Buffer` or
3832+
`Uint8Array` object.
38283833

38293834
Returns `napi_ok` if the API succeeded.
38303835

3831-
This API checks if the `Object` passed in is a buffer.
3836+
This API checks if the `Object` passed in is a buffer or Uint8Array.
3837+
[`napi_is_typedarray`][] should be preferred if the caller needs to check if the
3838+
value is a Uint8Array.
38323839

38333840
### `napi_is_date`
38343841

@@ -6498,11 +6505,13 @@ the add-on's file name during loading.
64986505
[`napi_get_last_error_info`]: #napi_get_last_error_info
64996506
[`napi_get_property`]: #napi_get_property
65006507
[`napi_get_reference_value`]: #napi_get_reference_value
6508+
[`napi_get_typedarray_info`]: #napi_get_typedarray_info
65016509
[`napi_get_value_external`]: #napi_get_value_external
65026510
[`napi_has_property`]: #napi_has_property
65036511
[`napi_instanceof`]: #napi_instanceof
65046512
[`napi_is_error`]: #napi_is_error
65056513
[`napi_is_exception_pending`]: #napi_is_exception_pending
6514+
[`napi_is_typedarray`]: #napi_is_typedarray
65066515
[`napi_make_callback`]: #napi_make_callback
65076516
[`napi_open_callback_scope`]: #napi_open_callback_scope
65086517
[`napi_open_escapable_handle_scope`]: #napi_open_escapable_handle_scope

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.