From ce13797dcaceede74f9bc6e6b7814e436aefd661 Mon Sep 17 00:00:00 2001 From: Michael Dawson Date: Tue, 15 May 2018 10:57:30 -0400 Subject: [PATCH] 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: https://github.com/nodejs/node/pull/20747 Fixes: https://github.com/nodejs/node-addon-api/issues/244 Reviewed-By: Gabriel Schulhof Reviewed-By: James M Snell --- doc/api/n-api.md | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/doc/api/n-api.md b/doc/api/n-api.md index a8d1ae46d09cdc..5a98b93d1f7b93 100644 --- a/doc/api/n-api.md +++ b/doc/api/n-api.md @@ -1750,10 +1750,15 @@ napi_status napi_get_typedarray_info(napi_env env, properties to query. - `[out] type`: Scalar datatype of the elements within the `TypedArray`. - `[out] length`: The number of elements in the `TypedArray`. -- `[out] data`: The data buffer underlying the `TypedArray`. +- `[out] data`: The data buffer underlying the `TypedArray` adjusted by +the `byte_offset` value so that it points to the first element in the +`TypedArray`. - `[out] arraybuffer`: The `ArrayBuffer` underlying the `TypedArray`. -- `[out] byte_offset`: The byte offset within the data buffer from which -to start projecting the `TypedArray`. +- `[out] byte_offset`: The byte offset within the underlying native array +at which the first element of the arrays is located. The value for the data +parameter has already been adjusted so that data points to the first element +in the array. Therefore, the first byte of the native array would be at +data - `byte_offset`. Returns `napi_ok` if the API succeeded.