node-addon-api 3.1.0 → 3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/CHANGELOG.md +84 -0
  2. package/README.md +67 -47
  3. package/napi-inl.deprecated.h +8 -8
  4. package/napi-inl.h +118 -80
  5. package/napi.h +513 -424
  6. package/package.json +25 -5
  7. package/tools/clang-format.js +30 -10
  8. package/.clang-format +0 -111
  9. package/.editorconfig +0 -8
  10. package/.github/workflows/ci.yml +0 -55
  11. package/.github/workflows/linter.yml +0 -24
  12. package/.github/workflows/stale.yml +0 -18
  13. package/.travis.yml +0 -58
  14. package/CODE_OF_CONDUCT.md +0 -4
  15. package/CONTRIBUTING.md +0 -66
  16. package/appveyor.yml +0 -37
  17. package/benchmark/README.md +0 -47
  18. package/benchmark/binding.gyp +0 -25
  19. package/benchmark/function_args.cc +0 -217
  20. package/benchmark/function_args.js +0 -60
  21. package/benchmark/index.js +0 -34
  22. package/benchmark/property_descriptor.cc +0 -91
  23. package/benchmark/property_descriptor.js +0 -37
  24. package/doc/addon.md +0 -157
  25. package/doc/array.md +0 -81
  26. package/doc/array_buffer.md +0 -149
  27. package/doc/async_context.md +0 -86
  28. package/doc/async_operations.md +0 -31
  29. package/doc/async_worker.md +0 -427
  30. package/doc/async_worker_variants.md +0 -557
  31. package/doc/bigint.md +0 -97
  32. package/doc/boolean.md +0 -68
  33. package/doc/buffer.md +0 -144
  34. package/doc/callback_scope.md +0 -54
  35. package/doc/callbackinfo.md +0 -97
  36. package/doc/checker-tool.md +0 -32
  37. package/doc/class_property_descriptor.md +0 -117
  38. package/doc/cmake-js.md +0 -68
  39. package/doc/conversion-tool.md +0 -28
  40. package/doc/creating_a_release.md +0 -62
  41. package/doc/dataview.md +0 -248
  42. package/doc/date.md +0 -68
  43. package/doc/env.md +0 -132
  44. package/doc/error.md +0 -120
  45. package/doc/error_handling.md +0 -186
  46. package/doc/escapable_handle_scope.md +0 -82
  47. package/doc/external.md +0 -63
  48. package/doc/function.md +0 -402
  49. package/doc/function_reference.md +0 -238
  50. package/doc/generator.md +0 -13
  51. package/doc/handle_scope.md +0 -65
  52. package/doc/hierarchy.md +0 -91
  53. package/doc/instance_wrap.md +0 -408
  54. package/doc/memory_management.md +0 -27
  55. package/doc/name.md +0 -29
  56. package/doc/node-gyp.md +0 -82
  57. package/doc/number.md +0 -163
  58. package/doc/object.md +0 -279
  59. package/doc/object_lifetime_management.md +0 -83
  60. package/doc/object_reference.md +0 -117
  61. package/doc/object_wrap.md +0 -561
  62. package/doc/prebuild_tools.md +0 -16
  63. package/doc/promises.md +0 -79
  64. package/doc/property_descriptor.md +0 -286
  65. package/doc/range_error.md +0 -59
  66. package/doc/reference.md +0 -111
  67. package/doc/setup.md +0 -81
  68. package/doc/string.md +0 -93
  69. package/doc/symbol.md +0 -48
  70. package/doc/threadsafe.md +0 -121
  71. package/doc/threadsafe_function.md +0 -290
  72. package/doc/type_error.md +0 -59
  73. package/doc/typed_array.md +0 -78
  74. package/doc/typed_array_of.md +0 -137
  75. package/doc/typed_threadsafe_function.md +0 -307
  76. package/doc/value.md +0 -340
  77. package/doc/version_management.md +0 -43
package/doc/boolean.md DELETED
@@ -1,68 +0,0 @@
1
- # Boolean
2
-
3
- Class `Napi::Boolean` inherits from class [`Napi::Value`][].
4
-
5
- `Napi::Boolean` class is a representation of the JavaScript `Boolean` object. The
6
- `Napi::Boolean` class inherits its behavior from the `Napi::Value` class
7
- (for more info see: [`Napi::Value`](value.md)).
8
-
9
- ## Methods
10
-
11
- ### Constructor
12
-
13
- Creates a new empty instance of an `Napi::Boolean` object.
14
-
15
- ```cpp
16
- Napi::Boolean::Boolean();
17
- ```
18
-
19
- Returns a new _empty_ `Napi::Boolean` object.
20
-
21
- ### Constructor
22
-
23
- Creates a new instance of the `Napi::Boolean` object.
24
-
25
- ```cpp
26
- Napi::Boolean(napi_env env, napi_value value);
27
- ```
28
-
29
- - `[in] env`: The `napi_env` environment in which to construct the `Napi::Boolean` object.
30
- - `[in] value`: The `napi_value` which is a handle for a JavaScript `Boolean`.
31
-
32
- Returns a non-empty `Napi::Boolean` object.
33
-
34
- ### New
35
-
36
- Initializes a new instance of the `Napi::Boolean` object.
37
-
38
- ```cpp
39
- Napi::Boolean Napi::Boolean::New(napi_env env, bool value);
40
- ```
41
- - `[in] env`: The `napi_env` environment in which to construct the `Napi::Boolean` object.
42
- - `[in] value`: The primitive boolean value (`true` or `false`).
43
-
44
- Returns a new instance of the `Napi::Boolean` object.
45
-
46
- ### Value
47
-
48
- Converts a `Napi::Boolean` value to a boolean primitive.
49
-
50
- ```cpp
51
- bool Napi::Boolean::Value() const;
52
- ```
53
-
54
- Returns the boolean primitive type of the corresponding `Napi::Boolean` object.
55
-
56
- ## Operators
57
-
58
- ### operator bool
59
-
60
- Converts a `Napi::Boolean` value to a boolean primitive.
61
-
62
- ```cpp
63
- Napi::Boolean::operator bool() const;
64
- ```
65
-
66
- Returns the boolean primitive type of the corresponding `Napi::Boolean` object.
67
-
68
- [`Napi::Value`]: ./value.md
package/doc/buffer.md DELETED
@@ -1,144 +0,0 @@
1
- # Buffer
2
-
3
- Class `Napi::Buffer` inherits from class [`Napi::Uint8Array`][].
4
-
5
- The `Napi::Buffer` class creates a projection of raw data that can be consumed by
6
- script.
7
-
8
- ## Methods
9
-
10
- ### New
11
-
12
- Allocates a new `Napi::Buffer` object with a given length.
13
-
14
- ```cpp
15
- static Napi::Buffer<T> Napi::Buffer::New(napi_env env, size_t length);
16
- ```
17
-
18
- - `[in] env`: The environment in which to create the `Napi::Buffer` object.
19
- - `[in] length`: The number of `T` elements to allocate.
20
-
21
- Returns a new `Napi::Buffer` object.
22
-
23
- ### New
24
-
25
- Wraps the provided external data into a new `Napi::Buffer` object.
26
-
27
- The `Napi::Buffer` object does not assume ownership for the data and expects it to be
28
- valid for the lifetime of the object. Since the `Napi::Buffer` is subject to garbage
29
- collection this overload is only suitable for data which is static and never
30
- needs to be freed.
31
-
32
- ```cpp
33
- static Napi::Buffer<T> Napi::Buffer::New(napi_env env, T* data, size_t length);
34
- ```
35
-
36
- - `[in] env`: The environment in which to create the `Napi::Buffer` object.
37
- - `[in] data`: The pointer to the external data to expose.
38
- - `[in] length`: The number of `T` elements in the external data.
39
-
40
- Returns a new `Napi::Buffer` object.
41
-
42
- ### New
43
-
44
- Wraps the provided external data into a new `Napi::Buffer` object.
45
-
46
- The `Napi::Buffer` object does not assume ownership for the data and expects it
47
- to be valid for the lifetime of the object. The data can only be freed once the
48
- `finalizeCallback` is invoked to indicate that the `Napi::Buffer` has been released.
49
-
50
- ```cpp
51
- template <typename Finalizer>
52
- static Napi::Buffer<T> Napi::Buffer::New(napi_env env,
53
- T* data,
54
- size_t length,
55
- Finalizer finalizeCallback);
56
- ```
57
-
58
- - `[in] env`: The environment in which to create the `Napi::Buffer` object.
59
- - `[in] data`: The pointer to the external data to expose.
60
- - `[in] length`: The number of `T` elements in the external data.
61
- - `[in] finalizeCallback`: The function to be called when the `Napi::Buffer` is
62
- destroyed. It must implement `operator()`, accept a `T*` (which is the
63
- external data pointer), and return `void`.
64
-
65
- Returns a new `Napi::Buffer` object.
66
-
67
- ### New
68
-
69
- Wraps the provided external data into a new `Napi::Buffer` object.
70
-
71
- The `Napi::Buffer` object does not assume ownership for the data and expects it to be
72
- valid for the lifetime of the object. The data can only be freed once the
73
- `finalizeCallback` is invoked to indicate that the `Napi::Buffer` has been released.
74
-
75
- ```cpp
76
- template <typename Finalizer, typename Hint>
77
- static Napi::Buffer<T> Napi::Buffer::New(napi_env env,
78
- T* data,
79
- size_t length,
80
- Finalizer finalizeCallback,
81
- Hint* finalizeHint);
82
- ```
83
-
84
- - `[in] env`: The environment in which to create the `Napi::Buffer` object.
85
- - `[in] data`: The pointer to the external data to expose.
86
- - `[in] length`: The number of `T` elements in the external data.
87
- - `[in] finalizeCallback`: The function to be called when the `Napi::Buffer` is
88
- destroyed. It must implement `operator()`, accept a `T*` (which is the
89
- external data pointer) and `Hint*`, and return `void`.
90
- - `[in] finalizeHint`: The hint to be passed as the second parameter of the
91
- finalize callback.
92
-
93
- Returns a new `Napi::Buffer` object.
94
-
95
- ### Copy
96
-
97
- Allocates a new `Napi::Buffer` object and copies the provided external data into it.
98
-
99
- ```cpp
100
- static Napi::Buffer<T> Napi::Buffer::Copy(napi_env env, const T* data, size_t length);
101
- ```
102
-
103
- - `[in] env`: The environment in which to create the `Napi::Buffer` object.
104
- - `[in] data`: The pointer to the external data to copy.
105
- - `[in] length`: The number of `T` elements in the external data.
106
-
107
- Returns a new `Napi::Buffer` object containing a copy of the data.
108
-
109
- ### Constructor
110
-
111
- Initializes an empty instance of the `Napi::Buffer` class.
112
-
113
- ```cpp
114
- Napi::Buffer::Buffer();
115
- ```
116
-
117
- ### Constructor
118
-
119
- Initializes the `Napi::Buffer` object using an existing Uint8Array.
120
-
121
- ```cpp
122
- Napi::Buffer::Buffer(napi_env env, napi_value value);
123
- ```
124
-
125
- - `[in] env`: The environment in which to create the `Napi::Buffer` object.
126
- - `[in] value`: The Uint8Array reference to wrap.
127
-
128
- ### Data
129
-
130
- ```cpp
131
- T* Napi::Buffer::Data() const;
132
- ```
133
-
134
- Returns a pointer the external data.
135
-
136
- ### Length
137
-
138
- ```cpp
139
- size_t Napi::Buffer::Length() const;
140
- ```
141
-
142
- Returns the number of `T` elements in the external data.
143
-
144
- [`Napi::Uint8Array`]: ./typed_array_of.md
@@ -1,54 +0,0 @@
1
- # CallbackScope
2
-
3
- There are cases (for example, resolving promises) where it is necessary to have
4
- the equivalent of the scope associated with a callback in place when making
5
- certain N-API calls.
6
-
7
- ## Methods
8
-
9
- ### Constructor
10
-
11
- Creates a new callback scope on the stack.
12
-
13
- ```cpp
14
- Napi::CallbackScope::CallbackScope(napi_env env, napi_callback_scope scope);
15
- ```
16
-
17
- - `[in] env`: The environment in which to create the `Napi::CallbackScope`.
18
- - `[in] scope`: The pre-existing `napi_callback_scope` or `Napi::CallbackScope`.
19
-
20
- ### Constructor
21
-
22
- Creates a new callback scope on the stack.
23
-
24
- ```cpp
25
- Napi::CallbackScope::CallbackScope(napi_env env, napi_async_context context);
26
- ```
27
-
28
- - `[in] env`: The environment in which to create the `Napi::CallbackScope`.
29
- - `[in] async_context`: The pre-existing `napi_async_context` or `Napi::AsyncContext`.
30
-
31
- ### Destructor
32
-
33
- Deletes the instance of `Napi::CallbackScope` object.
34
-
35
- ```cpp
36
- virtual Napi::CallbackScope::~CallbackScope();
37
- ```
38
-
39
- ### Env
40
-
41
- ```cpp
42
- Napi::Env Napi::CallbackScope::Env() const;
43
- ```
44
-
45
- Returns the `Napi::Env` associated with the `Napi::CallbackScope`.
46
-
47
- ## Operator
48
-
49
- ```cpp
50
- Napi::CallbackScope::operator napi_callback_scope() const;
51
- ```
52
-
53
- Returns the N-API `napi_callback_scope` wrapped by the `Napi::CallbackScope`
54
- object. This can be used to mix usage of the C N-API and node-addon-api.
@@ -1,97 +0,0 @@
1
- # CallbackInfo
2
-
3
- The object representing the components of the JavaScript request being made.
4
-
5
- The `Napi::CallbackInfo` object is usually created and passed by the Node.js runtime or node-addon-api infrastructure.
6
-
7
- The `Napi::CallbackInfo` object contains the arguments passed by the caller. The number of arguments is returned by the `Length` method. Each individual argument can be accessed using the `operator[]` method.
8
-
9
- The `SetData` and `Data` methods are used to set and retrieve the data pointer contained in the `Napi::CallbackInfo` object.
10
-
11
- ## Methods
12
-
13
- ### Constructor
14
-
15
- ```cpp
16
- Napi::CallbackInfo::CallbackInfo(napi_env env, napi_callback_info info);
17
- ```
18
-
19
- - `[in] env`: The `napi_env` environment in which to construct the `Napi::CallbackInfo` object.
20
- - `[in] info`: The `napi_callback_info` data structure from which to construct the `Napi::CallbackInfo` object.
21
-
22
- ### Env
23
-
24
- ```cpp
25
- Napi::Env Napi::CallbackInfo::Env() const;
26
- ```
27
-
28
- Returns the `Env` object in which the request is being made.
29
-
30
- ### NewTarget
31
-
32
- ```cpp
33
- Napi::Value Napi::CallbackInfo::NewTarget() const;
34
- ```
35
-
36
- Returns the `new.target` value of the constructor call. If the function that was invoked (and for which the `Napi::NCallbackInfo` was passed) is not a constructor call, a call to `IsEmpty()` on the returned value returns true.
37
-
38
- ### IsConstructCall
39
-
40
- ```cpp
41
- bool Napi::CallbackInfo::IsConstructCall() const;
42
- ```
43
-
44
- Returns a `bool` indicating if the function that was invoked (and for which the `Napi::CallbackInfo` was passed) is a constructor call.
45
-
46
- ### Length
47
-
48
- ```cpp
49
- size_t Napi::CallbackInfo::Length() const;
50
- ```
51
-
52
- Returns the number of arguments passed in the `Napi::CallbackInfo` object.
53
-
54
- ### operator []
55
-
56
- ```cpp
57
- const Napi::Value operator [](size_t index) const;
58
- ```
59
-
60
- - `[in] index`: The zero-based index of the requested argument.
61
-
62
- Returns a `Napi::Value` object containing the requested argument.
63
-
64
- ### This
65
-
66
- ```cpp
67
- Napi::Value Napi::CallbackInfo::This() const;
68
- ```
69
-
70
- Returns the JavaScript `this` value for the call
71
-
72
- ### Data
73
-
74
- ```cpp
75
- void* Napi::CallbackInfo::Data() const;
76
- ```
77
-
78
- Returns the data pointer for the callback.
79
-
80
- ### SetData
81
-
82
- ```cpp
83
- void Napi::CallbackInfo::SetData(void* data);
84
- ```
85
-
86
- - `[in] data`: The new data pointer to associate with this `Napi::CallbackInfo` object.
87
-
88
- Returns `void`.
89
-
90
- ### Not documented here
91
-
92
- ```cpp
93
- Napi::CallbackInfo::~CallbackInfo();
94
- // Disallow copying to prevent multiple free of _dynamicArgs
95
- Napi::CallbackInfo::CallbackInfo(CallbackInfo const &) = delete;
96
- void Napi::CallbackInfo::operator=(CallbackInfo const &) = delete;
97
- ```
@@ -1,32 +0,0 @@
1
- # Checker Tool
2
-
3
- **node-addon-api** provides a [checker tool][] that will inspect a given
4
- directory tree, identifying all Node.js native addons therein, and further
5
- indicating for each addon whether it is an N-API addon.
6
-
7
- ## To use the checker tool:
8
-
9
- 1. Install the application with `npm install`.
10
-
11
- 2. If the application does not depend on **node-addon-api**, copy the
12
- checker tool into the application's directory.
13
-
14
- 3. If the application does not depend on **node-addon-api**, run the checker
15
- tool from the application's directory:
16
-
17
- ```sh
18
- node ./check-napi.js
19
- ```
20
-
21
- Otherwise, the checker tool can be run from the application's
22
- `node_modules/` subdirectory:
23
-
24
- ```sh
25
- node ./node_modules/node-addon-api/tools/check-napi.js
26
- ```
27
-
28
- The tool accepts the root directory from which to start checking for Node.js
29
- native addons as a single optional command line parameter. If omitted it will
30
- start checking from the current directory (`.`).
31
-
32
- [checker tool]: ../tools/check-napi.js
@@ -1,117 +0,0 @@
1
- # Class property and descriptor
2
-
3
- Property descriptor for use with `Napi::ObjectWrap::DefineClass()`.
4
- This is different from the standalone `Napi::PropertyDescriptor` because it is
5
- specific to each `Napi::ObjectWrap<T>` subclass.
6
- This prevents using descriptors from a different class when defining a new class
7
- (preventing the callbacks from having incorrect `this` pointers).
8
-
9
- ## Example
10
-
11
- ```cpp
12
- #include <napi.h>
13
-
14
- class Example : public Napi::ObjectWrap<Example> {
15
- public:
16
- static Napi::Object Init(Napi::Env env, Napi::Object exports);
17
- Example(const Napi::CallbackInfo &info);
18
-
19
- private:
20
- static Napi::FunctionReference constructor;
21
- double _value;
22
- Napi::Value GetValue(const Napi::CallbackInfo &info);
23
- void SetValue(const Napi::CallbackInfo &info, const Napi::Value &value);
24
- };
25
-
26
- Napi::Object Example::Init(Napi::Env env, Napi::Object exports) {
27
- Napi::Function func = DefineClass(env, "Example", {
28
- // Register a class instance accessor with getter and setter functions.
29
- InstanceAccessor<&Example::GetValue, &Example::SetValue>("value"),
30
- // We can also register a readonly accessor by omitting the setter.
31
- InstanceAccessor<&Example::GetValue>("readOnlyProp")
32
- });
33
-
34
- constructor = Napi::Persistent(func);
35
- constructor.SuppressDestruct();
36
- exports.Set("Example", func);
37
-
38
- return exports;
39
- }
40
-
41
- Example::Example(const Napi::CallbackInfo &info) : Napi::ObjectWrap<Example>(info) {
42
- Napi::Env env = info.Env();
43
- // ...
44
- Napi::Number value = info[0].As<Napi::Number>();
45
- this->_value = value.DoubleValue();
46
- }
47
-
48
- Napi::FunctionReference Example::constructor;
49
-
50
- Napi::Value Example::GetValue(const Napi::CallbackInfo &info) {
51
- Napi::Env env = info.Env();
52
- return Napi::Number::New(env, this->_value);
53
- }
54
-
55
- void Example::SetValue(const Napi::CallbackInfo &info, const Napi::Value &value) {
56
- Napi::Env env = info.Env();
57
- // ...
58
- Napi::Number arg = value.As<Napi::Number>();
59
- this->_value = arg.DoubleValue();
60
- }
61
-
62
- // Initialize native add-on
63
- Napi::Object Init (Napi::Env env, Napi::Object exports) {
64
- Example::Init(env, exports);
65
- return exports;
66
- }
67
-
68
- // Register and initialize native add-on
69
- NODE_API_MODULE(NODE_GYP_MODULE_NAME, Init)
70
- ```
71
-
72
- The above code can be used from JavaScript as follows:
73
-
74
- ```js
75
- 'use strict';
76
-
77
- const { Example } = require('bindings')('addon');
78
-
79
- const example = new Example(11);
80
- console.log(example.value);
81
- // It prints 11
82
- example.value = 19;
83
- console.log(example.value);
84
- // It prints 19
85
- example.readOnlyProp = 500;
86
- console.log(example.readOnlyProp);
87
- // Unchanged. It prints 19
88
- ```
89
-
90
- ## Methods
91
-
92
- ### Constructor
93
-
94
- Creates new instance of `Napi::ClassPropertyDescriptor` descriptor object.
95
-
96
- ```cpp
97
- Napi::ClassPropertyDescriptor(napi_property_descriptor desc) : _desc(desc) {}
98
- ```
99
-
100
- - `[in] desc`: The `napi_property_descriptor`
101
-
102
- Returns new instance of `Napi::ClassPropertyDescriptor` that is used as property descriptor
103
- inside the `Napi::ObjectWrap<T>` class.
104
-
105
- ### Operator
106
-
107
- ```cpp
108
- operator napi_property_descriptor&() { return _desc; }
109
- ```
110
-
111
- Returns the original N-API `napi_property_descriptor` wrapped inside the `Napi::ClassPropertyDescriptor`
112
-
113
- ```cpp
114
- operator const napi_property_descriptor&() const { return _desc; }
115
- ```
116
-
117
- Returns the original N-API `napi_property_descriptor` wrapped inside the `Napi::ClassPropertyDescriptor`
package/doc/cmake-js.md DELETED
@@ -1,68 +0,0 @@
1
- # CMake.js
2
-
3
- [**CMake.js**](https://github.com/cmake-js/cmake-js) is a build tool that allow native addon developers to compile their
4
- C or C++ code into executable form. It works like **[node-gyp](node-gyp.md)** but
5
- instead of Google's [**gyp**](https://gyp.gsrc.io) tool it is based on the [**CMake**](https://cmake.org) build system.
6
-
7
- ## Quick Start
8
-
9
- ### Install CMake
10
-
11
- CMake.js requires that CMake be installed. Installers for a variety of platforms can be found on the [CMake website](https://cmake.org).
12
-
13
- ### Install CMake.js
14
-
15
- For developers, CMake.js is typically installed as a global package:
16
-
17
- ```bash
18
- npm install -g cmake-js
19
- cmake-js --help
20
- ```
21
-
22
- > For *users* of your native addon, CMake.js should be configured as a dependency in your `package.json` as described in the [CMake.js documentation](https://github.com/cmake-js/cmake-js).
23
-
24
- ### CMakeLists.txt
25
-
26
- Your project will require a `CMakeLists.txt` file. The [CMake.js README file](https://github.com/cmake-js/cmake-js#usage) shows what's necessary.
27
-
28
- ### NAPI_VERSION
29
-
30
- 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:
31
-
32
- ```
33
- add_definitions(-DNAPI_VERSION=3)
34
- ```
35
-
36
- 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.
37
-
38
- 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.
39
-
40
- ### NAPI_EXPERIMENTAL
41
-
42
- The following line in the `CMakeLists.txt` file will enable N-API experimental features if your code requires them:
43
-
44
- ```
45
- add_definitions(-DNAPI_EXPERIMENTAL)
46
- ```
47
-
48
- ### node-addon-api
49
-
50
- 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).
51
-
52
- ## Example
53
-
54
- 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/master/build_with_cmake#building-n-api-addons-using-cmakejs).
55
-
56
- ## **CMake** Reference
57
-
58
- - [Installation](https://github.com/cmake-js/cmake-js#installation)
59
- - [How to use](https://github.com/cmake-js/cmake-js#usage)
60
- - [Using N-API and node-addon-api](https://github.com/cmake-js/cmake-js#n-api-and-node-addon-api)
61
- - [Tutorials](https://github.com/cmake-js/cmake-js#tutorials)
62
- - [Use case in the works - ArrayFire.js](https://github.com/cmake-js/cmake-js#use-case-in-the-works---arrayfirejs)
63
-
64
- Sometimes finding the right settings is not easy so to accomplish at most
65
- complicated task please refer to:
66
-
67
- - [CMake documentation](https://cmake.org/)
68
- - [CMake.js wiki](https://github.com/cmake-js/cmake-js/wiki)
@@ -1,28 +0,0 @@
1
- # Conversion Tool
2
-
3
- To make the migration to **node-addon-api** easier, we have provided a script to
4
- help complete some tasks.
5
-
6
- ## To use the conversion script:
7
-
8
- 1. Go to your module directory
9
-
10
- ```
11
- cd [module_path]
12
- ```
13
-
14
- 2. Install node-addon-api module
15
-
16
- ```
17
- npm install node-addon-api
18
- ```
19
- 3. Run node-addon-api conversion script
20
-
21
- ```
22
- node ./node_modules/node-addon-api/tools/conversion.js ./
23
- ```
24
-
25
- 4. While this script makes conversion easier, it still cannot fully convert
26
- the module. The next step is to try to build the module and complete the
27
- remaining conversions necessary to allow it to compile and pass all of the
28
- module's tests.
@@ -1,62 +0,0 @@
1
- # Creating a release
2
-
3
- Only collaborators in npm for **node-addon-api** can create releases.
4
- If you want to be able to do releases ask one of the existing
5
- collaborators to add you. If necessary you can ask the build
6
- Working Group who manages the Node.js npm user to add you if
7
- there are no other active collaborators.
8
-
9
- ## Prerequisites
10
-
11
- Before to start creating a new release check if you have installed the following
12
- tools:
13
-
14
- * [Changelog maker](https://www.npmjs.com/package/changelog-maker)
15
-
16
- If not please follow the instruction reported in the tool's documentation to
17
- install it.
18
-
19
- ## Publish new release
20
-
21
- These are the steps to follow to create a new release:
22
-
23
- * Open an issue in the **node-addon-api** repo documenting the intent to create a
24
- new release. Give people some time to comment or suggest PRs that should land first.
25
-
26
- * Validate all tests pass by running npm test on master.
27
-
28
- * Update the version in **package.json** appropriately.
29
-
30
- * Update the [README.md](https://github.com/nodejs/node-addon-api/blob/master/README.md)
31
- to show the new version as the latest.
32
-
33
- * Generate the changelog for the new version using **changelog maker** tool. From
34
- the route folder of the repo launch the following command:
35
-
36
- ```bash
37
- > changelog-maker
38
- ```
39
- * Use the output generated by **changelog maker** to update the [CHANGELOG.md](https://github.com/nodejs/node-addon-api/blob/master/CHANGELOG.md)
40
- following the style used in publishing the previous release.
41
-
42
- * Add any new contributors to the "contributors" section in the package.json
43
-
44
- * Validate all tests pass by running npm test on master.
45
-
46
- * Use **[CI](https://ci.nodejs.org/view/x%20-%20Abi%20stable%20module%20API/job/node-test-node-addon-api-new/)**
47
- to validate tests pass (note there are still some issues on SmartOS and
48
- Windows in the testing).
49
-
50
- * Do a clean checkout of node-addon-api.
51
-
52
- * Login and then run `npm publish`.
53
-
54
- * Create a release in Github (look at existing releases for an example).
55
-
56
- * Validate that you can run `npm install node-addon-api` successfully
57
- and that the correct version is installed.
58
-
59
- * Comment on the issue opened in the first step that the release has been created
60
- and close the issue.
61
-
62
- * Tweet that the release has been created.