Skip to content

Commit

Permalink
doc: rename N-API with Node-API
Browse files Browse the repository at this point in the history
Done by running:
sed -i "s/N-API/Node-API/g" doc/*

Fixes: nodejs#950
  • Loading branch information
RaisinTen committed Mar 25, 2021
1 parent 8ef0725 commit 1980f06
Show file tree
Hide file tree
Showing 23 changed files with 65 additions and 65 deletions.
4 changes: 2 additions & 2 deletions doc/async_context.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ Returns the `Napi::Env` environment in which the async context has been created.
Napi::AsyncContext::operator napi_async_context() const;
```

Returns the N-API `napi_async_context` wrapped by the `Napi::AsyncContext`
object. This can be used to mix usage of the C N-API and node-addon-api.
Returns the Node-API `napi_async_context` wrapped by the `Napi::AsyncContext`
object. This can be used to mix usage of the C Node-API and node-addon-api.

## Example

Expand Down
4 changes: 2 additions & 2 deletions doc/async_worker.md
Original file line number Diff line number Diff line change
Expand Up @@ -343,8 +343,8 @@ virtual Napi::AsyncWorker::~AsyncWorker();
Napi::AsyncWorker::operator napi_async_work() const;
```

Returns the N-API napi_async_work wrapped by the `Napi::AsyncWorker` object. This
can be used to mix usage of the C N-API and node-addon-api.
Returns the Node-API napi_async_work wrapped by the `Napi::AsyncWorker` object. This
can be used to mix usage of the C Node-API and node-addon-api.

## Example

Expand Down
6 changes: 3 additions & 3 deletions doc/callback_scope.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

There are cases (for example, resolving promises) where it is necessary to have
the equivalent of the scope associated with a callback in place when making
certain N-API calls.
certain Node-API calls.

## Methods

Expand Down Expand Up @@ -50,5 +50,5 @@ Returns the `Napi::Env` associated with the `Napi::CallbackScope`.
Napi::CallbackScope::operator napi_callback_scope() const;
```

Returns the N-API `napi_callback_scope` wrapped by the `Napi::CallbackScope`
object. This can be used to mix usage of the C N-API and node-addon-api.
Returns the Node-API `napi_callback_scope` wrapped by the `Napi::CallbackScope`
object. This can be used to mix usage of the C Node-API and node-addon-api.
2 changes: 1 addition & 1 deletion doc/checker-tool.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

**node-addon-api** provides a [checker tool][] that will inspect a given
directory tree, identifying all Node.js native addons therein, and further
indicating for each addon whether it is an N-API addon.
indicating for each addon whether it is an Node-API addon.

## To use the checker tool:

Expand Down
4 changes: 2 additions & 2 deletions doc/class_property_descriptor.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@ inside the `Napi::ObjectWrap<T>` class.
operator napi_property_descriptor&() { return _desc; }
```

Returns the original N-API `napi_property_descriptor` wrapped inside the `Napi::ClassPropertyDescriptor`
Returns the original Node-API `napi_property_descriptor` wrapped inside the `Napi::ClassPropertyDescriptor`

```cpp
operator const napi_property_descriptor&() const { return _desc; }
```
Returns the original N-API `napi_property_descriptor` wrapped inside the `Napi::ClassPropertyDescriptor`
Returns the original Node-API `napi_property_descriptor` wrapped inside the `Napi::ClassPropertyDescriptor`
14 changes: 7 additions & 7 deletions doc/cmake-js.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,37 +27,37 @@ Your project will require a `CMakeLists.txt` file. The [CMake.js README file](ht

### NAPI_VERSION

When building N-API addons, it's crucial to specify the N-API version your code is designed to work with. With CMake.js, this information is specified in the `CMakeLists.txt` file:
When building Node-API addons, it's crucial to specify the Node-API version your code is designed to work with. With CMake.js, this information is specified in the `CMakeLists.txt` file:

```
add_definitions(-DNAPI_VERSION=3)
```

Since N-API is ABI-stable, your N-API addon will work, without recompilation, with the N-API version you specify in `NAPI_VERSION` and all subsequent N-API versions.
Since Node-API is ABI-stable, your Node-API addon will work, without recompilation, with the Node-API version you specify in `NAPI_VERSION` and all subsequent Node-API versions.

In the absence of a need for features available only in a specific N-API version, version 3 is a good choice as it is the version of N-API that was active when N-API left experimental status.
In the absence of a need for features available only in a specific Node-API version, version 3 is a good choice as it is the version of Node-API that was active when Node-API left experimental status.

### NAPI_EXPERIMENTAL

The following line in the `CMakeLists.txt` file will enable N-API experimental features if your code requires them:
The following line in the `CMakeLists.txt` file will enable Node-API experimental features if your code requires them:

```
add_definitions(-DNAPI_EXPERIMENTAL)
```

### node-addon-api

If your N-API native add-on uses the optional [**node-addon-api**](https://github.com/nodejs/node-addon-api#node-addon-api-module) C++ wrapper, the `CMakeLists.txt` file requires additional configuration information as described on the [CMake.js README file](https://github.com/cmake-js/cmake-js#n-api-and-node-addon-api).
If your Node-API native add-on uses the optional [**node-addon-api**](https://github.com/nodejs/node-addon-api#node-addon-api-module) C++ wrapper, the `CMakeLists.txt` file requires additional configuration information as described on the [CMake.js README file](https://github.com/cmake-js/cmake-js#n-api-and-node-addon-api).

## Example

A working example of an N-API native addon built using CMake.js can be found on the [node-addon-examples repository](https://github.com/nodejs/node-addon-examples/tree/HEAD/build_with_cmake#building-n-api-addons-using-cmakejs).
A working example of an Node-API native addon built using CMake.js can be found on the [node-addon-examples repository](https://github.com/nodejs/node-addon-examples/tree/HEAD/build_with_cmake#building-n-api-addons-using-cmakejs).

## **CMake** Reference

- [Installation](https://github.com/cmake-js/cmake-js#installation)
- [How to use](https://github.com/cmake-js/cmake-js#usage)
- [Using N-API and node-addon-api](https://github.com/cmake-js/cmake-js#n-api-and-node-addon-api)
- [Using Node-API and node-addon-api](https://github.com/cmake-js/cmake-js#n-api-and-node-addon-api)
- [Tutorials](https://github.com/cmake-js/cmake-js#tutorials)
- [Use case in the works - ArrayFire.js](https://github.com/cmake-js/cmake-js#use-case-in-the-works---arrayfirejs)

Expand Down
16 changes: 8 additions & 8 deletions doc/error_handling.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ exception, then node-addon-api automatically converts and throws it as a C++
exception of type `Napi:Error` on return from the JavaScript code to the native
method.

If a C++ exception of type `Napi::Error` escapes from a N-API C++ callback, then
the N-API wrapper automatically converts and throws it as a JavaScript exception.
If a C++ exception of type `Napi::Error` escapes from a Node-API C++ callback, then
the Node-API wrapper automatically converts and throws it as a JavaScript exception.

On return from a native method, node-addon-api will automatically convert a pending C++
exception to a JavaScript exception.
Expand All @@ -67,7 +67,7 @@ will bubble up as a C++ exception of type `Napi::Error`, until it is either caug
while still in C++, or else automatically propagated as a JavaScript exception
when returning to JavaScript.
### Propagating a N-API C++ exception
### Propagating a Node-API C++ exception
```cpp
Napi::Function jsFunctionThatThrows = someObj.As<Napi::Function>();
Expand All @@ -81,7 +81,7 @@ executed. The exception will bubble up as a C++ exception of type `Napi::Error`,
until it is either caught while still in C++, or else automatically propagated as
a JavaScript exception when returning to JavaScript.

### Handling a N-API C++ exception
### Handling a Node-API C++ exception

```cpp
Napi::Function jsFunctionThatThrows = someObj.As<Napi::Function>();
Expand Down Expand Up @@ -123,7 +123,7 @@ return;
After throwing a JavaScript exception, the code should generally return
immediately from the native callback, after performing any necessary cleanup.
### Propagating a N-API JS exception
### Propagating a Node-API JS exception
```cpp
Napi::Env env = ...
Expand All @@ -139,7 +139,7 @@ If env.IsExceptionPending() returns true a JavaScript exception is pending. To
let the exception propagate, the code should generally return immediately from
the native callback, after performing any necessary cleanup.

### Handling a N-API JS exception
### Handling a Node-API JS exception

```cpp
Napi::Env env = ...
Expand All @@ -154,10 +154,10 @@ if (env.IsExceptionPending()) {
Since the exception was cleared here, it will not be propagated as a JavaScript
exception after the native callback returns.

## Calling N-API directly from a **node-addon-api** addon
## Calling Node-API directly from a **node-addon-api** addon

**node-addon-api** provides macros for throwing errors in response to non-OK
`napi_status` results when calling [N-API](https://nodejs.org/docs/latest/api/n-api.html)
`napi_status` results when calling [Node-API](https://nodejs.org/docs/latest/api/n-api.html)
functions from within a native addon. These macros are defined differently
depending on whether C++ exceptions are enabled or not, but are available for
use in either case.
Expand Down
6 changes: 3 additions & 3 deletions doc/escapable_handle_scope.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,16 @@ Napi::EscapableHandleScope Napi::EscapableHandleScope::New(napi_env env, napi_ha

Returns a new `Napi::EscapableHandleScope` instance which wraps the
napi_escapable_handle_scope handle passed in. This can be used
to mix usage of the C N-API and node-addon-api.
to mix usage of the C Node-API and node-addon-api.

operator EscapableHandleScope::napi_escapable_handle_scope

```cpp
operator Napi::EscapableHandleScope::napi_escapable_handle_scope() const
```

Returns the N-API napi_escapable_handle_scope wrapped by the `Napi::EscapableHandleScope` object.
This can be used to mix usage of the C N-API and node-addon-api by allowing
Returns the Node-API napi_escapable_handle_scope wrapped by the `Napi::EscapableHandleScope` object.
This can be used to mix usage of the C Node-API and node-addon-api by allowing
the class to be used be converted to a napi_escapable_handle_scope.

### Destructor
Expand Down
2 changes: 1 addition & 1 deletion doc/function_reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Napi::FunctionReference::FunctionReference(napi_env env, napi_ref ref);
```
- `[in] env`: The environment in which to construct the `Napi::FunctionReference` object.
- `[in] ref`: The N-API reference to be held by the `Napi::FunctionReference`.
- `[in] ref`: The Node-API reference to be held by the `Napi::FunctionReference`.
Returns a newly created `Napi::FunctionReference` object.
Expand Down
4 changes: 2 additions & 2 deletions doc/generator.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
## What is generator

**[generator-napi-module](https://www.npmjs.com/package/generator-napi-module)** is a module to quickly generate a skeleton module using
**N-API**, the new API for Native addons. This module automatically sets up your
**gyp file** to use **node-addon-api**, the C++ wrappers for N-API and generates
**Node-API**, the new API for Native addons. This module automatically sets up your
**gyp file** to use **node-addon-api**, the C++ wrappers for Node-API and generates
a wrapper JS module. Optionally, it can even configure the generated project to
use **TypeScript** instead.

Expand Down
6 changes: 3 additions & 3 deletions doc/handle_scope.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Napi::HandleScope::HandleScope(Napi::Env env, Napi::HandleScope scope);
- `[in] scope`: pre-existing `Napi::HandleScope`.

Returns a new `Napi::HandleScope` instance which wraps the napi_handle_scope
handle passed in. This can be used to mix usage of the C N-API
handle passed in. This can be used to mix usage of the C Node-API
and node-addon-api.

operator HandleScope::napi_handle_scope
Expand All @@ -43,8 +43,8 @@ operator HandleScope::napi_handle_scope
operator Napi::HandleScope::napi_handle_scope() const
```

Returns the N-API napi_handle_scope wrapped by the `Napi::EscapableHandleScope` object.
This can be used to mix usage of the C N-API and node-addon-api by allowing
Returns the Node-API napi_handle_scope wrapped by the `Napi::EscapableHandleScope` object.
This can be used to mix usage of the C Node-API and node-addon-api by allowing
the class to be used be converted to a napi_handle_scope.

### Destructor
Expand Down
2 changes: 1 addition & 1 deletion doc/object_reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ Napi::ObjectReference::ObjectReference(napi_env env, napi_value value);
* `[in] env`: The `napi_env` environment in which to construct the `Napi::ObjectReference` object.
* `[in] value`: The N-API primitive value to be held by the `Napi::ObjectReference`.
* `[in] value`: The Node-API primitive value to be held by the `Napi::ObjectReference`.
Returns the newly created reference.
Expand Down
2 changes: 1 addition & 1 deletion doc/prebuild_tools.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ possible to distribute the native add-on in pre-built form for different platfor
and architectures. The prebuild tools help to create and distribute the pre-built
form of a native add-on.

The following list report known tools that are compatible with **N-API**:
The following list report known tools that are compatible with **Node-API**:

- **[node-pre-gyp](https://www.npmjs.com/package/node-pre-gyp)**
- **[prebuild](https://www.npmjs.com/package/prebuild)**
Expand Down
4 changes: 2 additions & 2 deletions doc/promises.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ void Napi::Promise::Deferred::Resolve(napi_value value) const;
Resolves the `Napi::Promise` object held by the `Napi::Promise::Deferred` object.
* `[in] value`: The N-API primitive value with which to resolve the `Napi::Promise`.
* `[in] value`: The Node-API primitive value with which to resolve the `Napi::Promise`.
### Reject
Expand All @@ -73,7 +73,7 @@ void Napi::Promise::Deferred::Reject(napi_value value) const;

Rejects the Promise object held by the `Napi::Promise::Deferred` object.

* `[in] value`: The N-API primitive value with which to reject the `Napi::Promise`.
* `[in] value`: The Node-API primitive value with which to reject the `Napi::Promise`.


[`Napi::Object`]: ./object.md
2 changes: 1 addition & 1 deletion doc/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Napi::Reference::Reference(napi_env env, napi_value value);
* `[in] env`: The `napi_env` environment in which to construct the `Napi::Reference` object.
* `[in] value`: The N-API primitive value to be held by the `Napi::Reference`.
* `[in] value`: The Node-API primitive value to be held by the `Napi::Reference`.
### Env
Expand Down
14 changes: 7 additions & 7 deletions doc/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Prerequisites

Before starting to use **N-API** you need to assure you have the following
Before starting to use **Node-API** you need to assure you have the following
prerequisites:

* **Node.JS** see: [Installing Node.js](https://nodejs.org/)
Expand All @@ -13,7 +13,7 @@ prerequisites:

## Installation and usage

To use **N-API** in a native module:
To use **Node-API** in a native module:

1. Add a dependency on this package to `package.json`:

Expand All @@ -29,9 +29,9 @@ To use **N-API** in a native module:
'include_dirs': ["<!(node -p \"require('node-addon-api').include_dir\")"],
```

3. Decide whether the package will enable C++ exceptions in the N-API wrapper.
3. Decide whether the package will enable C++ exceptions in the Node-API wrapper.
The base ABI-stable C APIs do not throw or handle C++ exceptions, but the
N-API C++ wrapper classes may _optionally_
Node-API C++ wrapper classes may _optionally_
[integrate C++ and JavaScript exception-handling
](https://github.com/nodejs/node-addon-api/blob/HEAD/doc/error_handling.md).
To enable that capability, C++ exceptions must be enabled in `binding.gyp`:
Expand All @@ -49,7 +49,7 @@ To use **N-API** in a native module:
},
```

Alternatively, disable use of C++ exceptions in N-API:
Alternatively, disable use of C++ exceptions in Node-API:

```gyp
'defines': [ 'NAPI_DISABLE_CPP_EXCEPTIONS' ],
Expand All @@ -74,8 +74,8 @@ To use **N-API** in a native module:
#include "napi.h"
```

At build time, the N-API back-compat library code will be used only when the
targeted node version *does not* have N-API built-in.
At build time, the Node-API back-compat library code will be used only when the
targeted node version *does not* have Node-API built-in.

The preprocessor directive `NODE_ADDON_API_DISABLE_DEPRECATED` can be defined at
compile time before including `napi.h` to skip the definition of deprecated APIs.
2 changes: 1 addition & 1 deletion doc/string.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ being used, callers should check the result of `Env::IsExceptionPending` before
attempting to use the returned value.

```cpp
Napi::String::String(napi_env env, napi_value value); ///< Wraps a N-API value primitive.
Napi::String::String(napi_env env, napi_value value); ///< Wraps a Node-API value primitive.
```
- `[in] env` - The environment in which to create the string.
- `[in] value` - The primitive to wrap.
Expand Down
2 changes: 1 addition & 1 deletion doc/symbol.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Napi::Symbol::New(napi_env env, napi_value description);
- `std::string&` - UTF8 string description.
- `const char*` - represents a UTF8 string description.
- `String` - Node addon API String description.
- `napi_value` - N-API `napi_value` description.
- `napi_value` - Node-API `napi_value` description.
If an error occurs, a `Napi::Error` will get thrown. If C++ exceptions are not
being used, callers should check the result of `Napi::Env::IsExceptionPending` before
Expand Down
12 changes: 6 additions & 6 deletions doc/threadsafe.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ native C++ code (the "callback") on the Node.js thread.

### [`Napi::ThreadSafeFunction`](threadsafe_function.md)

This API is designed without N-API 5 native support for [the optional JavaScript
This API is designed without Node-API 5 native support for [the optional JavaScript
function callback feature](https://github.com/nodejs/node/commit/53297e66cb).

This API has some dynamic functionality, in that:
Expand All @@ -65,7 +65,7 @@ situational **memory leaks**:
and dynamically constructs a wrapper for your callback on the heap for every
call to `[Non]BlockingCall()`.
- In acting in this "broker" fashion, the API will call the underlying "make
call" N-API method on this packaged item. If the API has determined the
call" Node-API method on this packaged item. If the API has determined the
thread-safe function is no longer accessible (eg. all threads have released
yet there are still items on the queue), **the callback passed to
[Non]BlockingCall will not execute**. This means it is impossible to perform
Expand All @@ -81,11 +81,11 @@ situational **memory leaks**:
### [`Napi::TypedThreadSafeFunction`](typed_threadsafe_function.md)

The `TypedThreadSafeFunction` class is a new implementation to address the
drawbacks listed above. The API is designed with N-API 5's support of an
drawbacks listed above. The API is designed with Node-API 5's support of an
optional function callback. The API will correctly allow developers to pass
`std::nullptr` instead of a `const Function&` for the callback function
specified in `::New`. It also provides helper APIs to _target_ N-API 4 and
construct a no-op `Function` **or** to target N-API 5 and "construct" a
specified in `::New`. It also provides helper APIs to _target_ Node-API 4 and
construct a no-op `Function` **or** to target Node-API 5 and "construct" a
`std::nullptr` callback. This allows a single codebase to use the same APIs,
with just a switch of the `NAPI_VERSION` compile-time constant.

Expand All @@ -111,7 +111,7 @@ The removal of the dynamic call functionality has the following implications:

In summary, it may be best to use `Napi::TypedThreadSafeFunction` if:

- static, compile-time support for targeting N-API 4 or 5+ with an optional
- static, compile-time support for targeting Node-API 4 or 5+ with an optional
JavaScript callback feature is desired;
- the callback can have `static` storage class and will not change across calls
to `[Non]BlockingCall()`;
Expand Down
2 changes: 1 addition & 1 deletion doc/threadsafe_function.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ napi_status Napi::ThreadSafeFunction::NonBlockingCall(DataType* data, Callback c
call as an `Napi::Function` in its parameters and the `DataType*` data pointer
(if provided). Must implement `void operator()(Napi::Env env, Function
jsCallback, DataType* data)`, skipping `data` if not provided. It is not
necessary to call into JavaScript via `MakeCallback()` because N-API runs
necessary to call into JavaScript via `MakeCallback()` because Node-API runs
`callback` in a context appropriate for callbacks.
**These specific function overloads should only be used on a `ThreadSafeFunction`
Expand Down
2 changes: 1 addition & 1 deletion doc/typed_threadsafe_function.md
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ void CallJs(Napi::Env env, Function callback, Context *context,
// Is the JavaScript environment still available to call into, eg. the TSFN is
// not aborted
if (env != nullptr) {
// On N-API 5+, the `callback` parameter is optional; however, this example
// On Node-API 5+, the `callback` parameter is optional; however, this example
// does ensure a callback is provided.
if (callback != nullptr) {
callback.Call(context->Value(), {Number::New(env, *data)});
Expand Down
Loading

0 comments on commit 1980f06

Please sign in to comment.