Skip to content

Commit 20a4854

Browse files
authored
doc: update website N-API references to Node-API (nodejs#178)
* Update doc references from N-API to Node-API * Update website N-API references to Node-API
1 parent 4c3b781 commit 20a4854

20 files changed

Lines changed: 252 additions & 251 deletions

website/README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,15 @@ Be sure to set `website` as the current working directory before working on the
4343

4444
```
4545
cd website
46+
npm install
4647
```
4748

4849
These commands are useful while working on the site:
4950

50-
| Command | Description |
51-
| ---------------- | ------------------------------------------------------------ |
52-
| `gatsby develop` | Start a hot-reloading preview site at `http://localhost:8000`. |
53-
| `gatsby build` | Perform an optimized production build into the `public` folder. |
51+
| Command | Description |
52+
| ---------------- | ---------------------------------------------------------------- |
53+
| `gatsby develop` | Start a hot-reloading preview site at `http://localhost:8000`. |
54+
| `gatsby build` | Perform an optimized production build into the `public` folder. |
5455
| `gatsby serve` | Start a local HTML server using the results from `gatsby build`. |
5556

5657
### Embedding Source Code Samples

website/docs/about/uses.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
---
22
id: about.uses
3-
title: Uses for N-API
3+
title: Uses for Node-API
44
prev: about.what
55
---
66

77
## An existing C/C++ library
88

9-
Perhaps the most popular use for N-API is making the capabilities of an existing C/C++ library available to JavaScript programmers. This permits you to leverage the investment you've already made in your existing code, making it available to a whole new population of JavaScript programmers and projects.
9+
Perhaps the most popular use for Node-API is making the capabilities of an existing C/C++ library available to JavaScript programmers. This permits you to leverage the investment you've already made in your existing code, making it available to a whole new population of JavaScript programmers and projects.
1010

11-
For many applications, the C/C++ code base is the reference implementation. N-API permits you to continue to refine and maintain your existing C/C++ code. Improvements to the C/C++ code are then easily transferred to the JavaScript users.
11+
For many applications, the C/C++ code base is the reference implementation. Node-API permits you to continue to refine and maintain your existing C/C++ code. Improvements to the C/C++ code are then easily transferred to the JavaScript users.
1212

1313
## Access to OS resources
1414

15-
Some applications, like those built on [Electron](https://electronjs.org) or [NW.js](https://nwjs.io), can benefit from accessing system toolkits and APIs not currently available through Node. N-API facilities accessing these system resources.
15+
Some applications, like those built on [Electron](https://electronjs.org) or [NW.js](https://nwjs.io), can benefit from accessing system toolkits and APIs not currently available through Node. Node-API facilities accessing these system resources.
1616

1717
## Computational tasks
1818

19-
For low-powered devices, it may make sense to code computationally intensive tasks in C or C++ and then make that code available to JavaScript using N-API. Although in many cases Node's JavaScript runtime engine will eventually compile the JavaScript down to binary, N-API offers the ability to compile the C/C++ code just once and have the binary available to Node right from the start.
19+
For low-powered devices, it may make sense to code computationally intensive tasks in C or C++ and then make that code available to JavaScript using Node-API. Although in many cases Node's JavaScript runtime engine will eventually compile the JavaScript down to binary, Node-API offers the ability to compile the C/C++ code just once and have the binary available to Node right from the start.

website/docs/about/what.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
id: about.what
3-
title: What is N-API?
3+
title: What is Node-API?
44
next: about.uses
55
---
66

@@ -18,18 +18,18 @@ One of the real benefits of adopting Node is the comprehensive ecosystem of Node
1818

1919
Besides modules written in JavaScript, Node also provides technology to enable the development of Node modules written primarily in C and C++. This permits existing C and C++ libraries to be compiled into Node *native* modules that are virtually indistinguishable from those written entirely in JavaScript.
2020

21-
N-API is the technology that enables the development of Node native modules.
21+
Node-API is the technology that enables the development of Node native modules.
2222

23-
## N-API
23+
## Node-API
2424

25-
[N-API](https://nodejs.org/api/n-api.html#n_api_n_api) is a toolkit introduced in Node 8.0.0 that acts as an intermediary between C/C++ code and the Node JavaScript engine. It permits C/C++ code to access, create, and manipulate JavaScript objects as if they were created by JavaScript code. N-API is built into Node versions 8.0.0 and later and requires no further installation.
25+
[Node-API](https://nodejs.org/api/n-api.html#n_api_n_api) is a toolkit introduced in Node 8.0.0 that acts as an intermediary between C/C++ code and the Node JavaScript engine. It permits C/C++ code to access, create, and manipulate JavaScript objects as if they were created by JavaScript code. Node-API is built into Node versions 8.0.0 and later and requires no further installation.
2626

27-
There is another Node toolkit that predates N-API, [Native Abstractions for Node.js (NAN)](https://github.com/nodejs/nan) that serves a similar purpose. NAN is implemented using direct calls to the [Chrome V8](https://developers.google.com/v8/) that Node has historically used as its JavaScript engine. The disadvantage of this approach is that the NAN layer itself, as well as code that relies on it, needs to be updated every time the V8 engine used by Node is updated.
27+
There is another Node toolkit that predates Node-API, [Native Abstractions for Node.js (NAN)](https://github.com/nodejs/nan) that serves a similar purpose. NAN is implemented using direct calls to the [Chrome V8](https://developers.google.com/v8/) that Node has historically used as its JavaScript engine. The disadvantage of this approach is that the NAN layer itself, as well as code that relies on it, needs to be updated every time the V8 engine used by Node is updated.
2828

29-
N-API, on the other hand, abstracts out its API from the underlying JavaScript engine. This provides two immediate benefits. The first is that N-API guarantees that the API will always be backward compatible. This means that a module you create today will continue to run on all future versions of Node without the need for running `npm install` again. Since N-API is ABI-stable, your module will continue to run even without recompilation.
29+
Node-API, on the other hand, abstracts out its API from the underlying JavaScript engine. This provides two immediate benefits. The first is that Node-API guarantees that the API will always be backward compatible. This means that a module you create today will continue to run on all future versions of Node without the need for running `npm install` again. Since Node-API is ABI-stable, your module will continue to run even without recompilation.
3030

31-
The second benefit is that your module will continue to run even if Node's underlying JavaScript engine is changed. For example, there is a lot of interest in incorporating [Microsoft's ChakraCore](https://github.com/Microsoft/ChakraCore) JavaScript engine [into Node](https://github.com/nodejs/node-chakracore). Modules built on N-API will run on the ChakraCore engine without modification. In fact, they'll run without recompilation.
31+
The second benefit is that your module will continue to run even if Node's underlying JavaScript engine is changed. For example, there is a lot of interest in incorporating [Microsoft's ChakraCore](https://github.com/Microsoft/ChakraCore) JavaScript engine [into Node](https://github.com/nodejs/node-chakracore). Modules built on Node-API will run on the ChakraCore engine without modification. In fact, they'll run without recompilation.
3232

3333
## node-addon-api
3434

35-
An important adjunct to N-API, although not strictly a part of the main project, is the npm [`node-addon-api`](https://www.npmjs.com/package/node-addon-api) module. The purpose of this module is to raise the N-API API from the level of "C" up to "C++". For many users, the object model implemented by `node-addon-api` makes the effort of creating N-API modules much easier and enjoyable.
35+
An important adjunct to Node-API, although not strictly a part of the main project, is the npm [`node-addon-api`](https://www.npmjs.com/package/node-addon-api) module. The purpose of this module is to raise the Node-API API from the level of "C" up to "C++". For many users, the object model implemented by `node-addon-api` makes the effort of creating Node-API modules much easier and enjoyable.

website/docs/build-tools/cmake-js.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ prev: build-tools.node-gyp
55
next: build-tools.node-pre-gyp
66
---
77

8-
[CMake.js](https://github.com/cmake-js/cmake-js) is good build tool alternative to [node-gyp](node-gyp.html). CMake.js is based on the [CMake](https://cmake.org) tool which must be installed.
8+
[CMake.js](https://github.com/cmake-js/cmake-js) is good build tool alternative to [node-gyp](node-gyp). CMake.js is based on the [CMake](https://cmake.org) tool which must be installed.
99

1010
### Pros
1111

@@ -14,7 +14,7 @@ next: build-tools.node-pre-gyp
1414

1515
### Cons
1616

17-
- Not widely adopted in the Node community.
17+
- Not widely adopted in the Node community.
1818

1919
## Installation
2020

@@ -42,7 +42,7 @@ cmake-js --version
4242

4343
## package.json
4444

45-
Your `package.json` file needs to have a couple of entires for your native module to work with CMake.js.
45+
Your `package.json` file needs to have a couple of entires for your native module to work with CMake.js.
4646

4747
Since your native module needs to be compiled using CMake.js on installation, the `scripts` property of your `package.json` file needs an `install` entry to make this happen:
4848

@@ -68,7 +68,7 @@ An alternative is to manually add the development dependency to your `package.js
6868

6969
Here is a complete `package.json` file:
7070

71-
[**package.json**](https://github.com/nodejs/node-addon-examples/blob/master/build_with_cmake/node-addon-api/package.json)
71+
[**package.json**](https://github.com/nodejs/node-addon-examples/blob/main/build_with_cmake/node-addon-api/package.json)
7272

7373
`embed:build_with_cmake/node-addon-api/package.json`
7474

@@ -93,18 +93,18 @@ target_link_libraries(${PROJECT_NAME} ${CMAKE_JS_LIB})
9393

9494
### NAPI_VERSION
9595

96-
When building a native module based on N-API, it is important to declare the minimum N-API version against which your module is designed to work. For CMake.js, this is accomplished by adding a line like this to the `CMakeLists.txt` file:
96+
When building a native module based on Node-API, it is important to declare the minimum Node-API version against which your module is designed to work. For CMake.js, this is accomplished by adding a line like this to the `CMakeLists.txt` file:
9797

9898
```
9999
# define NAPI_VERSION
100100
add_definitions(-DNAPI_VERSION=3)
101101
```
102102

103-
> In the absence of other requirements, N-API version 3 is a good choice as this is the N-API version active when N-API left experimental status.
103+
> In the absence of other requirements, Node-API version 3 is a good choice as this is the Node-API version active when Node-API left experimental status.
104104
105105
### node-addon-api
106106

107-
Additional configuration values are required for N-API modules based on `node-addon-api`.
107+
Additional configuration values are required for Node-API modules based on `node-addon-api`.
108108

109109
`node-addon-api` requires C++11. These configuration lines at the top of the `CMakeLists.txt` file specify this requirement:
110110

@@ -117,7 +117,7 @@ set (CMAKE_CXX_STANDARD 11)
117117
Modules based on `node-addon-api` include additional header files that are not part of Node itself. These lines instruct CMake.js where to find these files:
118118

119119
```
120-
# Include N-API wrappers
120+
# Include Node-API wrappers
121121
execute_process(COMMAND node -p "require('node-addon-api').include"
122122
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
123123
OUTPUT_VARIABLE NODE_ADDON_API_DIR
@@ -127,9 +127,9 @@ string(REPLACE "\"" "" NODE_ADDON_API_DIR ${NODE_ADDON_API_DIR})
127127
target_include_directories(${PROJECT_NAME} PRIVATE ${NODE_ADDON_API_DIR})
128128
```
129129

130-
Here is a complete `CMakeLists.txt` file for an N-API native module built on `node-addon-api`:
130+
Here is a complete `CMakeLists.txt` file for an Node-API native module built on `node-addon-api`:
131131

132-
[**CMakeLists.txt**](https://github.com/nodejs/node-addon-examples/blob/master/build_with_cmake/node-addon-api/CMakeLists.txt)
132+
[**CMakeLists.txt**](https://github.com/nodejs/node-addon-examples/blob/main/build_with_cmake/node-addon-api/CMakeLists.txt)
133133

134134
`embed:build_with_cmake/node-addon-api/CMakeLists.txt`
135135

@@ -141,4 +141,4 @@ The [CMake](https://cmake.org) project home page.
141141

142142
[CMake](https://cmake.org/documentation/) documentation.
143143

144-
A couple of working [examples](https://github.com/nodejs/node-addon-examples/tree/master/build_with_cmake).
144+
A couple of working [examples](https://github.com/nodejs/node-addon-examples/tree/main/build_with_cmake).

website/docs/build-tools/node-gyp.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@ title: node-gyp
44
next: build-tools.cmake-js
55
---
66

7-
Historically, [node-gyp](https://github.com/nodejs/node-gyp) has been the build tool of choice for the Node ecosystem. The tool comes bundled with Node and is nearly universally used to build Node native modules. Most of the examples on this site use node-gyp to build the binaries.
7+
Historically, [node-gyp](https://github.com/nodejs/node-gyp) has been the build tool of choice for the Node ecosystem. The tool comes bundled with Node and is nearly universally used to build Node native modules. Most of the examples on this site use node-gyp to build the binaries.
88

9-
node-gyp is based upon Google's [GYP](https://gyp.gsrc.io/) build tool. GYP, in turn, requires Python.
9+
node-gyp is based upon Google's [GYP](https://gyp.gsrc.io/) build tool. GYP, in turn, requires Python.
1010

1111
> node-gyp requires Python 2.7 or Python 3.5+ depending upon the operating system on which the native module is being built. The specifics of the requirements can be found [here](https://github.com/nodejs/node-gyp#installation).
1212
13-
For developers who find the node-gyp build tool too constraining, [CMake.js](cmake-js.html) is a good alternative.
13+
For developers who find the node-gyp build tool too constraining, [CMake.js](cmake-js) is a good alternative.
1414

1515
### Pros
1616

1717
- Comes bundled with Node.
18-
- Is nearly universally used by the Node community to build native modules.
18+
- Is nearly universally used by the Node community to build native modules.
1919

2020
### Cons
2121

0 commit comments

Comments
 (0)