Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: rename N-API to Node-API #37259

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 13 additions & 12 deletions doc/api/addons.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ _Addons_ are dynamically-linked shared objects written in C++. The
[`require()`][require] function can load addons as ordinary Node.js modules.
Addons provide an interface between JavaScript and C/C++ libraries.

There are three options for implementing addons: N-API, nan, or direct
There are three options for implementing addons: Node-API, nan, or direct
use of internal V8, libuv and Node.js libraries. Unless there is a need for
direct access to functionality which is not exposed by N-API, use N-API.
Refer to [C/C++ addons with N-API](n-api.md) for more information on N-API.
direct access to functionality which is not exposed by Node-API, use Node-API.
Refer to [C/C++ addons with Node-API](n-api.md) for more information on
Node-API.

When not using N-API, implementing addons is complicated,
When not using Node-API, implementing addons is complicated,
involving knowledge of several components and APIs:

* V8: the C++ library Node.js uses to provide the
Expand Down Expand Up @@ -245,7 +246,7 @@ changes:
In order to be loaded from multiple Node.js environments,
such as a main thread and a Worker thread, an add-on needs to either:

* Be an N-API addon, or
* Be an Node-API addon, or
* Be declared as context-aware using `NODE_MODULE_INIT()` as described above

In order to support [`Worker`][] threads, addons need to clean up any resources
Expand Down Expand Up @@ -437,11 +438,11 @@ addon developers are recommended to use to keep compatibility between past and
future releases of V8 and Node.js. See the `nan` [examples][] for an
illustration of how it can be used.

## N-API
## Node-API

> Stability: 2 - Stable

N-API is an API for building native addons. It is independent from
Node-API is an API for building native addons. It is independent from
the underlying JavaScript runtime (e.g. V8) and is maintained as part of
Node.js itself. This API will be Application Binary Interface (ABI) stable
across versions of Node.js. It is intended to insulate addons from
Expand All @@ -451,17 +452,17 @@ recompilation. Addons are built/packaged with the same approach/tools
outlined in this document (node-gyp, etc.). The only difference is the
set of APIs that are used by the native code. Instead of using the V8
or [Native Abstractions for Node.js][] APIs, the functions available
in the N-API are used.
in the Node-API are used.

Creating and maintaining an addon that benefits from the ABI stability
provided by N-API carries with it certain
provided by Node-API carries with it certain
[implementation considerations](n-api.md#n_api_implications_of_abi_stability).

To use N-API in the above "Hello world" example, replace the content of
To use Node-API in the above "Hello world" example, replace the content of
`hello.cc` with the following. All other instructions remain the same.

```cpp
// hello.cc using N-API
// hello.cc using Node-API
#include <node_api.h>

namespace demo {
Expand Down Expand Up @@ -493,7 +494,7 @@ NAPI_MODULE(NODE_GYP_MODULE_NAME, init)
```

The functions available and how to use them are documented in
[C/C++ addons with N-API](n-api.md).
[C/C++ addons with Node-API](n-api.md).

## Addon examples

Expand Down
4 changes: 2 additions & 2 deletions doc/api/errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -1823,7 +1823,7 @@ would be possible by calling a callback more than once.
<a id="ERR_NAPI_CONS_FUNCTION"></a>
### `ERR_NAPI_CONS_FUNCTION`

While using `N-API`, a constructor passed was not a function.
While using `Node-API`, a constructor passed was not a function.

<a id="ERR_NAPI_INVALID_DATAVIEW_ARGS"></a>
### `ERR_NAPI_INVALID_DATAVIEW_ARGS`
Expand Down Expand Up @@ -2559,7 +2559,7 @@ added: v9.0.0
removed: v10.0.0
-->

Used by the `N-API` when `Constructor.prototype` is not an object.
Used by the `Node-API` when `Constructor.prototype` is not an object.

<a id="ERR_NO_LONGER_SUPPORTED"></a>
### `ERR_NO_LONGER_SUPPORTED`
Expand Down
2 changes: 1 addition & 1 deletion doc/api/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* [Async hooks](async_hooks.md)
* [Buffer](buffer.md)
* [C++ addons](addons.md)
* [C/C++ addons with N-API](n-api.md)
* [C/C++ addons with Node-API](n-api.md)
* [C++ embedder API](embedding.md)
* [Child processes](child_process.md)
* [Cluster](cluster.md)
Expand Down
Loading