Skip to content

Commit ce13797

Browse files
mhdawsonMylesBorins
authored andcommitted
doc: fix doc for napi_get_typedarray_info
The data pointer returned for the typedarray has already been adjusted by the offset so it does not point to the start of the buffer, instead id points to the start of the first element. I think we probably would have liked it to point to the start of the buffer, but we can't change as that would be a breaking change. Update the doc to match the implementation. PR-URL: #20747 Fixes: nodejs/node-addon-api#244 Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 0112357 commit ce13797

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

doc/api/n-api.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1750,10 +1750,15 @@ napi_status napi_get_typedarray_info(napi_env env,
17501750
properties to query.
17511751
- `[out] type`: Scalar datatype of the elements within the `TypedArray`.
17521752
- `[out] length`: The number of elements in the `TypedArray`.
1753-
- `[out] data`: The data buffer underlying the `TypedArray`.
1753+
- `[out] data`: The data buffer underlying the `TypedArray` adjusted by
1754+
the `byte_offset` value so that it points to the first element in the
1755+
`TypedArray`.
17541756
- `[out] arraybuffer`: The `ArrayBuffer` underlying the `TypedArray`.
1755-
- `[out] byte_offset`: The byte offset within the data buffer from which
1756-
to start projecting the `TypedArray`.
1757+
- `[out] byte_offset`: The byte offset within the underlying native array
1758+
at which the first element of the arrays is located. The value for the data
1759+
parameter has already been adjusted so that data points to the first element
1760+
in the array. Therefore, the first byte of the native array would be at
1761+
data - `byte_offset`.
17571762

17581763
Returns `napi_ok` if the API succeeded.
17591764

0 commit comments

Comments
 (0)