Skip to content

Commit 36863f0

Browse files
Gabriel "_|Nix|_" Schulhofmhdawson
authored andcommitted
doc: refer to TypedArray and ArrayBuffer from Array
Add a blurb to the `Napi::Array` documentation that refers readers to `Napi::TypedArray` and `Napi::ArrayBuffer` for using arrays with large amounts of data. PR-URL: #465 Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: Nicola Del Gobbo <[email protected]>
1 parent c12c425 commit 36863f0

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

doc/basic_types.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,12 @@ The value is not coerced to a string.
339339
Arrays are native representations of JavaScript Arrays. `Napi::Array` is a wrapper
340340
around `napi_value` representing a JavaScript Array.
341341
342+
[`Napi::TypedArray`][] and [`Napi::ArrayBuffer`][] correspond to JavaScript data
343+
types such as [`Int32Array`][] and [`ArrayBuffer`][], respectively, that can be
344+
used for transferring large amounts of data from JavaScript to the native side.
345+
An example illustrating the use of a JavaScript-provided `ArrayBuffer` in native
346+
code is available [here](https://github.com/nodejs/node-addon-examples/tree/master/array_buffer_to_native/node-addon-api).
347+
342348
### Constructor
343349
```cpp
344350
Napi::Array::Array();
@@ -402,3 +408,8 @@ This can execute JavaScript code implicitly according to JavaScript semantics.
402408
If an error occurs, a `Napi::Error` will get thrown. If C++ exceptions are not
403409
being used, callers should check the result of `Env::IsExceptionPending` before
404410
attempting to use the returned value.
411+
412+
[`Napi::TypedArray`]: ./typed_array.md
413+
[`Napi::ArrayBuffer`]: ./array_buffer.md
414+
[`Int32Array`]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Int32Array
415+
[`ArrayBuffer`]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer

0 commit comments

Comments
 (0)