Skip to content

Commit d1e1709

Browse files
committed
doc: Clarify positioning versus N-API
PR-URL: nodejs/node-addon-api#288 Reviewed-By: Nicola Del Gobbo <nicoladelgobbo@NickNaso.local>
1 parent 0121b0b commit d1e1709

File tree

1 file changed

+32
-20
lines changed

1 file changed

+32
-20
lines changed

README.md

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,32 @@
1-
# **Node.js API (N-API) Package**
2-
3-
This package contains **header-only C++ wrapper classes** for the
4-
**ABI-stable Node.js API** also known as **N-API**, providing C++ object
5-
model and exception handling semantics with low overhead. It guarantees
6-
backward compatibility when used with older versions of Node.js that do
7-
not have N-API built-in.
8-
9-
N-API is an API for building native addons. It is independent from the
10-
underlying JavaScript runtime (e.g. V8 or ChakraCore) and is maintained as
11-
part of Node.js itself. This API will be Application Binary Interface (ABI)
12-
stable across versions and flavors of Node.js. It is intended to insulate
1+
# **node-addon-api module**
2+
This module contains **header-only C++ wrapper classes** which simplify
3+
the use of the C based [N-API](https://nodejs.org/dist/latest/docs/api/n-api.html)
4+
provided by Node.js when using C++. It provides a C++ object model
5+
and exception handling semantics with low overhead.
6+
7+
N-API is an ABI stable C interface provided by Node.js for building native
8+
addons. It is independent from the underlying JavaScript runtime (e.g. V8 or ChakraCore)
9+
and is maintained as part of Node.js itself. It is intended to insulate
1310
native addons from changes in the underlying JavaScript engine and allow
1411
modules compiled for one version to run on later versions of Node.js without
15-
recompilation. N-API guarantees the **API** and **ABI** compatibility across
16-
different versions of Node.js. So if you switched to a different version of
17-
Node.js, you would not need to reinstall or recompile the native addon.
12+
recompilation.
1813

19-
APIs exposed by N-API are generally used to create and manipulate JavaScript
20-
values. Concepts and operations generally map to ideas specified in the
21-
**ECMA262 Language Specification**.
14+
The `node-addon-api` module, which is not part of Node.js, preserves the benefits
15+
of the N-API as it consists only of inline code that depends only on the stable API
16+
provided by N-API. As such, modules built against one version of Node.js
17+
using node-addon-api should run without having to be rebuilt with newer versions
18+
of Node.js.
19+
20+
As new APIs are added to N-API, node-addon-api must be updated to provide
21+
wrappers for those new APIs. For this reason node-addon-api provides
22+
methods that allow callers to obtain the underlying N-API handles so
23+
direct calls to N-API and the use of the objects/methods provided by
24+
node-addon-api can be used together. For example, in order to be able
25+
to use an API for which the node-add-api does not yet provide a wrapper.
26+
27+
APIs exposed by node-addon-api are generally used to create and
28+
manipulate JavaScript values. Concepts and operations generally map
29+
to ideas specified in the **ECMA262 Language Specification**.
2230

2331
- **[Setup](#setup)**
2432
- **[API Documentation](#api)**
@@ -47,6 +55,10 @@ values. Concepts and operations generally map to ideas specified in the
4755
<a name="api"></a>
4856

4957
### **API Documentation**
58+
59+
The following is the documentation for node-addon-api (NOTE:
60+
still a work in progress as its not yet complete).
61+
5062
- [Basic Types](doc/basic_types.md)
5163
- [Array](doc/array.md)
5264
- [Symbol](doc/symbol.md)
@@ -86,7 +98,7 @@ values. Concepts and operations generally map to ideas specified in the
8698

8799
### **Examples**
88100

89-
Are you new to **N-API**? Take a look at our **[examples](https://github.com/nodejs/abi-stable-node-addon-examples)**
101+
Are you new to **node-addon-api**? Take a look at our **[examples](https://github.com/nodejs/abi-stable-node-addon-examples)**
90102

91103
- **[Hello World](https://github.com/nodejs/abi-stable-node-addon-examples/tree/master/1_hello_world/node-addon-api)**
92104
- **[Pass arguments to a function](https://github.com/nodejs/abi-stable-node-addon-examples/tree/master/2_function_arguments/node-addon-api)**
@@ -101,7 +113,7 @@ Are you new to **N-API**? Take a look at our **[examples](https://github.com/nod
101113

102114
### **Tests**
103115

104-
To run the **N-API** tests do:
116+
To run the **node-addon-api** tests do:
105117

106118
```
107119
npm install

0 commit comments

Comments
 (0)