node-addon-api 3.0.1 → 3.2.1

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 (74) hide show
  1. package/CHANGELOG.md +217 -0
  2. package/README.md +104 -60
  3. package/common.gypi +1 -1
  4. package/index.js +4 -3
  5. package/napi-inl.deprecated.h +8 -8
  6. package/napi-inl.h +1206 -540
  7. package/napi.h +821 -522
  8. package/package-support.json +21 -0
  9. package/package.json +80 -4
  10. package/tools/README.md +8 -2
  11. package/tools/clang-format.js +67 -0
  12. package/tools/conversion.js +4 -4
  13. package/.editorconfig +0 -8
  14. package/.travis.yml +0 -59
  15. package/CODE_OF_CONDUCT.md +0 -4
  16. package/CONTRIBUTING.md +0 -66
  17. package/appveyor.yml +0 -48
  18. package/benchmark/README.md +0 -47
  19. package/benchmark/binding.gyp +0 -25
  20. package/benchmark/function_args.cc +0 -153
  21. package/benchmark/function_args.js +0 -52
  22. package/benchmark/index.js +0 -34
  23. package/benchmark/property_descriptor.cc +0 -60
  24. package/benchmark/property_descriptor.js +0 -29
  25. package/doc/Doxyfile +0 -2450
  26. package/doc/array_buffer.md +0 -129
  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 -456
  31. package/doc/basic_types.md +0 -423
  32. package/doc/bigint.md +0 -93
  33. package/doc/boolean.md +0 -64
  34. package/doc/buffer.md +0 -140
  35. package/doc/callback_scope.md +0 -54
  36. package/doc/callbackinfo.md +0 -97
  37. package/doc/checker-tool.md +0 -32
  38. package/doc/class_property_descriptor.md +0 -117
  39. package/doc/cmake-js.md +0 -68
  40. package/doc/conversion-tool.md +0 -28
  41. package/doc/creating_a_release.md +0 -62
  42. package/doc/dataview.md +0 -244
  43. package/doc/date.md +0 -68
  44. package/doc/env.md +0 -132
  45. package/doc/error.md +0 -115
  46. package/doc/error_handling.md +0 -186
  47. package/doc/escapable_handle_scope.md +0 -82
  48. package/doc/external.md +0 -59
  49. package/doc/function.md +0 -401
  50. package/doc/function_reference.md +0 -238
  51. package/doc/generator.md +0 -13
  52. package/doc/handle_scope.md +0 -65
  53. package/doc/memory_management.md +0 -27
  54. package/doc/node-gyp.md +0 -82
  55. package/doc/number.md +0 -163
  56. package/doc/object.md +0 -275
  57. package/doc/object_lifetime_management.md +0 -83
  58. package/doc/object_reference.md +0 -117
  59. package/doc/object_wrap.md +0 -851
  60. package/doc/prebuild_tools.md +0 -16
  61. package/doc/promises.md +0 -74
  62. package/doc/property_descriptor.md +0 -286
  63. package/doc/range_error.md +0 -59
  64. package/doc/reference.md +0 -111
  65. package/doc/setup.md +0 -81
  66. package/doc/string.md +0 -89
  67. package/doc/symbol.md +0 -44
  68. package/doc/threadsafe_function.md +0 -320
  69. package/doc/type_error.md +0 -59
  70. package/doc/typed_array.md +0 -74
  71. package/doc/typed_array_of.md +0 -133
  72. package/doc/value.md +0 -278
  73. package/doc/version_management.md +0 -43
  74. package/doc/working_with_javascript_values.md +0 -14
package/doc/function.md DELETED
@@ -1,401 +0,0 @@
1
- # Function
2
-
3
- The `Napi::Function` class provides a set of methods for creating a function object in
4
- native code that can later be called from JavaScript. The created function is not
5
- automatically visible from JavaScript. Instead it needs to be part of the add-on's
6
- module exports or be returned by one of the module's exported functions.
7
-
8
- In addition the `Napi::Function` class also provides methods that can be used to call
9
- functions that were created in JavaScript and passed to the native add-on.
10
-
11
- The `Napi::Function` class inherits its behavior from the `Napi::Object` class (for more info
12
- see: [`Napi::Object`](object.md)).
13
-
14
- > For callbacks that will be called with asynchronous events from a
15
- > non-JavaScript thread, please refer to [`Napi::ThreadSafeFunction`][] for more
16
- > examples.
17
-
18
- ## Example
19
-
20
- ```cpp
21
- #include <napi.h>
22
-
23
- using namespace Napi;
24
-
25
- Value Fn(const CallbackInfo& info) {
26
- Env env = info.Env();
27
- // ...
28
- return String::New(env, "Hello World");
29
- }
30
-
31
- Object Init(Env env, Object exports) {
32
- exports.Set(String::New(env, "fn"), Function::New<Fn>(env));
33
- }
34
-
35
- NODE_API_MODULE(NODE_GYP_MODULE_NAME, Init)
36
- ```
37
-
38
- The above code can be used from JavaScript as follows:
39
-
40
- ```js
41
- const addon = require('./addon');
42
- addon.fn();
43
- ```
44
-
45
- With the `Napi::Function` class it is possible to call a JavaScript function object
46
- from a native add-on with two different methods: `Call` and `MakeCallback`.
47
- The API of these two methods is very similar, but they are used in different
48
- contexts. The `MakeCallback` method is used to call from native code back into
49
- JavaScript after returning from an [asynchronous operation](async_operations.md)
50
- and in general in situations which don't have an existing JavaScript function on
51
- the stack. The `Call` method is used when there is already a JavaScript function
52
- on the stack (for example when running a native method called from JavaScript).
53
-
54
- ## Type definitions
55
-
56
- ### Napi::Function::VoidCallback
57
-
58
- This is the type describing a callback returning `void` that will be invoked
59
- from JavaScript.
60
-
61
- ```cpp
62
- typedef void (*VoidCallback)(const Napi::CallbackInfo& info);
63
- ```
64
-
65
- ### Napi::Function::Callback
66
-
67
- This is the type describing a callback returning a value that will be invoked
68
- from JavaScript.
69
-
70
-
71
- ```cpp
72
- typedef Value (*Callback)(const Napi::CallbackInfo& info);
73
- ```
74
-
75
- ## Methods
76
-
77
- ### Constructor
78
-
79
- Creates a new empty instance of `Napi::Function`.
80
-
81
- ```cpp
82
- Napi::Function::Function();
83
- ```
84
-
85
- ### Constructor
86
-
87
- Creates a new instance of the `Napi::Function` object.
88
-
89
- ```cpp
90
- Napi::Function::Function(napi_env env, napi_value value);
91
- ```
92
-
93
- - `[in] env`: The `napi_env` environment in which to construct the `Napi::Function` object.
94
- - `[in] value`: The `napi_value` which is a handle for a JavaScript function.
95
-
96
- Returns a non-empty `Napi::Function` instance.
97
-
98
- ### New
99
-
100
- Creates an instance of a `Napi::Function` object.
101
-
102
- ```cpp
103
- template <Napi::VoidCallback cb>
104
- static Napi::Function New(napi_env env,
105
- const char* utf8name = nullptr,
106
- void* data = nullptr);
107
- ```
108
-
109
- - `[template] cb`: The native function to invoke when the JavaScript function is
110
- invoked.
111
- - `[in] env`: The `napi_env` environment in which to construct the `Napi::Function` object.
112
- - `[in] utf8name`: Null-terminated string to be used as the name of the function.
113
- - `[in] data`: User-provided data context. This will be passed back into the
114
- function when invoked later.
115
-
116
- Returns an instance of a `Napi::Function` object.
117
-
118
- ### New
119
-
120
- Creates an instance of a `Napi::Function` object.
121
-
122
- ```cpp
123
- template <Napi::Callback cb>
124
- static Napi::Function New(napi_env env,
125
- const char* utf8name = nullptr,
126
- void* data = nullptr);
127
- ```
128
-
129
- - `[template] cb`: The native function to invoke when the JavaScript function is
130
- invoked.
131
- - `[in] env`: The `napi_env` environment in which to construct the `Napi::Function` object.
132
- - `[in] utf8name`: Null-terminated string to be used as the name of the function.
133
- - `[in] data`: User-provided data context. This will be passed back into the
134
- function when invoked later.
135
-
136
- Returns an instance of a `Napi::Function` object.
137
-
138
- ### New
139
-
140
- Creates an instance of a `Napi::Function` object.
141
-
142
- ```cpp
143
- template <Napi::VoidCallback cb>
144
- static Napi::Function New(napi_env env,
145
- const std::string& utf8name,
146
- void* data = nullptr);
147
- ```
148
-
149
- - `[template] cb`: The native function to invoke when the JavaScript function is
150
- invoked.
151
- - `[in] env`: The `napi_env` environment in which to construct the `Napi::Function` object.
152
- - `[in] utf8name`: String to be used as the name of the function.
153
- - `[in] data`: User-provided data context. This will be passed back into the
154
- function when invoked later.
155
-
156
- Returns an instance of a `Napi::Function` object.
157
-
158
- ### New
159
-
160
- Creates an instance of a `Napi::Function` object.
161
-
162
- ```cpp
163
- template <Napi::Callback cb>
164
- static Napi::Function New(napi_env env,
165
- const std::string& utf8name,
166
- void* data = nullptr);
167
- ```
168
-
169
- - `[template] cb`: The native function to invoke when the JavaScript function is
170
- invoked.
171
- - `[in] env`: The `napi_env` environment in which to construct the `Napi::Function` object.
172
- - `[in] utf8name`: String to be used as the name of the function.
173
- - `[in] data`: User-provided data context. This will be passed back into the
174
- function when invoked later.
175
-
176
- Returns an instance of a `Napi::Function` object.
177
-
178
- ### New
179
-
180
- Creates an instance of a `Napi::Function` object.
181
-
182
- ```cpp
183
- template <typename Callable>
184
- static Napi::Function Napi::Function::New(napi_env env, Callable cb, const char* utf8name = nullptr, void* data = nullptr);
185
- ```
186
-
187
- - `[in] env`: The `napi_env` environment in which to construct the `Napi::Function` object.
188
- - `[in] cb`: Object that implements `Callable`.
189
- - `[in] utf8name`: Null-terminated string to be used as the name of the function.
190
- - `[in] data`: User-provided data context. This will be passed back into the
191
- function when invoked later.
192
-
193
- Returns an instance of a `Napi::Function` object.
194
-
195
- ### New
196
-
197
- ```cpp
198
- template <typename Callable>
199
- static Napi::Function Napi::Function::New(napi_env env, Callable cb, const std::string& utf8name, void* data = nullptr);
200
- ```
201
-
202
- - `[in] env`: The `napi_env` environment in which to construct the `Napi::Function` object.
203
- - `[in] cb`: Object that implements `Callable`.
204
- - `[in] utf8name`: String to be used as the name of the function.
205
- - `[in] data`: User-provided data context. This will be passed back into the
206
- function when invoked later.
207
-
208
- Returns an instance of a `Napi::Function` object.
209
-
210
- ### New
211
-
212
- Creates a new JavaScript value from one that represents the constructor for the
213
- object.
214
-
215
- ```cpp
216
- Napi::Object Napi::Function::New(const std::initializer_list<napi_value>& args) const;
217
- ```
218
-
219
- - `[in] args`: Initializer list of JavaScript values as `napi_value` representing
220
- the arguments of the contructor function.
221
-
222
- Returns a new JavaScript object.
223
-
224
- ### New
225
-
226
- Creates a new JavaScript value from one that represents the constructor for the
227
- object.
228
-
229
- ```cpp
230
- Napi::Object Napi::Function::New(const std::vector<napi_value>& args) const;
231
- ```
232
-
233
- - `[in] args`: Vector of JavaScript values as `napi_value` representing the
234
- arguments of the constructor function.
235
-
236
- Returns a new JavaScript object.
237
-
238
- ### New
239
-
240
- Creates a new JavaScript value from one that represents the constructor for the
241
- object.
242
-
243
- ```cpp
244
- Napi::Object Napi::Function::New(size_t argc, const napi_value* args) const;
245
- ```
246
-
247
- - `[in] argc`: The number of the arguments passed to the contructor function.
248
- - `[in] args`: Array of JavaScript values as `napi_value` representing the
249
- arguments of the constructor function.
250
-
251
- Returns a new JavaScript object.
252
-
253
- ### Call
254
-
255
- Calls a Javascript function from a native add-on.
256
-
257
- ```cpp
258
- Napi::Value Napi::Function::Call(const std::initializer_list<napi_value>& args) const;
259
- ```
260
-
261
- - `[in] args`: Initializer list of JavaScript values as `napi_value` representing
262
- the arguments of the function.
263
-
264
- Returns a `Napi::Value` representing the JavaScript value returned by the function.
265
-
266
- ### Call
267
-
268
- Calls a JavaScript function from a native add-on.
269
-
270
- ```cpp
271
- Napi::Value Napi::Function::Call(const std::vector<napi_value>& args) const;
272
- ```
273
-
274
- - `[in] args`: Vector of JavaScript values as `napi_value` representing the
275
- arguments of the function.
276
-
277
- Returns a `Napi::Value` representing the JavaScript value returned by the function.
278
-
279
- ### Call
280
-
281
- Calls a Javascript function from a native add-on.
282
-
283
- ```cpp
284
- Napi::Value Napi::Function::Call(size_t argc, const napi_value* args) const;
285
- ```
286
-
287
- - `[in] argc`: The number of the arguments passed to the function.
288
- - `[in] args`: Array of JavaScript values as `napi_value` representing the
289
- arguments of the function.
290
-
291
- Returns a `Napi::Value` representing the JavaScript value returned by the function.
292
-
293
- ### Call
294
-
295
- Calls a Javascript function from a native add-on.
296
-
297
- ```cpp
298
- Napi::Value Napi::Function::Call(napi_value recv, const std::initializer_list<napi_value>& args) const;
299
- ```
300
-
301
- - `[in] recv`: The `this` object passed to the called function.
302
- - `[in] args`: Initializer list of JavaScript values as `napi_value` representing
303
- the arguments of the function.
304
-
305
- Returns a `Napi::Value` representing the JavaScript value returned by the function.
306
-
307
- ### Call
308
-
309
- Calls a Javascript function from a native add-on.
310
-
311
- ```cpp
312
- Napi::Value Napi::Function::Call(napi_value recv, const std::vector<napi_value>& args) const;
313
- ```
314
-
315
- - `[in] recv`: The `this` object passed to the called function.
316
- - `[in] args`: Vector of JavaScript values as `napi_value` representing the
317
- arguments of the function.
318
-
319
- Returns a `Napi::Value` representing the JavaScript value returned by the function.
320
-
321
- ### Call
322
-
323
- Calls a Javascript function from a native add-on.
324
-
325
- ```cpp
326
- Napi::Value Napi::Function::Call(napi_value recv, size_t argc, const napi_value* args) const;
327
- ```
328
-
329
- - `[in] recv`: The `this` object passed to the called function.
330
- - `[in] argc`: The number of the arguments passed to the function.
331
- - `[in] args`: Array of JavaScript values as `napi_value` representing the
332
- arguments of the function.
333
-
334
- Returns a `Napi::Value` representing the JavaScript value returned by the function.
335
-
336
- ### MakeCallback
337
-
338
- Calls a Javascript function from a native add-on after an asynchronous operation.
339
-
340
- ```cpp
341
- Napi::Value Napi::Function::MakeCallback(napi_value recv, const std::initializer_list<napi_value>& args, napi_async_context context = nullptr) const;
342
- ```
343
-
344
- - `[in] recv`: The `this` object passed to the called function.
345
- - `[in] args`: Initializer list of JavaScript values as `napi_value` representing
346
- the arguments of the function.
347
- - `[in] context`: Context for the async operation that is invoking the callback.
348
- This should normally be a value previously obtained from [Napi::AsyncContext](async_context.md).
349
- However `nullptr` is also allowed, which indicates the current async context
350
- (if any) is to be used for the callback.
351
-
352
- Returns a `Napi::Value` representing the JavaScript value returned by the function.
353
-
354
- ### MakeCallback
355
-
356
- Calls a Javascript function from a native add-on after an asynchronous operation.
357
-
358
- ```cpp
359
- Napi::Value Napi::Function::MakeCallback(napi_value recv, const std::vector<napi_value>& args, napi_async_context context = nullptr) const;
360
- ```
361
-
362
- - `[in] recv`: The `this` object passed to the called function.
363
- - `[in] args`: List of JavaScript values as `napi_value` representing the
364
- arguments of the function.
365
- - `[in] context`: Context for the async operation that is invoking the callback.
366
- This should normally be a value previously obtained from [Napi::AsyncContext](async_context.md).
367
- However `nullptr` is also allowed, which indicates the current async context
368
- (if any) is to be used for the callback.
369
-
370
- Returns a `Napi::Value` representing the JavaScript value returned by the function.
371
-
372
- ### MakeCallback
373
-
374
- Calls a Javascript function from a native add-on after an asynchronous operation.
375
-
376
- ```cpp
377
- Napi::Value Napi::Function::MakeCallback(napi_value recv, size_t argc, const napi_value* args, napi_async_context context = nullptr) const;
378
- ```
379
-
380
- - `[in] recv`: The `this` object passed to the called function.
381
- - `[in] argc`: The number of the arguments passed to the function.
382
- - `[in] args`: Array of JavaScript values as `napi_value` representing the
383
- arguments of the function.
384
- - `[in] context`: Context for the async operation that is invoking the callback.
385
- This should normally be a value previously obtained from [Napi::AsyncContext](async_context.md).
386
- However `nullptr` is also allowed, which indicates the current async context
387
- (if any) is to be used for the callback.
388
-
389
- Returns a `Napi::Value` representing the JavaScript value returned by the function.
390
-
391
- ## Operator
392
-
393
- ```cpp
394
- Napi::Value Napi::Function::operator ()(const std::initializer_list<napi_value>& args) const;
395
- ```
396
-
397
- - `[in] args`: Initializer list of JavaScript values as `napi_value`.
398
-
399
- Returns a `Napi::Value` representing the JavaScript value returned by the function.
400
-
401
- [`Napi::ThreadSafeFunction`]: ./threadsafe_function.md
@@ -1,238 +0,0 @@
1
- # FunctionReference
2
-
3
- `Napi::FunctionReference` is a subclass of [`Napi::Reference`](reference.md), and
4
- is equivalent to an instance of `Napi::Reference<Napi::Function>`. This means
5
- that a `Napi::FunctionReference` holds a [`Napi::Function`](function.md), and a
6
- count of the number of references to that `Napi::Function`. When the count is
7
- greater than 0, a `Napi::FunctionReference` is not eligible for garbage collection.
8
- This ensures that the `Function` will remain accessible, even if the original
9
- reference to it is no longer available.
10
- `Napi::FunctionReference` allows the referenced JavaScript function object to be
11
- called from a native add-on with two different methods: `Call` and `MakeCallback`.
12
- See the documentation for [`Napi::Function`](function.md) for when `Call` should
13
- be used instead of `MakeCallback` and vice-versa.
14
-
15
- The `Napi::FunctionReference` class inherits its behavior from the `Napi::Reference`
16
- class (for more info see: [`Napi::Reference`](reference.md)).
17
-
18
- ## Methods
19
-
20
- ### Weak
21
-
22
- Creates a "weak" reference to the value, in that the initial reference count is
23
- set to 0.
24
-
25
- ```cpp
26
- static Napi::FunctionReference Napi::Weak(const Napi::Function& value);
27
- ```
28
-
29
- - `[in] value`: The value which is to be referenced.
30
-
31
- Returns the newly created reference.
32
-
33
- ### Persistent
34
-
35
- Creates a "persistent" reference to the value, in that the initial reference
36
- count is set to 1.
37
-
38
- ```cpp
39
- static Napi::FunctionReference Napi::Persistent(const Napi::Function& value);
40
- ```
41
-
42
- - `[in] value`: The value which is to be referenced.
43
-
44
- Returns the newly created reference.
45
-
46
- ### Constructor
47
-
48
- Creates a new empty instance of `Napi::FunctionReference`.
49
-
50
- ```cpp
51
- Napi::FunctionReference::FunctionReference();
52
- ```
53
-
54
- ### Constructor
55
-
56
- Creates a new instance of the `Napi::FunctionReference`.
57
-
58
- ```cpp
59
- Napi::FunctionReference::FunctionReference(napi_env env, napi_ref ref);
60
- ```
61
-
62
- - `[in] env`: The environment in which to construct the `Napi::FunctionReference` object.
63
- - `[in] ref`: The N-API reference to be held by the `Napi::FunctionReference`.
64
-
65
- Returns a newly created `Napi::FunctionReference` object.
66
-
67
- ### New
68
-
69
- Constructs a new instance by calling the constructor held by this reference.
70
-
71
- ```cpp
72
- Napi::Object Napi::FunctionReference::New(const std::initializer_list<napi_value>& args) const;
73
- ```
74
-
75
- - `[in] args`: Initializer list of JavaScript values as `napi_value` representing
76
- the arguments of the contructor function.
77
-
78
- Returns a new JavaScript object.
79
-
80
- ### New
81
-
82
- Constructs a new instance by calling the constructor held by this reference.
83
-
84
- ```cpp
85
- Napi::Object Napi::FunctionReference::New(const std::vector<napi_value>& args) const;
86
- ```
87
-
88
- - `[in] args`: Vector of JavaScript values as `napi_value` representing the
89
- arguments of the constructor function.
90
-
91
- Returns a new JavaScript object.
92
-
93
- ### Call
94
-
95
- Calls a referenced Javascript function from a native add-on.
96
-
97
- ```cpp
98
- Napi::Value Napi::FunctionReference::Call(const std::initializer_list<napi_value>& args) const;
99
- ```
100
-
101
- - `[in] args`: Initializer list of JavaScript values as `napi_value` representing
102
- the arguments of the referenced function.
103
-
104
- Returns a `Napi::Value` representing the JavaScript object returned by the referenced
105
- function.
106
-
107
- ### Call
108
-
109
- Calls a referenced JavaScript function from a native add-on.
110
-
111
- ```cpp
112
- Napi::Value Napi::FunctionReference::Call(const std::vector<napi_value>& args) const;
113
- ```
114
-
115
- - `[in] args`: Vector of JavaScript values as `napi_value` representing the
116
- arguments of the referenced function.
117
-
118
- Returns a `Napi::Value` representing the JavaScript object returned by the referenced
119
- function.
120
-
121
- ### Call
122
-
123
- Calls a referenced JavaScript function from a native add-on.
124
-
125
- ```cpp
126
- Napi::Value Napi::FunctionReference::Call(napi_value recv, const std::initializer_list<napi_value>& args) const;
127
- ```
128
-
129
- - `[in] recv`: The `this` object passed to the referenced function when it's called.
130
- - `[in] args`: Initializer list of JavaScript values as `napi_value` representing
131
- the arguments of the referenced function.
132
-
133
- Returns a `Napi::Value` representing the JavaScript object returned by the referenced
134
- function.
135
-
136
- ### Call
137
-
138
- Calls a referenced JavaScript function from a native add-on.
139
-
140
- ```cpp
141
- Napi::Value Napi::FunctionReference::Call(napi_value recv, const std::vector<napi_value>& args) const;
142
- ```
143
-
144
- - `[in] recv`: The `this` object passed to the referenced function when it's called.
145
- - `[in] args`: Vector of JavaScript values as `napi_value` representing the
146
- arguments of the referenced function.
147
-
148
- Returns a `Napi::Value` representing the JavaScript object returned by the referenced
149
- function.
150
-
151
- ### Call
152
-
153
- Calls a referenced JavaScript function from a native add-on.
154
-
155
- ```cpp
156
- Napi::Value Napi::FunctionReference::Call(napi_value recv, size_t argc, const napi_value* args) const;
157
- ```
158
-
159
- - `[in] recv`: The `this` object passed to the referenced function when it's called.
160
- - `[in] argc`: The number of arguments passed to the referenced function.
161
- - `[in] args`: Array of JavaScript values as `napi_value` representing the
162
- arguments of the referenced function.
163
-
164
- Returns a `Napi::Value` representing the JavaScript object returned by the referenced
165
- function.
166
-
167
-
168
- ### MakeCallback
169
-
170
- Calls a referenced JavaScript function from a native add-on after an asynchronous
171
- operation.
172
-
173
- ```cpp
174
- Napi::Value Napi::FunctionReference::MakeCallback(napi_value recv, const std::initializer_list<napi_value>& args, napi_async_context = nullptr) const;
175
- ```
176
-
177
- - `[in] recv`: The `this` object passed to the referenced function when it's called.
178
- - `[in] args`: Initializer list of JavaScript values as `napi_value` representing
179
- the arguments of the referenced function.
180
- - `[in] context`: Context for the async operation that is invoking the callback.
181
- This should normally be a value previously obtained from [Napi::AsyncContext](async_context.md).
182
- However `nullptr` is also allowed, which indicates the current async context
183
- (if any) is to be used for the callback.
184
-
185
- Returns a `Napi::Value` representing the JavaScript object returned by the referenced
186
- function.
187
-
188
- ### MakeCallback
189
-
190
- Calls a referenced JavaScript function from a native add-on after an asynchronous
191
- operation.
192
-
193
- ```cpp
194
- Napi::Value Napi::FunctionReference::MakeCallback(napi_value recv, const std::vector<napi_value>& args, napi_async_context context = nullptr) const;
195
- ```
196
-
197
- - `[in] recv`: The `this` object passed to the referenced function when it's called.
198
- - `[in] args`: Vector of JavaScript values as `napi_value` representing the
199
- arguments of the referenced function.
200
- - `[in] context`: Context for the async operation that is invoking the callback.
201
- This should normally be a value previously obtained from [Napi::AsyncContext](async_context.md).
202
- However `nullptr` is also allowed, which indicates the current async context
203
- (if any) is to be used for the callback.
204
-
205
- Returns a `Napi::Value` representing the JavaScript object returned by the referenced
206
- function.
207
-
208
- ### MakeCallback
209
-
210
- Calls a referenced JavaScript function from a native add-on after an asynchronous
211
- operation.
212
-
213
- ```cpp
214
- Napi::Value Napi::FunctionReference::MakeCallback(napi_value recv, size_t argc, const napi_value* args, napi_async_context context = nullptr) const;
215
- ```
216
-
217
- - `[in] recv`: The `this` object passed to the referenced function when it's called.
218
- - `[in] argc`: The number of arguments passed to the referenced function.
219
- - `[in] args`: Array of JavaScript values as `napi_value` representing the
220
- arguments of the referenced function.
221
- - `[in] context`: Context for the async operation that is invoking the callback.
222
- This should normally be a value previously obtained from [Napi::AsyncContext](async_context.md).
223
- However `nullptr` is also allowed, which indicates the current async context
224
- (if any) is to be used for the callback.
225
-
226
- Returns a `Napi::Value` representing the JavaScript object returned by the referenced
227
- function.
228
-
229
- ## Operator
230
-
231
- ```cpp
232
- Napi::Value operator ()(const std::initializer_list<napi_value>& args) const;
233
- ```
234
-
235
- - `[in] args`: Initializer list of reference to JavaScript values as `napi_value`
236
-
237
- Returns a `Napi::Value` representing the JavaScript value returned by the referenced
238
- function.
package/doc/generator.md DELETED
@@ -1,13 +0,0 @@
1
- # Generator
2
-
3
- ## What is generator
4
-
5
- **[generator-napi-module](https://www.npmjs.com/package/generator-napi-module)** is a module to quickly generate a skeleton module using
6
- **N-API**, the new API for Native addons. This module automatically sets up your
7
- **gyp file** to use **node-addon-api**, the C++ wrappers for N-API and generates
8
- a wrapper JS module. Optionally, it can even configure the generated project to
9
- use **TypeScript** instead.
10
-
11
- ## **generator-napi-module** reference
12
-
13
- - [Installation and usage](https://www.npmjs.com/package/generator-napi-module#installation)