node-addon-api 3.0.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 (74) hide show
  1. package/CHANGELOG.md +242 -2
  2. package/README.md +106 -62
  3. package/common.gypi +1 -1
  4. package/index.js +5 -2
  5. package/napi-inl.deprecated.h +8 -8
  6. package/napi-inl.h +1221 -548
  7. package/napi.h +823 -524
  8. package/package-support.json +21 -0
  9. package/package.json +96 -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 -77
  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 -833
  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
@@ -1,833 +0,0 @@
1
- # Object Wrap
2
-
3
- The `Napi::ObjectWrap` class is used to bind the lifetime of C++ code to a
4
- JavaScript object. Once bound, each time an instance of the JavaScript object
5
- is created, an instance of the C++ class will also be created. When a method
6
- is called on the JavaScript object which is defined as an InstanceMethod, the
7
- corresponding C++ method on the wrapped C++ class will be invoked.
8
-
9
- In order to create a wrapper it's necessary to extend the
10
- `Napi::ObjectWrap`class which contains all the plumbing to connect JavaScript code
11
- with a C++ object. Classes extending `Napi::ObjectWrap` can be instantiated from
12
- JavaScript using the **new** operator, and their methods can be directly invoked
13
- from JavaScript. The **wrap** word refers to a way of grouping methods and state
14
- of the class because it will be necessary write custom code to bridge each of
15
- your C++ class methods.
16
-
17
- ## Example
18
-
19
- ```cpp
20
- #include <napi.h>
21
-
22
- class Example : public Napi::ObjectWrap<Example> {
23
- public:
24
- static Napi::Object Init(Napi::Env env, Napi::Object exports);
25
- Example(const Napi::CallbackInfo &info);
26
-
27
- private:
28
- static Napi::FunctionReference constructor;
29
- double _value;
30
- Napi::Value GetValue(const Napi::CallbackInfo &info);
31
- Napi::Value SetValue(const Napi::CallbackInfo &info);
32
- };
33
-
34
- Napi::Object Example::Init(Napi::Env env, Napi::Object exports) {
35
- // This method is used to hook the accessor and method callbacks
36
- Napi::Function func = DefineClass(env, "Example", {
37
- InstanceMethod<&Example::GetValue>("GetValue"),
38
- InstanceMethod<&Example::SetValue>("SetValue")
39
- });
40
-
41
- // Create a peristent reference to the class constructor. This will allow
42
- // a function called on a class prototype and a function
43
- // called on instance of a class to be distinguished from each other.
44
- constructor = Napi::Persistent(func);
45
- // Call the SuppressDestruct() method on the static data prevent the calling
46
- // to this destructor to reset the reference when the environment is no longer
47
- // available.
48
- constructor.SuppressDestruct();
49
- exports.Set("Example", func);
50
- return exports;
51
- }
52
-
53
- Example::Example(const Napi::CallbackInfo &info) : Napi::ObjectWrap<Example>(info) {
54
- Napi::Env env = info.Env();
55
- // ...
56
- Napi::Number value = info[0].As<Napi::Number>();
57
- this->_value = value.DoubleValue();
58
- }
59
-
60
- Napi::FunctionReference Example::constructor;
61
-
62
- Napi::Value Example::GetValue(const Napi::CallbackInfo &info){
63
- Napi::Env env = info.Env();
64
- return Napi::Number::New(env, this->_value);
65
- }
66
-
67
- Napi::Value Example::SetValue(const Napi::CallbackInfo &info){
68
- Napi::Env env = info.Env();
69
- // ...
70
- Napi::Number value = info[0].As<Napi::Number>();
71
- this->_value = value.DoubleValue();
72
- return this->GetValue(info);
73
- }
74
-
75
- // Initialize native add-on
76
- Napi::Object Init (Napi::Env env, Napi::Object exports) {
77
- Example::Init(env, exports);
78
- return exports;
79
- }
80
-
81
- // Register and initialize native add-on
82
- NODE_API_MODULE(NODE_GYP_MODULE_NAME, Init)
83
- ```
84
-
85
- The above code can be used from JavaScript as follows:
86
-
87
- ```js
88
- 'use strict'
89
-
90
- const { Example } = require('bindings')('addon')
91
-
92
- const example = new Example(11)
93
- console.log(example.GetValue())
94
- // It prints 11
95
- example.SetValue(19)
96
- console.log(example.GetValue());
97
- // It prints 19
98
- ```
99
-
100
- At initialization time, the `Napi::ObjectWrap::DefineClass()` method must be used
101
- to hook up the accessor and method callbacks. It takes a list of property
102
- descriptors, which can be constructed via the various static methods on the base
103
- class.
104
-
105
- When JavaScript code invokes the constructor, the constructor callback will create
106
- a new C++ instance and "wrap" it into the newly created JavaScript object.
107
-
108
- When JavaScript code invokes a method or a property accessor on the class the
109
- corresponding C++ callback function will be executed.
110
-
111
- For a wrapped object it could be difficult to distinguish between a function called
112
- on a class prototype and a function called on instance of a class. Therefore it is
113
- good practice to save a persistent reference to the class constructor. This allows
114
- the two cases to be distinguished from each other by checking the this object
115
- against the class constructor.
116
-
117
- ## Methods
118
-
119
- ### Constructor
120
-
121
- Creates a new instance of a JavaScript object that wraps native instance.
122
-
123
- ```cpp
124
- Napi::ObjectWrap(const Napi::CallbackInfo& callbackInfo);
125
- ```
126
-
127
- - `[in] callbackInfo`: The object representing the components of the JavaScript
128
- request being made.
129
-
130
- ### Unwrap
131
-
132
- Retrieves a native instance wrapped in a JavaScript object.
133
-
134
- ```cpp
135
- static T* Napi::ObjectWrap::Unwrap(Napi::Object wrapper);
136
- ```
137
-
138
- * `[in] wrapper`: The JavaScript object that wraps the native instance.
139
-
140
- Returns a native instace wrapped in a JavaScript object. Given the
141
- Napi:Object, this allows a method to get a pointer to the wrapped
142
- C++ object and then reference fields, call methods, etc. within that class.
143
- In many cases calling Unwrap is not required, as methods can
144
- use the `this` field for ObjectWrap when running in a method on a
145
- class that extends ObjectWrap.
146
-
147
- ### DefineClass
148
-
149
- Defnines a JavaScript class with constructor, static and instance properties and
150
- methods.
151
-
152
- ```cpp
153
- static Napi::Function Napi::ObjectWrap::DefineClass(Napi::Env env,
154
- const char* utf8name,
155
- const std::initializer_list<PropertyDescriptor>& properties,
156
- void* data = nullptr);
157
- ```
158
-
159
- * `[in] env`: The environment in which to construct a JavaScript class.
160
- * `[in] utf8name`: Null-terminated string that represents the name of the
161
- JavaScript constructor function.
162
- * `[in] properties`: Initializer list of class property descriptor describing
163
- static and instance properties and methods of the class.
164
- See: [`Class property and descriptor`](class_property_descriptor.md).
165
- * `[in] data`: User-provided data passed to the constructor callback as `data`
166
- property of the `Napi::CallbackInfo`.
167
-
168
- Returns a `Napi::Function` representing the constructor function for the class.
169
-
170
- ### DefineClass
171
-
172
- Defnines a JavaScript class with constructor, static and instance properties and
173
- methods.
174
-
175
- ```cpp
176
- static Napi::Function Napi::ObjectWrap::DefineClass(Napi::Env env,
177
- const char* utf8name,
178
- const std::vector<PropertyDescriptor>& properties,
179
- void* data = nullptr);
180
- ```
181
-
182
- * `[in] env`: The environment in which to construct a JavaScript class.
183
- * `[in] utf8name`: Null-terminated string that represents the name of the
184
- JavaScript constructor function.
185
- * `[in] properties`: Vector of class property descriptor describing static and
186
- instance properties and methods of the class.
187
- See: [`Class property and descriptor`](class_property_descriptor.md).
188
- * `[in] data`: User-provided data passed to the constructor callback as `data`
189
- property of the `Napi::CallbackInfo`.
190
-
191
- Returns a `Napi::Function` representing the constructor function for the class.
192
-
193
- ### Finalize
194
-
195
- Provides an opportunity to run cleanup code that requires access to the `Napi::Env`
196
- before the wrapped native object instance is freed. Override to implement.
197
-
198
- ```cpp
199
- virtual void Finalize(Napi::Env env);
200
- ```
201
-
202
- - `[in] env`: `Napi::Env`.
203
-
204
- ### StaticMethod
205
-
206
- Creates property descriptor that represents a static method of a JavaScript class.
207
-
208
- ```cpp
209
- static Napi::PropertyDescriptor Napi::ObjectWrap::StaticMethod(const char* utf8name,
210
- StaticVoidMethodCallback method,
211
- napi_property_attributes attributes = napi_default,
212
- void* data = nullptr);
213
- ```
214
-
215
- - `[in] utf8name`: Null-terminated string that represents the name of a static
216
- method for the class.
217
- - `[in] method`: The native function that represents a static method of a
218
- JavaScript class.
219
- - `[in] attributes`: The attributes associated with a particular property.
220
- One or more of `napi_property_attributes`.
221
- - `[in] data`: User-provided data passed into method when it is invoked.
222
-
223
- Returns `Napi::PropertyDescriptor` object that represents the static method of a
224
- JavaScript class.
225
-
226
- ### StaticMethod
227
-
228
- Creates property descriptor that represents a static method of a JavaScript class.
229
-
230
- ```cpp
231
- static Napi::PropertyDescriptor Napi::ObjectWrap::StaticMethod(const char* utf8name,
232
- StaticMethodCallback method,
233
- napi_property_attributes attributes = napi_default,
234
- void* data = nullptr);
235
- ```
236
-
237
- - `[in] utf8name`: Null-terminated string that represents the name of a static
238
- method for the class.
239
- - `[in] method`: The native function that represents a static method of a
240
- JavaScript class.
241
- - `[in] attributes`: The attributes associated with a particular property.
242
- One or more of `napi_property_attributes`.
243
- - `[in] data`: User-provided data passed into method when it is invoked.
244
-
245
- Returns `Napi::PropertyDescriptor` object that represents a static method of a
246
- JavaScript class.
247
-
248
- ### StaticMethod
249
-
250
- Creates property descriptor that represents a static method of a JavaScript class.
251
-
252
- ```cpp
253
- static Napi::PropertyDescriptor Napi::ObjectWrap::StaticMethod(Symbol name,
254
- StaticVoidMethodCallback method,
255
- napi_property_attributes attributes = napi_default,
256
- void* data = nullptr);
257
- ```
258
-
259
- - `[in] name`: Napi:Symbol that represents the name of a static
260
- method for the class.
261
- - `[in] method`: The native function that represents a static method of a
262
- JavaScript class.
263
- - `[in] attributes`: The attributes associated with a particular property.
264
- One or more of `napi_property_attributes`.
265
- - `[in] data`: User-provided data passed into method when it is invoked.
266
-
267
- Returns `Napi::PropertyDescriptor` object that represents the static method of a
268
- JavaScript class.
269
-
270
- ### StaticMethod
271
-
272
- Creates property descriptor that represents a static method of a JavaScript class.
273
-
274
- ```cpp
275
- static Napi::PropertyDescriptor Napi::ObjectWrap::StaticMethod(Symbol name,
276
- StaticMethodCallback method,
277
- napi_property_attributes attributes = napi_default,
278
- void* data = nullptr);
279
- ```
280
-
281
- method for the class.
282
- - `[in] name`: Napi:Symbol that represents the name of a static.
283
- - `[in] method`: The native function that represents a static method of a
284
- JavaScript class.
285
- - `[in] attributes`: The attributes associated with a particular property.
286
- One or more of `napi_property_attributes`.
287
- - `[in] data`: User-provided data passed into method when it is invoked.
288
-
289
- Returns `Napi::PropertyDescriptor` object that represents a static method of a
290
- JavaScript class.
291
-
292
- ### StaticMethod
293
-
294
- Creates property descriptor that represents a static method of a JavaScript class.
295
-
296
- ```cpp
297
- template <StaticVoidMethodCallback method>
298
- static Napi::PropertyDescriptor Napi::ObjectWrap::StaticMethod(const char* utf8name,
299
- napi_property_attributes attributes = napi_default,
300
- void* data = nullptr);
301
- ```
302
-
303
- - `[in] method`: The native function that represents a static method of a
304
- JavaScript class. This function returns nothing.
305
- - `[in] utf8name`: Null-terminated string that represents the name of a static
306
- method for the class.
307
- - `[in] attributes`: The attributes associated with a particular property.
308
- One or more of `napi_property_attributes`.
309
- - `[in] data`: User-provided data passed into method when it is invoked.
310
-
311
- Returns `Napi::PropertyDescriptor` object that represents the static method of a
312
- JavaScript class.
313
-
314
- ### StaticMethod
315
-
316
- Creates property descriptor that represents a static method of a JavaScript class.
317
-
318
- ```cpp
319
- template <StaticMethodCallback method>
320
- static Napi::PropertyDescriptor Napi::ObjectWrap::StaticMethod(const char* utf8name,
321
- napi_property_attributes attributes = napi_default,
322
- void* data = nullptr);
323
- ```
324
-
325
- - `[in] method`: The native function that represents a static method of a
326
- JavaScript class.
327
- - `[in] utf8name`: Null-terminated string that represents the name of a static
328
- method for the class.
329
- - `[in] attributes`: The attributes associated with a particular property.
330
- One or more of `napi_property_attributes`.
331
- - `[in] data`: User-provided data passed into method when it is invoked.
332
-
333
- Returns `Napi::PropertyDescriptor` object that represents a static method of a
334
- JavaScript class.
335
-
336
- ### StaticMethod
337
-
338
- Creates property descriptor that represents a static method of a JavaScript class.
339
-
340
- ```cpp
341
- template <StaticVoidMethodCallback method>
342
- static Napi::PropertyDescriptor Napi::ObjectWrap::StaticMethod(Symbol name,
343
- napi_property_attributes attributes = napi_default,
344
- void* data = nullptr);
345
- ```
346
-
347
- - `[in] method`: The native function that represents a static method of a
348
- JavaScript class.
349
- - `[in] name`: Napi:Symbol that represents the name of a static
350
- method for the class.
351
- - `[in] attributes`: The attributes associated with a particular property.
352
- One or more of `napi_property_attributes`.
353
- - `[in] data`: User-provided data passed into method when it is invoked.
354
-
355
- Returns `Napi::PropertyDescriptor` object that represents the static method of a
356
- JavaScript class.
357
-
358
- ### StaticMethod
359
-
360
- Creates property descriptor that represents a static method of a JavaScript class.
361
-
362
- ```cpp
363
- template <StaticMethodCallback method>
364
- static Napi::PropertyDescriptor Napi::ObjectWrap::StaticMethod(Symbol name,
365
- napi_property_attributes attributes = napi_default,
366
- void* data = nullptr);
367
- ```
368
-
369
- - `[in] method`: The native function that represents a static method of a
370
- JavaScript class.
371
- - `[in] name`: Napi:Symbol that represents the name of a static.
372
- - `[in] attributes`: The attributes associated with a particular property.
373
- One or more of `napi_property_attributes`.
374
- - `[in] data`: User-provided data passed into method when it is invoked.
375
-
376
- Returns `Napi::PropertyDescriptor` object that represents a static method of a
377
- JavaScript class.
378
-
379
- ### StaticAccessor
380
-
381
- Creates property descriptor that represents a static accessor property of a
382
- JavaScript class.
383
-
384
- ```cpp
385
- static Napi::PropertyDescriptor Napi::ObjectWrap::StaticAccessor(const char* utf8name,
386
- StaticGetterCallback getter,
387
- StaticSetterCallback setter,
388
- napi_property_attributes attributes = napi_default,
389
- void* data = nullptr);
390
- ```
391
-
392
- - `[in] utf8name`: Null-terminated string that represents the name of a static
393
- accessor property for the class.
394
- - `[in] getter`: The native function to call when a get access to the property of
395
- a JavaScript class is performed.
396
- - `[in] setter`: The native function to call when a set access to the property of
397
- a JavaScript class is performed.
398
- - `[in] attributes`: The attributes associated with a particular property.
399
- One or more of `napi_property_attributes`.
400
- - `[in] data`: User-provided data passed into getter or setter when
401
- is invoked.
402
-
403
- Returns `Napi::PropertyDescriptor` object that represents a static accessor
404
- property of a JavaScript class.
405
-
406
- ### StaticAccessor
407
-
408
- Creates property descriptor that represents a static accessor property of a
409
- JavaScript class.
410
-
411
- ```cpp
412
- static Napi::PropertyDescriptor Napi::ObjectWrap::StaticAccessor(Symbol name,
413
- StaticGetterCallback getter,
414
- StaticSetterCallback setter,
415
- napi_property_attributes attributes = napi_default,
416
- void* data = nullptr);
417
- ```
418
-
419
- - `[in] name`: Napi:Symbol that represents the name of a static accessor.
420
- - `[in] getter`: The native function to call when a get access to the property of
421
- a JavaScript class is performed.
422
- - `[in] setter`: The native function to call when a set access to the property of
423
- a JavaScript class is performed.
424
- - `[in] attributes`: The attributes associated with a particular property.
425
- One or more of `napi_property_attributes`.
426
- - `[in] data`: User-provided data passed into getter or setter when
427
- is invoked.
428
-
429
- Returns `Napi::PropertyDescriptor` object that represents a static accessor
430
- property of a JavaScript class.
431
-
432
- ### StaticAccessor
433
-
434
- Creates property descriptor that represents a static accessor property of a
435
- JavaScript class.
436
-
437
- ```cpp
438
- template <StaticGetterCallback getter, StaticSetterCallback setter=nullptr>
439
- static Napi::PropertyDescriptor Napi::ObjectWrap::StaticAccessor(const char* utf8name,
440
- napi_property_attributes attributes = napi_default,
441
- void* data = nullptr);
442
- ```
443
-
444
- - `[in] getter`: The native function to call when a get access to the property of
445
- a JavaScript class is performed.
446
- - `[in] setter`: The native function to call when a set access to the property of
447
- a JavaScript class is performed.
448
- - `[in] utf8name`: Null-terminated string that represents the name of a static
449
- accessor property for the class.
450
- - `[in] attributes`: The attributes associated with a particular property.
451
- One or more of `napi_property_attributes`.
452
- - `[in] data`: User-provided data passed into getter or setter when
453
- is invoked.
454
-
455
- Returns `Napi::PropertyDescriptor` object that represents a static accessor
456
- property of a JavaScript class.
457
-
458
- ### StaticAccessor
459
-
460
- Creates property descriptor that represents a static accessor property of a
461
- JavaScript class.
462
-
463
- ```cpp
464
- template <StaticGetterCallback getter, StaticSetterCallback setter=nullptr>
465
- static Napi::PropertyDescriptor Napi::ObjectWrap::StaticAccessor(Symbol name,
466
- napi_property_attributes attributes = napi_default,
467
- void* data = nullptr);
468
- ```
469
-
470
- - `[in] getter`: The native function to call when a get access to the property of
471
- a JavaScript class is performed.
472
- - `[in] setter`: The native function to call when a set access to the property of
473
- a JavaScript class is performed.
474
- - `[in] name`: Napi:Symbol that represents the name of a static accessor.
475
- - `[in] attributes`: The attributes associated with a particular property.
476
- One or more of `napi_property_attributes`.
477
- - `[in] data`: User-provided data passed into getter or setter when
478
- is invoked.
479
-
480
- Returns `Napi::PropertyDescriptor` object that represents a static accessor
481
- property of a JavaScript class.
482
-
483
- ### InstanceMethod
484
-
485
- Creates property descriptor that represents an instance method of a JavaScript class.
486
-
487
- ```cpp
488
- static Napi::PropertyDescriptor Napi::ObjectWrap::InstanceMethod(const char* utf8name,
489
- InstanceVoidMethodCallback method,
490
- napi_property_attributes attributes = napi_default,
491
- void* data = nullptr);
492
- ```
493
-
494
- - `[in] utf8name`: Null-terminated string that represents the name of an instance
495
- method for the class.
496
- - `[in] method`: The native function that represents an instance method of a
497
- JavaScript class.
498
- - `[in] attributes`: The attributes associated with a particular property.
499
- One or more of `napi_property_attributes`.
500
- - `[in] data`: User-provided data passed into method when it is invoked.
501
-
502
- Returns `Napi::PropertyDescriptor` object that represents an instance method of a
503
- JavaScript class.
504
-
505
- ### InstanceMethod
506
-
507
- Creates property descriptor that represents an instance method of a JavaScript class.
508
-
509
- ```cpp
510
- static Napi::PropertyDescriptor Napi::ObjectWrap::InstanceMethod(const char* utf8name,
511
- InstanceMethodCallback method,
512
- napi_property_attributes attributes = napi_default,
513
- void* data = nullptr);
514
- ```
515
-
516
- - `[in] utf8name`: Null-terminated string that represents the name of an instance
517
- method for the class.
518
- - `[in] method`: The native function that represents an instance method of a
519
- JavaScript class.
520
- - `[in] attributes`: The attributes associated with a particular property.
521
- One or more of `napi_property_attributes`.
522
- - `[in] data`: User-provided data passed into method when it is invoked.
523
-
524
- Returns `Napi::PropertyDescriptor` object that represents an instance method of a
525
- JavaScript class.
526
-
527
- ### InstanceMethod
528
-
529
- Creates property descriptor that represents an instance method of a JavaScript class.
530
-
531
- ```cpp
532
- static Napi::PropertyDescriptor Napi::ObjectWrap::InstanceMethod(Napi::Symbol name,
533
- InstanceVoidMethodCallback method,
534
- napi_property_attributes attributes = napi_default,
535
- void* data = nullptr);
536
- ```
537
-
538
- - `[in] name`: The `Napi::Symbol` object whose value is used to identify the
539
- instance method for the class.
540
- - `[in] method`: The native function that represents an instance method of a
541
- JavaScript class.
542
- - `[in] attributes`: The attributes associated with a particular property.
543
- One or more of `napi_property_attributes`.
544
- - `[in] data`: User-provided data passed into method when it is invoked.
545
-
546
- Returns `Napi::PropertyDescriptor` object that represents an instance method of a
547
- JavaScript class.
548
-
549
- ### InstanceMethod
550
-
551
- Creates property descriptor that represents an instance method of a JavaScript class.
552
-
553
- ```cpp
554
- static Napi::PropertyDescriptor Napi::ObjectWrap::InstanceMethod(Napi::Symbol name,
555
- InstanceMethodCallback method,
556
- napi_property_attributes attributes = napi_default,
557
- void* data = nullptr);
558
- ```
559
-
560
- - `[in] name`: The `Napi::Symbol` object whose value is used to identify the
561
- instance method for the class.
562
- - `[in] method`: The native function that represents an instance method of a
563
- JavaScript class.
564
- - `[in] attributes`: The attributes associated with a particular property.
565
- One or more of `napi_property_attributes`.
566
- - `[in] data`: User-provided data passed into method when it is invoked.
567
-
568
- Returns `Napi::PropertyDescriptor` object that represents an instance method of a
569
- JavaScript class.
570
-
571
- ### InstanceMethod
572
-
573
- Creates property descriptor that represents an instance method of a JavaScript class.
574
-
575
- ```cpp
576
- template <InstanceVoidMethodCallback method>
577
- static Napi::PropertyDescriptor Napi::ObjectWrap::InstanceMethod(const char* utf8name,
578
- napi_property_attributes attributes = napi_default,
579
- void* data = nullptr);
580
- ```
581
-
582
- - `[in] method`: The native function that represents an instance method of a
583
- JavaScript class.
584
- - `[in] utf8name`: Null-terminated string that represents the name of an instance
585
- method for the class.
586
- - `[in] attributes`: The attributes associated with a particular property.
587
- One or more of `napi_property_attributes`.
588
- - `[in] data`: User-provided data passed into method when it is invoked.
589
-
590
- Returns `Napi::PropertyDescriptor` object that represents an instance method of a
591
- JavaScript class.
592
-
593
- ### InstanceMethod
594
-
595
- Creates property descriptor that represents an instance method of a JavaScript class.
596
-
597
- ```cpp
598
- template <InstanceMethodCallback method>
599
- static Napi::PropertyDescriptor Napi::ObjectWrap::InstanceMethod(const char* utf8name,
600
- napi_property_attributes attributes = napi_default,
601
- void* data = nullptr);
602
- ```
603
-
604
- - `[in] method`: The native function that represents an instance method of a
605
- JavaScript class.
606
- - `[in] utf8name`: Null-terminated string that represents the name of an instance
607
- method for the class.
608
- - `[in] attributes`: The attributes associated with a particular property.
609
- One or more of `napi_property_attributes`.
610
- - `[in] data`: User-provided data passed into method when it is invoked.
611
-
612
- Returns `Napi::PropertyDescriptor` object that represents an instance method of a
613
- JavaScript class.
614
-
615
- ### InstanceMethod
616
-
617
- Creates property descriptor that represents an instance method of a JavaScript class.
618
-
619
- ```cpp
620
- template <InstanceVoidMethodCallback method>
621
- static Napi::PropertyDescriptor Napi::ObjectWrap::InstanceMethod(Napi::Symbol name,
622
- napi_property_attributes attributes = napi_default,
623
- void* data = nullptr);
624
- ```
625
-
626
- - `[in] method`: The native function that represents an instance method of a
627
- JavaScript class.
628
- - `[in] name`: The `Napi::Symbol` object whose value is used to identify the
629
- instance method for the class.
630
- - `[in] attributes`: The attributes associated with a particular property.
631
- One or more of `napi_property_attributes`.
632
- - `[in] data`: User-provided data passed into method when it is invoked.
633
-
634
- Returns `Napi::PropertyDescriptor` object that represents an instance method of a
635
- JavaScript class.
636
-
637
- ### InstanceMethod
638
-
639
- Creates property descriptor that represents an instance method of a JavaScript class.
640
-
641
- ```cpp
642
- template <InstanceMethodCallback method>
643
- static Napi::PropertyDescriptor Napi::ObjectWrap::InstanceMethod(Napi::Symbol name,
644
- napi_property_attributes attributes = napi_default,
645
- void* data = nullptr);
646
- ```
647
-
648
- - `[in] method`: The native function that represents an instance method of a
649
- JavaScript class.
650
- - `[in] name`: The `Napi::Symbol` object whose value is used to identify the
651
- instance method for the class.
652
- - `[in] attributes`: The attributes associated with a particular property.
653
- One or more of `napi_property_attributes`.
654
- - `[in] data`: User-provided data passed into method when it is invoked.
655
-
656
- Returns `Napi::PropertyDescriptor` object that represents an instance method of a
657
- JavaScript class.
658
-
659
- ### InstanceAccessor
660
-
661
- Creates property descriptor that represents an instance accessor property of a
662
- JavaScript class.
663
-
664
- ```cpp
665
- static Napi::PropertyDescriptor Napi::ObjectWrap::InstanceAccessor(const char* utf8name,
666
- InstanceGetterCallback getter,
667
- InstanceSetterCallback setter,
668
- napi_property_attributes attributes = napi_default,
669
- void* data = nullptr);
670
- ```
671
-
672
- - `[in] utf8name`: Null-terminated string that represents the name of an instance
673
- accessor property for the class.
674
- - `[in] getter`: The native function to call when a get access to the property of
675
- a JavaScript class is performed.
676
- - `[in] setter`: The native function to call when a set access to the property of
677
- a JavaScript class is performed.
678
- - `[in] attributes`: The attributes associated with the particular property.
679
- One or more of `napi_property_attributes`.
680
- - `[in] data`: User-provided data passed into getter or setter when this is invoked.
681
-
682
- Returns `Napi::PropertyDescriptor` object that represents an instance accessor
683
- property of a JavaScript class.
684
-
685
- ### InstanceAccessor
686
-
687
- Creates property descriptor that represents an instance accessor property of a
688
- JavaScript class.
689
-
690
- ```cpp
691
- static Napi::PropertyDescriptor Napi::ObjectWrap::InstanceAccessor(Symbol name,
692
- InstanceGetterCallback getter,
693
- InstanceSetterCallback setter,
694
- napi_property_attributes attributes = napi_default,
695
- void* data = nullptr);
696
- ```
697
-
698
- - `[in] name`: The `Napi::Symbol` object whose value is used to identify the
699
- instance accessor.
700
- - `[in] getter`: The native function to call when a get access to the property of
701
- a JavaScript class is performed.
702
- - `[in] setter`: The native function to call when a set access to the property of
703
- a JavaScript class is performed.
704
- - `[in] attributes`: The attributes associated with the particular property.
705
- One or more of `napi_property_attributes`.
706
- - `[in] data`: User-provided data passed into getter or setter when this is invoked.
707
-
708
- Returns `Napi::PropertyDescriptor` object that represents an instance accessor
709
- property of a JavaScript class.
710
-
711
- ### InstanceAccessor
712
-
713
- Creates property descriptor that represents an instance accessor property of a
714
- JavaScript class.
715
-
716
- ```cpp
717
- template <InstanceGetterCallback getter, InstanceSetterCallback setter=nullptr>
718
- static Napi::PropertyDescriptor Napi::ObjectWrap::InstanceAccessor(const char* utf8name,
719
- napi_property_attributes attributes = napi_default,
720
- void* data = nullptr);
721
- ```
722
-
723
- - `[in] getter`: The native function to call when a get access to the property of
724
- a JavaScript class is performed.
725
- - `[in] setter`: The native function to call when a set access to the property of
726
- a JavaScript class is performed.
727
- - `[in] utf8name`: Null-terminated string that represents the name of an instance
728
- accessor property for the class.
729
- - `[in] attributes`: The attributes associated with the particular property.
730
- One or more of `napi_property_attributes`.
731
- - `[in] data`: User-provided data passed into getter or setter when this is invoked.
732
-
733
- Returns `Napi::PropertyDescriptor` object that represents an instance accessor
734
- property of a JavaScript class.
735
-
736
- ### InstanceAccessor
737
-
738
- Creates property descriptor that represents an instance accessor property of a
739
- JavaScript class.
740
-
741
- ```cpp
742
- template <InstanceGetterCallback getter, InstanceSetterCallback setter=nullptr>
743
- static Napi::PropertyDescriptor Napi::ObjectWrap::InstanceAccessor(Symbol name,
744
- napi_property_attributes attributes = napi_default,
745
- void* data = nullptr);
746
- ```
747
-
748
- - `[in] getter`: The native function to call when a get access to the property of
749
- a JavaScript class is performed.
750
- - `[in] setter`: The native function to call when a set access to the property of
751
- a JavaScript class is performed.
752
- - `[in] name`: The `Napi::Symbol` object whose value is used to identify the
753
- instance accessor.
754
- - `[in] attributes`: The attributes associated with the particular property.
755
- One or more of `napi_property_attributes`.
756
- - `[in] data`: User-provided data passed into getter or setter when this is invoked.
757
-
758
- Returns `Napi::PropertyDescriptor` object that represents an instance accessor
759
- property of a JavaScript class.
760
-
761
- ### StaticValue
762
-
763
- Creates property descriptor that represents an static value property of a
764
- JavaScript class.
765
- ```cpp
766
- static Napi::PropertyDescriptor Napi::ObjectWrap::StaticValue(const char* utf8name,
767
- Napi::Value value,
768
- napi_property_attributes attributes = napi_default);
769
- ```
770
-
771
- - `[in] utf8name`: Null-terminated string that represents the name of the static
772
- property.
773
- - `[in] value`: The value that's retrieved by a get access of the property.
774
- - `[in] attributes`: The attributes to be associated with the property in addition
775
- to the napi_static attribute. One or more of `napi_property_attributes`.
776
-
777
- Returns `Napi::PropertyDescriptor` object that represents an static value
778
- property of a JavaScript class
779
-
780
- ### StaticValue
781
-
782
- Creates property descriptor that represents an static value property of a
783
- JavaScript class.
784
- ```cpp
785
- static Napi::PropertyDescriptor Napi::ObjectWrap::StaticValue(Symbol name,
786
- Napi::Value value,
787
- napi_property_attributes attributes = napi_default);
788
- ```
789
-
790
- - `[in] name`: The `Napi::Symbol` object whose value is used to identify the
791
- name of the static property.
792
- - `[in] value`: The value that's retrieved by a get access of the property.
793
- - `[in] attributes`: The attributes to be associated with the property in addition
794
- to the napi_static attribute. One or more of `napi_property_attributes`.
795
-
796
- Returns `Napi::PropertyDescriptor` object that represents an static value
797
- property of a JavaScript class
798
-
799
- ### InstanceValue
800
-
801
- Creates property descriptor that represents an instance value property of a
802
- JavaScript class.
803
- ```cpp
804
- static Napi::PropertyDescriptor Napi::ObjectWrap::InstanceValue(const char* utf8name,
805
- Napi::Value value,
806
- napi_property_attributes attributes = napi_default);
807
- ```
808
-
809
- - `[in] utf8name`: Null-terminated string that represents the name of the property.
810
- - `[in] value`: The value that's retrieved by a get access of the property.
811
- - `[in] attributes`: The attributes to be associated with the property.
812
- One or more of `napi_property_attributes`.
813
-
814
- Returns `Napi::PropertyDescriptor` object that represents an instance value
815
- property of a JavaScript class.
816
-
817
- ### InstanceValue
818
-
819
- Creates property descriptor that represents an instance value property of a
820
- JavaScript class.
821
- ```cpp
822
- static Napi::PropertyDescriptor Napi::ObjectWrap::InstanceValue(Symbol name,
823
- Napi::Value value,
824
- napi_property_attributes attributes = napi_default);
825
- ```
826
-
827
- - `[in] name`: The `Napi::Symbol` object whose value is used to identify the
828
- name of the property.
829
- - `[in] value`: The value that's retrieved by a get access of the property.
830
- - `[in] attributes`: The attributes to be associated with the property.
831
- One or more of `napi_property_attributes`.
832
-
833
- Returns `Napi::PropertyDescriptor` object that represents an instance value