Skip to content

Commit

Permalink
doc: clarify use of NAPI_EXPERIMENTAL
Browse files Browse the repository at this point in the history
We've had a few questions about APIs not being available which
were related to not having specified `NAPI_EXPERIMENTAL`.

Add some additional documentation to explain this common
issue:

Refs: nodejs/node-addon-api#810

Signed-off-by: Michael Dawson <[email protected]>

PR-URL: #35195
Reviewed-By: Jiawen Geng <[email protected]>
Reviewed-By: Gabriel Schulhof <[email protected]>
Reviewed-By: Chengzhong Wu <[email protected]>
  • Loading branch information
mhdawson authored and addaleax committed Sep 22, 2020
1 parent 89636e3 commit 6669eff
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions doc/api/n-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,18 @@ listed as supporting a later version.

\* Indicates that the N-API version was released as experimental

Each API documented for N-API will have a header named `added in:`, and APIs
which are stable will have the additional header `N-API version:`.
APIs are directly usable when using a Node.js version which supports
the N-API version shown in `N-API version:` or higher.
When using a Node.js version that does not support the
`N-API version:` listed or if there is no `N-API version:` listed,
then the API will only be available if
`#define NAPI_EXPERIMENTAL` precedes the inclusion of `node_api.h`
or `js_native_api.h`. If an API appears not to be available on
a version of Node.js which is later than the one shown in `added in:` then
this is most likely the reason for the apparent absence.

The N-APIs associated strictly with accessing ECMAScript features from native
code can be found separately in `js_native_api.h` and `js_native_api_types.h`.
The APIs defined in these headers are included in `node_api.h` and
Expand Down

0 comments on commit 6669eff

Please sign in to comment.