source: trip-planner-front/node_modules/node-addon-api/README.md@ 571e0df

Last change on this file since 571e0df was e29cc2e, checked in by Ema <ema_spirova@…>, 3 years ago

primeNG components

  • Property mode set to 100644
File size: 12.6 KB
RevLine 
[e29cc2e]1NOTE: The default branch has been renamed!
2master is now named main
3
4If you have a local clone, you can update it by running:
5
6```shell
7git branch -m master main
8git fetch origin
9git branch -u origin/main main
10```
11
12# **node-addon-api module**
13This module contains **header-only C++ wrapper classes** which simplify
14the use of the C based [Node-API](https://nodejs.org/dist/latest/docs/api/n-api.html)
15provided by Node.js when using C++. It provides a C++ object model
16and exception handling semantics with low overhead.
17
18There are three options for implementing addons: Node-API, nan, or direct
19use of internal V8, libuv and Node.js libraries. Unless there is a need for
20direct access to functionality which is not exposed by Node-API as outlined
21in [C/C++ addons](https://nodejs.org/dist/latest/docs/api/addons.html)
22in Node.js core, use Node-API. Refer to
23[C/C++ addons with Node-API](https://nodejs.org/dist/latest/docs/api/n-api.html)
24for more information on Node-API.
25
26Node-API is an ABI stable C interface provided by Node.js for building native
27addons. It is independent from the underlying JavaScript runtime (e.g. V8 or ChakraCore)
28and is maintained as part of Node.js itself. It is intended to insulate
29native addons from changes in the underlying JavaScript engine and allow
30modules compiled for one version to run on later versions of Node.js without
31recompilation.
32
33The `node-addon-api` module, which is not part of Node.js, preserves the benefits
34of the Node-API as it consists only of inline code that depends only on the stable API
35provided by Node-API. As such, modules built against one version of Node.js
36using node-addon-api should run without having to be rebuilt with newer versions
37of Node.js.
38
39It is important to remember that *other* Node.js interfaces such as
40`libuv` (included in a project via `#include <uv.h>`) are not ABI-stable across
41Node.js major versions. Thus, an addon must use Node-API and/or `node-addon-api`
42exclusively and build against a version of Node.js that includes an
43implementation of Node-API (meaning an active LTS version of Node.js) in
44order to benefit from ABI stability across Node.js major versions. Node.js
45provides an [ABI stability guide][] containing a detailed explanation of ABI
46stability in general, and the Node-API ABI stability guarantee in particular.
47
48As new APIs are added to Node-API, node-addon-api must be updated to provide
49wrappers for those new APIs. For this reason node-addon-api provides
50methods that allow callers to obtain the underlying Node-API handles so
51direct calls to Node-API and the use of the objects/methods provided by
52node-addon-api can be used together. For example, in order to be able
53to use an API for which the node-addon-api does not yet provide a wrapper.
54
55APIs exposed by node-addon-api are generally used to create and
56manipulate JavaScript values. Concepts and operations generally map
57to ideas specified in the **ECMA262 Language Specification**.
58
59The [Node-API Resource](https://nodejs.github.io/node-addon-examples/) offers an
60excellent orientation and tips for developers just getting started with Node-API
61and node-addon-api.
62
63- **[Setup](#setup)**
64- **[API Documentation](#api)**
65- **[Examples](#examples)**
66- **[Tests](#tests)**
67- **[More resource and info about native Addons](#resources)**
68- **[Badges](#badges)**
69- **[Code of Conduct](CODE_OF_CONDUCT.md)**
70- **[Contributors](#contributors)**
71- **[License](#license)**
72
73## **Current version: 3.2.1**
74
75(See [CHANGELOG.md](CHANGELOG.md) for complete Changelog)
76
77[![NPM](https://nodei.co/npm/node-addon-api.png?downloads=true&downloadRank=true)](https://nodei.co/npm/node-addon-api/) [![NPM](https://nodei.co/npm-dl/node-addon-api.png?months=6&height=1)](https://nodei.co/npm/node-addon-api/)
78
79<a name="setup"></a>
80
81node-addon-api is based on [Node-API](https://nodejs.org/api/n-api.html) and supports using different Node-API versions.
82This allows addons built with it to run with Node.js versions which support the targeted Node-API version.
83**However** the node-addon-api support model is to support only the active LTS Node.js versions. This means that
84every year there will be a new major which drops support for the Node.js LTS version which has gone out of service.
85
86The oldest Node.js version supported by the current version of node-addon-api is Node.js 10.x.
87
88## Setup
89 - [Installation and usage](doc/setup.md)
90 - [node-gyp](doc/node-gyp.md)
91 - [cmake-js](doc/cmake-js.md)
92 - [Conversion tool](doc/conversion-tool.md)
93 - [Checker tool](doc/checker-tool.md)
94 - [Generator](doc/generator.md)
95 - [Prebuild tools](doc/prebuild_tools.md)
96
97<a name="api"></a>
98
99### **API Documentation**
100
101The following is the documentation for node-addon-api.
102
103 - [Full Class Hierarchy](doc/hierarchy.md)
104 - [Addon Structure](doc/addon.md)
105 - Data Types:
106 - [Env](doc/env.md)
107 - [CallbackInfo](doc/callbackinfo.md)
108 - [Reference](doc/reference.md)
109 - [Value](doc/value.md)
110 - [Name](doc/name.md)
111 - [Symbol](doc/symbol.md)
112 - [String](doc/string.md)
113 - [Number](doc/number.md)
114 - [Date](doc/date.md)
115 - [BigInt](doc/bigint.md)
116 - [Boolean](doc/boolean.md)
117 - [External](doc/external.md)
118 - [Object](doc/object.md)
119 - [Array](doc/array.md)
120 - [ObjectReference](doc/object_reference.md)
121 - [PropertyDescriptor](doc/property_descriptor.md)
122 - [Function](doc/function.md)
123 - [FunctionReference](doc/function_reference.md)
124 - [ObjectWrap](doc/object_wrap.md)
125 - [ClassPropertyDescriptor](doc/class_property_descriptor.md)
126 - [Buffer](doc/buffer.md)
127 - [ArrayBuffer](doc/array_buffer.md)
128 - [TypedArray](doc/typed_array.md)
129 - [TypedArrayOf](doc/typed_array_of.md)
130 - [DataView](doc/dataview.md)
131 - [Error Handling](doc/error_handling.md)
132 - [Error](doc/error.md)
133 - [TypeError](doc/type_error.md)
134 - [RangeError](doc/range_error.md)
135 - [Object Lifetime Management](doc/object_lifetime_management.md)
136 - [HandleScope](doc/handle_scope.md)
137 - [EscapableHandleScope](doc/escapable_handle_scope.md)
138 - [Memory Management](doc/memory_management.md)
139 - [Async Operations](doc/async_operations.md)
140 - [AsyncWorker](doc/async_worker.md)
141 - [AsyncContext](doc/async_context.md)
142 - [AsyncWorker Variants](doc/async_worker_variants.md)
143 - [Thread-safe Functions](doc/threadsafe.md)
144 - [ThreadSafeFunction](doc/threadsafe_function.md)
145 - [TypedThreadSafeFunction](doc/typed_threadsafe_function.md)
146 - [Promises](doc/promises.md)
147 - [Version management](doc/version_management.md)
148
149<a name="examples"></a>
150
151### **Examples**
152
153Are you new to **node-addon-api**? Take a look at our **[examples](https://github.com/nodejs/node-addon-examples)**
154
155- **[Hello World](https://github.com/nodejs/node-addon-examples/tree/HEAD/1_hello_world/node-addon-api)**
156- **[Pass arguments to a function](https://github.com/nodejs/node-addon-examples/tree/HEAD/2_function_arguments/node-addon-api)**
157- **[Callbacks](https://github.com/nodejs/node-addon-examples/tree/HEAD/3_callbacks/node-addon-api)**
158- **[Object factory](https://github.com/nodejs/node-addon-examples/tree/HEAD/4_object_factory/node-addon-api)**
159- **[Function factory](https://github.com/nodejs/node-addon-examples/tree/HEAD/5_function_factory/node-addon-api)**
160- **[Wrapping C++ Object](https://github.com/nodejs/node-addon-examples/tree/HEAD/6_object_wrap/node-addon-api)**
161- **[Factory of wrapped object](https://github.com/nodejs/node-addon-examples/tree/HEAD/7_factory_wrap/node-addon-api)**
162- **[Passing wrapped object around](https://github.com/nodejs/node-addon-examples/tree/HEAD/8_passing_wrapped/node-addon-api)**
163
164<a name="tests"></a>
165
166### **Tests**
167
168To run the **node-addon-api** tests do:
169
170```
171npm install
172npm test
173```
174
175To avoid testing the deprecated portions of the API run
176```
177npm install
178npm test --disable-deprecated
179```
180
181To run the tests targeting a specific version of Node-API run
182```
183npm install
184export NAPI_VERSION=X
185npm test --NAPI_VERSION=X
186```
187
188where X is the version of Node-API you want to target.
189
190### **Debug**
191
192To run the **node-addon-api** tests with `--debug` option:
193
194```
195npm run-script dev
196```
197
198If you want faster build, you might use the following option:
199
200```
201npm run-script dev:incremental
202```
203
204Take a look and get inspired by our **[test suite](https://github.com/nodejs/node-addon-api/tree/HEAD/test)**
205
206### **Benchmarks**
207
208You can run the available benchmarks using the following command:
209
210```
211npm run-script benchmark
212```
213
214See [benchmark/README.md](benchmark/README.md) for more details about running and adding benchmarks.
215
216<a name="resources"></a>
217
218### **More resource and info about native Addons**
219- **[C++ Addons](https://nodejs.org/dist/latest/docs/api/addons.html)**
220- **[Node-API](https://nodejs.org/dist/latest/docs/api/n-api.html)**
221- **[Node-API - Next Generation Node API for Native Modules](https://youtu.be/-Oniup60Afs)**
222- **[How We Migrated Realm JavaScript From NAN to Node-API](https://developer.mongodb.com/article/realm-javascript-nan-to-n-api)**
223
224As node-addon-api's core mission is to expose the plain C Node-API as C++
225wrappers, tools that facilitate n-api/node-addon-api providing more
226convenient patterns on developing a Node.js add-ons with n-api/node-addon-api
227can be published to NPM as standalone packages. It is also recommended to tag
228such packages with `node-addon-api` to provide more visibility to the community.
229
230Quick links to NPM searches: [keywords:node-addon-api](https://www.npmjs.com/search?q=keywords%3Anode-addon-api).
231
232<a name="other-bindings"></a>
233
234### **Other bindings**
235
236- **[napi-rs](https://napi.rs)** - (`Rust`)
237
238<a name="badges"></a>
239
240### **Badges**
241
242The use of badges is recommended to indicate the minimum version of Node-API
243required for the module. This helps to determine which Node.js major versions are
244supported. Addon maintainers can consult the [Node-API support matrix][] to determine
245which Node.js versions provide a given Node-API version. The following badges are
246available:
247
248![Node-API v1 Badge](https://github.com/nodejs/abi-stable-node/blob/doc/assets/Node-API%20v1%20Badge.svg)
249![Node-API v2 Badge](https://github.com/nodejs/abi-stable-node/blob/doc/assets/Node-API%20v2%20Badge.svg)
250![Node-API v3 Badge](https://github.com/nodejs/abi-stable-node/blob/doc/assets/Node-API%20v3%20Badge.svg)
251![Node-API v4 Badge](https://github.com/nodejs/abi-stable-node/blob/doc/assets/Node-API%20v4%20Badge.svg)
252![Node-API v5 Badge](https://github.com/nodejs/abi-stable-node/blob/doc/assets/Node-API%20v5%20Badge.svg)
253![Node-API v6 Badge](https://github.com/nodejs/abi-stable-node/blob/doc/assets/Node-API%20v6%20Badge.svg)
254![Node-API v7 Badge](https://github.com/nodejs/abi-stable-node/blob/doc/assets/Node-API%20v7%20Badge.svg)
255![Node-API v8 Badge](https://github.com/nodejs/abi-stable-node/blob/doc/assets/Node-API%20v8%20Badge.svg)
256![Node-API Experimental Version Badge](https://github.com/nodejs/abi-stable-node/blob/doc/assets/Node-API%20Experimental%20Version%20Badge.svg)
257
258## **Contributing**
259
260We love contributions from the community to **node-addon-api**!
261See [CONTRIBUTING.md](CONTRIBUTING.md) for more details on our philosophy around extending this module.
262
263<a name="contributors"></a>
264
265## Team members
266
267### Active
268| Name | GitHub Link |
269| ------------------- | ----------------------------------------------------- |
270| Anna Henningsen | [addaleax](https://github.com/addaleax) |
271| Chengzhong Wu | [legendecas](https://github.com/legendecas) |
272| Gabriel Schulhof | [gabrielschulhof](https://github.com/gabrielschulhof) |
273| Jim Schlight | [jschlight](https://github.com/jschlight) |
274| Michael Dawson | [mhdawson](https://github.com/mhdawson) |
275| Kevin Eady | [KevinEady](https://github.com/KevinEady)
276| Nicola Del Gobbo | [NickNaso](https://github.com/NickNaso) |
277
278### Emeritus
279| Name | GitHub Link |
280| ------------------- | ----------------------------------------------------- |
281| Arunesh Chandra | [aruneshchandra](https://github.com/aruneshchandra) |
282| Benjamin Byholm | [kkoopa](https://github.com/kkoopa) |
283| Jason Ginchereau | [jasongin](https://github.com/jasongin) |
284| Hitesh Kanwathirtha | [digitalinfinity](https://github.com/digitalinfinity) |
285| Sampson Gao | [sampsongao](https://github.com/sampsongao) |
286| Taylor Woll | [boingoing](https://github.com/boingoing) |
287
288<a name="license"></a>
289
290Licensed under [MIT](./LICENSE.md)
291
292[ABI stability guide]: https://nodejs.org/en/docs/guides/abi-stability/
293[Node-API support matrix]: https://nodejs.org/dist/latest/docs/api/n-api.html#n_api_n_api_version_matrix
Note: See TracBrowser for help on using the repository browser.