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/CHANGELOG.md CHANGED
@@ -1,5 +1,222 @@
1
1
  # node-addon-api Changelog
2
2
 
3
+ ## 2021-05-28 Version 3.2.1, @NickNaso
4
+
5
+ ### Notable changes:
6
+
7
+ #### Documentation
8
+
9
+ - Fixed documentation about the oldest Node.js version supported.
10
+
11
+ ### Commits
12
+
13
+ * [[`6d41ee5a3a`](https://github.com/nodejs/node-addon-api/commit/6d41ee5a3a)] - Fixed readme for new release. (NickNaso)
14
+
15
+ ## 2021-05-17 Version 3.2.0, @NickNaso
16
+
17
+ ### Notable changes:
18
+
19
+ #### API
20
+
21
+ - Remove unnecessary symbol exposure.
22
+ - Fixed leak in `Napi::ObjectWrap` instance for getter and setter method.
23
+ - Added `Napi::Object::Freeze` and `Napi::object::Seal` methods.
24
+ - `Napi::Reference` is now copyable.
25
+
26
+ #### Documentation
27
+
28
+ - Added docuemtnation for `Napi::Object::PropertyLValue`.
29
+ - Changed all N-API references to Node-API.
30
+ - Some minor corrections all over the documentation.
31
+
32
+ #### TEST
33
+
34
+ - Added tests relating to fetch property from Global Object.
35
+ - Added addtiona tests for `Napi::Object`.
36
+ - Added test for `Napi::Function` contructors.
37
+ - Fixed intermittent failure for `Napi::ThreadSafeFunction` test.
38
+ - Some minor corrections all over the test suite.
39
+
40
+ ### TOOL
41
+
42
+ - Added Node.js v16.x to CI.
43
+ - Added CI configuration for Windows.
44
+ - Some fixex on linter command.
45
+
46
+ ### Commits
47
+
48
+ * [[`52721312f6`](https://github.com/nodejs/node-addon-api/commit/52721312f6)] - **docs**: add napi-rs iin Other Bindings section (#999) (LongYinan)
49
+ * [[`78a6570a42`](https://github.com/nodejs/node-addon-api/commit/78a6570a42)] - **doc**: fix typo in code example (#997) (Tobias Nießen)
50
+ * [[`da3bd5778f`](https://github.com/nodejs/node-addon-api/commit/da3bd5778f)] - **test**: fix undoc assumptions about the timing of tsfn calls (legendecas) [#995](https://github.com/nodejs/node-addon-api/pull/995)
51
+ * [[`410cf6a81e`](https://github.com/nodejs/node-addon-api/commit/410cf6a81e)] - **src**: return bool on object freeze and seal (#991) (legendecas)
52
+ * [[`93f1898312`](https://github.com/nodejs/node-addon-api/commit/93f1898312)] - **src**: return bool on object set and define property (#977) (legendecas)
53
+ * [[`331c2ee274`](https://github.com/nodejs/node-addon-api/commit/331c2ee274)] - **build**: add Node.js v16.x to CI (#983) (legendecas)
54
+ * [[`b6f5eb15e6`](https://github.com/nodejs/node-addon-api/commit/b6f5eb15e6)] - **test**: run test suites with helpers (legendecas) [#976](https://github.com/nodejs/node-addon-api/pull/976)
55
+ * [[`fbcdf00ea0`](https://github.com/nodejs/node-addon-api/commit/fbcdf00ea0)] - **test**: rename misspelled parameters (Tobias Nießen) [#973](https://github.com/nodejs/node-addon-api/pull/973)
56
+ * [[`63a6c32e80`](https://github.com/nodejs/node-addon-api/commit/63a6c32e80)] - **test**: fix intermittent TSFN crashes (Kevin Eady) [#974](https://github.com/nodejs/node-addon-api/pull/974)
57
+ * [[`8f120b033f`](https://github.com/nodejs/node-addon-api/commit/8f120b033f)] - **fix**: key for wapping drawing's system condition (#970) (Kévin VOYER)
58
+ * [[`1c9d528d66`](https://github.com/nodejs/node-addon-api/commit/1c9d528d66)] - **doc**: correct struct definition (#969) (Darshan Sen)
59
+ * [[`5e64d1fa61`](https://github.com/nodejs/node-addon-api/commit/5e64d1fa61)] - Added badges for Node-API v7 and v8. (#954) (Nicola Del Gobbo)
60
+ * [[`6ce629b3fa`](https://github.com/nodejs/node-addon-api/commit/6ce629b3fa)] - **src**: add pull request template (#967) (Michael Dawson)
61
+ * [[`98126661af`](https://github.com/nodejs/node-addon-api/commit/98126661af)] - Update CONTRIBUTING.md (#966) (Michael Dawson)
62
+ * [[`77350eee98`](https://github.com/nodejs/node-addon-api/commit/77350eee98)] - **src**: added Freeze and Seal method to Object class. (NickNaso) [#955](https://github.com/nodejs/node-addon-api/pull/955)
63
+ * [[`bc5147cc4a`](https://github.com/nodejs/node-addon-api/commit/bc5147cc4a)] - Finished tests relating to fetch property from Global Object (JckXia)
64
+ * [[`0127813111`](https://github.com/nodejs/node-addon-api/commit/0127813111)] - **doc**: unambiguously mark deprecated signatures (Tobias Nießen) [#942](https://github.com/nodejs/node-addon-api/pull/942)
65
+ * [[`787e216105`](https://github.com/nodejs/node-addon-api/commit/787e216105)] - **doc**: rename N-API with Node-API (Darshan Sen) [#951](https://github.com/nodejs/node-addon-api/pull/951)
66
+ * [[`628023689a`](https://github.com/nodejs/node-addon-api/commit/628023689a)] - **src**: rename N-API with Node-API on comments (NickNaso) [#953](https://github.com/nodejs/node-addon-api/pull/953)
67
+ * [[`5c6391578f`](https://github.com/nodejs/node-addon-api/commit/5c6391578f)] - **build**: add CI configuration for Windows (NickNaso) [#948](https://github.com/nodejs/node-addon-api/pull/948)
68
+ * [[`8ef07251ec`](https://github.com/nodejs/node-addon-api/commit/8ef07251ec)] - **doc**: added some warnings for buffer and array buffer factory method. (#929) (Nicola Del Gobbo)
69
+ * [[`6490b1f730`](https://github.com/nodejs/node-addon-api/commit/6490b1f730)] - **doc**: sync Object::Set value arg with Value::From (#933) (Tobias Nießen)
70
+ * [[`7319a0d7a2`](https://github.com/nodejs/node-addon-api/commit/7319a0d7a2)] - Fix tab indent (#938) (Tobias Nießen)
71
+ * [[`1916cb937e`](https://github.com/nodejs/node-addon-api/commit/1916cb937e)] - **chore**: fixup linter commands (#940) (legendecas)
72
+ * [[`fc4585fa23`](https://github.com/nodejs/node-addon-api/commit/fc4585fa23)] - **test**: dd tests for Function constructors (JoseExposito) [#937](https://github.com/nodejs/node-addon-api/pull/937)
73
+ * [[`87b7aae469`](https://github.com/nodejs/node-addon-api/commit/87b7aae469)] - **doc**: warn about SuppressDestruct() (#926) (Anna Henningsen)
74
+ * [[`71494a49a3`](https://github.com/nodejs/node-addon-api/commit/71494a49a3)] - **src,doc**: refactor to replace typedefs with usings (Darshan Sen) [#910](https://github.com/nodejs/node-addon-api/pull/910)
75
+ * [[`298ff8d9d2`](https://github.com/nodejs/node-addon-api/commit/298ff8d9d2)] - **test**: add additional tests for Object (JoseExposito) [#923](https://github.com/nodejs/node-addon-api/pull/923)
76
+ * [[`8a1147b430`](https://github.com/nodejs/node-addon-api/commit/8a1147b430)] - **revert**: src: add additional tests for Function (Michael Dawson)
77
+ * [[`bb56ffaa6f`](https://github.com/nodejs/node-addon-api/commit/bb56ffaa6f)] - **doc**: fix documentation for object api (Nicola Del Gobbo) [#931](https://github.com/nodejs/node-addon-api/pull/931)
78
+ * [[`3b8bddab49`](https://github.com/nodejs/node-addon-api/commit/3b8bddab49)] - **src**: add additional tests for Function (José Expósito) [#928](https://github.com/nodejs/node-addon-api/pull/928)
79
+ * [[`74ab50c775`](https://github.com/nodejs/node-addon-api/commit/74ab50c775)] - **src**: allow references to be copyable in APIs (legendecas) [#915](https://github.com/nodejs/node-addon-api/pull/915)
80
+ * [[`929709d0fe`](https://github.com/nodejs/node-addon-api/commit/929709d0fe)] - **doc**: add propertylvalue.md (#925) (Gabriel Schulhof)
81
+ * [[`69d0d98be4`](https://github.com/nodejs/node-addon-api/commit/69d0d98be4)] - fixup (Anna Henningsen)
82
+ * [[`46e41d961b`](https://github.com/nodejs/node-addon-api/commit/46e41d961b)] - fixup (Anna Henningsen)
83
+ * [[`1af1642fb7`](https://github.com/nodejs/node-addon-api/commit/1af1642fb7)] - **doc**: warn about SuppressDestruct() (Anna Henningsen)
84
+ * [[`12c548b2ff`](https://github.com/nodejs/node-addon-api/commit/12c548b2ff)] - **tools**: fix error detection (#914) (Darshan Sen)
85
+ * [[`458d895d5b`](https://github.com/nodejs/node-addon-api/commit/458d895d5b)] - **packaging**: list files to be published to npm (Lovell Fuller) [#889](https://github.com/nodejs/node-addon-api/pull/889)
86
+ * [[`f7ed2490d4`](https://github.com/nodejs/node-addon-api/commit/f7ed2490d4)] - **test**: remove outdated V8 flag (Darshan Sen) [#895](https://github.com/nodejs/node-addon-api/pull/895)
87
+ * [[`a575a6ec60`](https://github.com/nodejs/node-addon-api/commit/a575a6ec60)] - **src**: fix leak in ObjectWrap instance set/getters (Kevin Eady) [#899](https://github.com/nodejs/node-addon-api/pull/899)
88
+ * [[`b6e844e0b0`](https://github.com/nodejs/node-addon-api/commit/b6e844e0b0)] - **doc**: fix spelling of "targeted" and "targeting" (#904) (Tobias Nießen)
89
+ * [[`4d856f6e91`](https://github.com/nodejs/node-addon-api/commit/4d856f6e91)] - **src**: remove unnecessary symbol exposure (Gabriel Schulhof) [#896](https://github.com/nodejs/node-addon-api/pull/896)
90
+ * [[`f35bb7d0d7`](https://github.com/nodejs/node-addon-api/commit/f35bb7d0d7)] - **doc**: Update GitHub URL references from 'master' to 'HEAD' (#898) (Jim Schlight)
91
+ * [[`286ae215d1`](https://github.com/nodejs/node-addon-api/commit/286ae215d1)] - Add warning about branch rename (Michael Dawson)
92
+ * [[`a4a7b28288`](https://github.com/nodejs/node-addon-api/commit/a4a7b28288)] - Update branch references from master to main (#886) (Jim Schlight)
93
+ * [[`a2ad0a107a`](https://github.com/nodejs/node-addon-api/commit/a2ad0a107a)] - **docs**: add NAN to N-API resource link (#880) (kidneysolo)
94
+ * [[`1c040eeb63`](https://github.com/nodejs/node-addon-api/commit/1c040eeb63)] - **test**: load testModules automatically (raisinten) [#876](https://github.com/nodejs/node-addon-api/pull/876)
95
+ * [[`bf478e4496`](https://github.com/nodejs/node-addon-api/commit/bf478e4496)] - **src**: use NAPI\_NOEXCEPT macro instead of noexcept (NickNaso) [#864](https://github.com/nodejs/node-addon-api/pull/864)
96
+ * [[`744705f2eb`](https://github.com/nodejs/node-addon-api/commit/744705f2eb)] - **test**: refactor remove repeated execution index.js (raisinten) [#839](https://github.com/nodejs/node-addon-api/pull/839)
97
+ * [[`db62e3c811`](https://github.com/nodejs/node-addon-api/commit/db62e3c811)] - Update team members (Michael Dawson)
98
+
99
+ ## 2020-12-17 Version 3.1.0, @NickNaso
100
+
101
+ ### Notable changes:
102
+
103
+ #### API
104
+
105
+ - Added `Napi::TypedThreadSafeFunction` class that is a new implementation for
106
+ thread-safe functions.
107
+ - Fixed leak on `Napi::AsyncProgressWorkerBase`.
108
+ - Fixed empty data on `Napi::AsyncProgressWorker::OnProgress` caused by race
109
+ conditions of `Napi::AsyncProgressWorker`.
110
+ - Added `Napi::ArrayBuffer::Detach()` and `Napi::ArrayBuffer::IsDetached()`.
111
+ - Fixed problem on `Napi::FinalizeCallback` it needs to create a
112
+ `Napi::HandleScope` when it calls `Napi::ObjectWrap::~ObjectWrap()`.
113
+
114
+ #### Documentation
115
+
116
+ - Added documentation for `Napi::TypedThreadSafeFunction`.
117
+ - Removed unsued Doxygen file.
118
+ - Clarified when to use N-API.
119
+ - Added support information.
120
+ - Some minor corrections all over the documentation.
121
+
122
+ #### TEST
123
+
124
+ - Added test for `Napi::TypedThreadSafeFunction`.
125
+ - Fixed testing for specific N-API version.
126
+ - Some minor corrections all over the test suite.
127
+
128
+ ### TOOL
129
+
130
+ - Setup github actions for tests.
131
+ - Added stale action.
132
+ - Removed `sudo` tag from Travis CI.
133
+ - Added clang-format.
134
+ - Added pre-commit package for linting.
135
+
136
+ ### Commits
137
+
138
+ * [[`ff642c5b85`](https://github.com/nodejs/node-addon-api/commit/ff642c5b85)] - **doc**: fix tsfn docs to reflect true implementation (#860) (Kevin Eady)
139
+ * [[`86feeebf54`](https://github.com/nodejs/node-addon-api/commit/86feeebf54)] - **src**: empty data OnProgress in AsyncProgressWorker (legendecas) [#853](https://github.com/nodejs/node-addon-api/pull/853)
140
+ * [[`a7fb5fb31c`](https://github.com/nodejs/node-addon-api/commit/a7fb5fb31c)] - **action**: add stale action (#856) (Michael Dawson)
141
+ * [[`fd44609885`](https://github.com/nodejs/node-addon-api/commit/fd44609885)] - **chore**: setup github actions for tests (#854) (legendecas) [#854](https://github.com/nodejs/node-addon-api/pull/854)
142
+ * [[`c52ace4813`](https://github.com/nodejs/node-addon-api/commit/c52ace4813)] - **script**: fix complains that js files are not supported on npm run lint:fix (#852) (legendecas)
143
+ * [[`b4a3364ad5`](https://github.com/nodejs/node-addon-api/commit/b4a3364ad5)] - **doc**: remove unused Doxygen file (#851) (Michael Dawson)
144
+ * [[`b810466ae2`](https://github.com/nodejs/node-addon-api/commit/b810466ae2)] - **doc**: clarify when to use N-API (#849) (Michael Dawson)
145
+ * [[`528b9f6832`](https://github.com/nodejs/node-addon-api/commit/528b9f6832)] - **test**: remove sudo from travis (#850) (Michael Dawson)
146
+ * [[`4bb680de4e`](https://github.com/nodejs/node-addon-api/commit/4bb680de4e)] - Remove misleading sentence (#847) (Nikolai Vavilov) [#847](https://github.com/nodejs/node-addon-api/pull/847)
147
+ * [[`48e6b584a3`](https://github.com/nodejs/node-addon-api/commit/48e6b584a3)] - Merge pull request #742 from KevinEady/contexted-tsfn-api-gcc-4 (Gabriel Schulhof)
148
+ * [[`d5e37210cc`](https://github.com/nodejs/node-addon-api/commit/d5e37210cc)] - **tools**: print more instructions on clang-format check failed (#846) (legendecas) [#846](https://github.com/nodejs/node-addon-api/pull/846)
149
+ * [[`d9e11ff2c9`](https://github.com/nodejs/node-addon-api/commit/d9e11ff2c9)] - **doc**: add support info (#843) (Michael Dawson) [#843](https://github.com/nodejs/node-addon-api/pull/843)
150
+ * [[`356e93d69a`](https://github.com/nodejs/node-addon-api/commit/356e93d69a)] - **test**: fixup testing for specific N-API version (#840) (Michael Dawson) [#840](https://github.com/nodejs/node-addon-api/pull/840)
151
+ * [[`5e5b9ce1b7`](https://github.com/nodejs/node-addon-api/commit/5e5b9ce1b7)] - Apply formatting changes (Kevin Eady)
152
+ * [[`559ad8c0c0`](https://github.com/nodejs/node-addon-api/commit/559ad8c0c0)] - Merge remote-tracking branch 'upstream/master' into contexted-tsfn-api-gcc-4 (Kevin Eady)
153
+ * [[`c24c455ced`](https://github.com/nodejs/node-addon-api/commit/c24c455ced)] - Rename to TypedThreadSafeFunction (Kevin Eady)
154
+ * [[`63b43f4125`](https://github.com/nodejs/node-addon-api/commit/63b43f4125)] - **test**: fix buildType bug objectwrap\_worker\_thread (raisinten) [#837](https://github.com/nodejs/node-addon-api/pull/837)
155
+ * [[`6321f2ba1a`](https://github.com/nodejs/node-addon-api/commit/6321f2ba1a)] - **test**: fix typos in addon\_build/index.js (raisinten) [#838](https://github.com/nodejs/node-addon-api/pull/838)
156
+ * [[`59c6a6aeb0`](https://github.com/nodejs/node-addon-api/commit/59c6a6aeb0)] - **fix**: git-clang-format doesn't recognize no changes requested on given files (#835) (legendecas)
157
+ * [[`1427b3ef78`](https://github.com/nodejs/node-addon-api/commit/1427b3ef78)] - **src**: create a HandleScope in FinalizeCallback (blagoev) [#832](https://github.com/nodejs/node-addon-api/pull/832)
158
+ * [[`8fb5820557`](https://github.com/nodejs/node-addon-api/commit/8fb5820557)] - **build**: add incremental clang-format checks (legendecas) [#819](https://github.com/nodejs/node-addon-api/pull/819)
159
+ * [[`2c02d317e5`](https://github.com/nodejs/node-addon-api/commit/2c02d317e5)] - **build**: add pre-commit package for linting (#823) (Kevin Eady)
160
+ * [[`1b52c28eb8`](https://github.com/nodejs/node-addon-api/commit/1b52c28eb8)] - Clean up AsyncProgressWorker documentation (#831) (mastergberry)
161
+ * [[`4abe7cfe30`](https://github.com/nodejs/node-addon-api/commit/4abe7cfe30)] - **test**: rename tsfnex test files (Kevin Eady)
162
+ * [[`c9563caa25`](https://github.com/nodejs/node-addon-api/commit/c9563caa25)] - **src**: add ArrayBuffer::Detach() and ::IsDetached() (Tobias Nießen) [#659](https://github.com/nodejs/node-addon-api/pull/659)
163
+ * [[`c79cabaed2`](https://github.com/nodejs/node-addon-api/commit/c79cabaed2)] - **doc**: avoid directing users to HTTP (#828) (Tobias Nießen)
164
+ * [[`7a13f861ab`](https://github.com/nodejs/node-addon-api/commit/7a13f861ab)] - **doc**: fix additional typo (Kevin Eady)
165
+ * [[`7ec9741dd2`](https://github.com/nodejs/node-addon-api/commit/7ec9741dd2)] - Merge remote-tracking branch 'upstream/master' into contexted-tsfn-api-gcc-4 (Kevin Eady)
166
+ * [[`f5fad239fa`](https://github.com/nodejs/node-addon-api/commit/f5fad239fa)] - Update object\_reference.md (#827) (kidneysolo)
167
+ * [[`35b65712c2`](https://github.com/nodejs/node-addon-api/commit/35b65712c2)] - **Fix**: some typos in documentation (#826) (Helio Frota)
168
+ * [[`8983383000`](https://github.com/nodejs/node-addon-api/commit/8983383000)] - **Fix**: some typos in the document (#825) (Ziqiu Zhao)
169
+ * [[`826e466ef6`](https://github.com/nodejs/node-addon-api/commit/826e466ef6)] - Fixed example in addon.md. (#820) (nempoBu4) [#820](https://github.com/nodejs/node-addon-api/pull/820)
170
+ * [[`b54f5eb788`](https://github.com/nodejs/node-addon-api/commit/b54f5eb788)] - Additional changes from review (Kevin Eady)
171
+ * [[`59f27dac9a`](https://github.com/nodejs/node-addon-api/commit/59f27dac9a)] - Fix common.gypi (Kevin Eady)
172
+ * [[`151a914c99`](https://github.com/nodejs/node-addon-api/commit/151a914c99)] - Apply documentation suggestions from code review (Kevin Eady)
173
+ * [[`ceb27d4949`](https://github.com/nodejs/node-addon-api/commit/ceb27d4949)] - **src**: fix leak in AsyncProgressWorkerBase\<DataType\> (Ferdinand Holzer) [#795](https://github.com/nodejs/node-addon-api/pull/795)
174
+
175
+ ## 2020-09-18 Version 3.0.2, @NickNaso
176
+
177
+ ### Notable changes:
178
+
179
+ #### API
180
+
181
+ - Introduced `include_dir` for use with **gyp** in a scalar context.
182
+ - Added `Napi::Addon` to help handle the loading of a native add-on into
183
+ multiple threads and or multiple times in the same thread.
184
+ - Concentrate callbacks provided to core N-API.
185
+ - Make sure wrapcallback is used.
186
+
187
+ #### Documentation
188
+
189
+ - Added documentation for `Napi::Addon`.
190
+ - Added documentation that reports the full class hierarchy.
191
+ - Added link to N-API tutorial website.
192
+ - Some minor corrections all over the documentation.
193
+
194
+ #### TEST
195
+
196
+ - Added tests to check the build process.
197
+ - Refactored test for threasfafe function using async/await.
198
+ - Converted tests that gc into async functions that await 10 ticks after
199
+ each gc.
200
+ - Some minor corrections all over the test suite.
201
+
202
+ ### Commits
203
+
204
+ * [[`51e25f7c39`](https://github.com/nodejs/node-addon-api/commit/51e25f7c39)] - **doc**: remove a file (#815) (Gabriel Schulhof)
205
+ * [[`8c9f1809a2`](https://github.com/nodejs/node-addon-api/commit/8c9f1809a2)] - **doc**: add inheritance links and other changes (Gabriel Schulhof) [#798](https://github.com/nodejs/node-addon-api/pull/798)
206
+ * [[`6562e6b0ab`](https://github.com/nodejs/node-addon-api/commit/6562e6b0ab)] - **test**: added tests to check the build process (NickNaso) [#808](https://github.com/nodejs/node-addon-api/pull/808)
207
+ * [[`a13b36c96e`](https://github.com/nodejs/node-addon-api/commit/a13b36c96e)] - **test**: fix the threasfafe function test (NickNaso) [#807](https://github.com/nodejs/node-addon-api/pull/807)
208
+ * [[`f27623ff61`](https://github.com/nodejs/node-addon-api/commit/f27623ff61)] - **build**: introduce include\_dir (Lovell Fuller) [#766](https://github.com/nodejs/node-addon-api/pull/766)
209
+ * [[`9aceea71fc`](https://github.com/nodejs/node-addon-api/commit/9aceea71fc)] - **src**: concentrate callbacks provided to core N-API (Gabriel Schulhof) [#786](https://github.com/nodejs/node-addon-api/pull/786)
210
+ * [[`2bc45bbffd`](https://github.com/nodejs/node-addon-api/commit/2bc45bbffd)] - **test**: refactor test to use async/await (Velmisov) [#787](https://github.com/nodejs/node-addon-api/pull/787)
211
+ * [[`518cfdcdc1`](https://github.com/nodejs/node-addon-api/commit/518cfdcdc1)] - **test**: test ObjectWrap destructor - no HandleScope (David Halls) [#729](https://github.com/nodejs/node-addon-api/pull/729)
212
+ * [[`c2cbbd9191`](https://github.com/nodejs/node-addon-api/commit/c2cbbd9191)] - **doc**: add link to n-api tutorial website (#794) (Jim Schlight) [#794](https://github.com/nodejs/node-addon-api/pull/794)
213
+ * [[`1c2a8d59b5`](https://github.com/nodejs/node-addon-api/commit/1c2a8d59b5)] - **doc**: Added required return to example (#793) (pacop) [#793](https://github.com/nodejs/node-addon-api/pull/793)
214
+ * [[`cec2c76941`](https://github.com/nodejs/node-addon-api/commit/cec2c76941)] - **src**: wrap finalizer callback (Gabriel Schulhof) [#762](https://github.com/nodejs/node-addon-api/pull/762)
215
+ * [[`4ce40d22a6`](https://github.com/nodejs/node-addon-api/commit/4ce40d22a6)] - **test**: use assert.strictEqual() (Koki Nishihara) [#777](https://github.com/nodejs/node-addon-api/pull/777)
216
+ * [[`461e3640c6`](https://github.com/nodejs/node-addon-api/commit/461e3640c6)] - **test**: string tests together (Gabriel Schulhof) [#773](https://github.com/nodejs/node-addon-api/pull/773)
217
+ * [[`5af645f649`](https://github.com/nodejs/node-addon-api/commit/5af645f649)] - **src**: add Addon\<T\> class (Gabriel Schulhof) [#749](https://github.com/nodejs/node-addon-api/pull/749)
218
+ * [[`6148fb4bcc`](https://github.com/nodejs/node-addon-api/commit/6148fb4bcc)] - Synchronise Node.js versions in Appveyor Windows CI with Travis (#768) (Lovell Fuller)
219
+
3
220
  ## 2020-07-13 Version 3.0.1, @NickNaso
4
221
 
5
222
  ### Notable changes:
package/README.md CHANGED
@@ -1,10 +1,29 @@
1
+ NOTE: The default branch has been renamed!
2
+ master is now named main
3
+
4
+ If you have a local clone, you can update it by running:
5
+
6
+ ```shell
7
+ git branch -m master main
8
+ git fetch origin
9
+ git branch -u origin/main main
10
+ ```
11
+
1
12
  # **node-addon-api module**
2
13
  This module contains **header-only C++ wrapper classes** which simplify
3
- the use of the C based [N-API](https://nodejs.org/dist/latest/docs/api/n-api.html)
14
+ the use of the C based [Node-API](https://nodejs.org/dist/latest/docs/api/n-api.html)
4
15
  provided by Node.js when using C++. It provides a C++ object model
5
16
  and exception handling semantics with low overhead.
6
17
 
7
- N-API is an ABI stable C interface provided by Node.js for building native
18
+ There are three options for implementing addons: Node-API, nan, or direct
19
+ use of internal V8, libuv and Node.js libraries. Unless there is a need for
20
+ direct access to functionality which is not exposed by Node-API as outlined
21
+ in [C/C++ addons](https://nodejs.org/dist/latest/docs/api/addons.html)
22
+ in Node.js core, use Node-API. Refer to
23
+ [C/C++ addons with Node-API](https://nodejs.org/dist/latest/docs/api/n-api.html)
24
+ for more information on Node-API.
25
+
26
+ Node-API is an ABI stable C interface provided by Node.js for building native
8
27
  addons. It is independent from the underlying JavaScript runtime (e.g. V8 or ChakraCore)
9
28
  and is maintained as part of Node.js itself. It is intended to insulate
10
29
  native addons from changes in the underlying JavaScript engine and allow
@@ -12,24 +31,24 @@ modules compiled for one version to run on later versions of Node.js without
12
31
  recompilation.
13
32
 
14
33
  The `node-addon-api` module, which is not part of Node.js, preserves the benefits
15
- of the N-API as it consists only of inline code that depends only on the stable API
16
- provided by N-API. As such, modules built against one version of Node.js
34
+ of the Node-API as it consists only of inline code that depends only on the stable API
35
+ provided by Node-API. As such, modules built against one version of Node.js
17
36
  using node-addon-api should run without having to be rebuilt with newer versions
18
37
  of Node.js.
19
38
 
20
39
  It is important to remember that *other* Node.js interfaces such as
21
40
  `libuv` (included in a project via `#include <uv.h>`) are not ABI-stable across
22
- Node.js major versions. Thus, an addon must use N-API and/or `node-addon-api`
41
+ Node.js major versions. Thus, an addon must use Node-API and/or `node-addon-api`
23
42
  exclusively and build against a version of Node.js that includes an
24
- implementation of N-API (meaning an active LTS version of Node.js) in
43
+ implementation of Node-API (meaning an active LTS version of Node.js) in
25
44
  order to benefit from ABI stability across Node.js major versions. Node.js
26
45
  provides an [ABI stability guide][] containing a detailed explanation of ABI
27
- stability in general, and the N-API ABI stability guarantee in particular.
46
+ stability in general, and the Node-API ABI stability guarantee in particular.
28
47
 
29
- As new APIs are added to N-API, node-addon-api must be updated to provide
48
+ As new APIs are added to Node-API, node-addon-api must be updated to provide
30
49
  wrappers for those new APIs. For this reason node-addon-api provides
31
- methods that allow callers to obtain the underlying N-API handles so
32
- direct calls to N-API and the use of the objects/methods provided by
50
+ methods that allow callers to obtain the underlying Node-API handles so
51
+ direct calls to Node-API and the use of the objects/methods provided by
33
52
  node-addon-api can be used together. For example, in order to be able
34
53
  to use an API for which the node-addon-api does not yet provide a wrapper.
35
54
 
@@ -37,6 +56,10 @@ APIs exposed by node-addon-api are generally used to create and
37
56
  manipulate JavaScript values. Concepts and operations generally map
38
57
  to ideas specified in the **ECMA262 Language Specification**.
39
58
 
59
+ The [Node-API Resource](https://nodejs.github.io/node-addon-examples/) offers an
60
+ excellent orientation and tips for developers just getting started with Node-API
61
+ and node-addon-api.
62
+
40
63
  - **[Setup](#setup)**
41
64
  - **[API Documentation](#api)**
42
65
  - **[Examples](#examples)**
@@ -47,7 +70,7 @@ to ideas specified in the **ECMA262 Language Specification**.
47
70
  - **[Contributors](#contributors)**
48
71
  - **[License](#license)**
49
72
 
50
- ## **Current version: 3.0.1**
73
+ ## **Current version: 3.2.1**
51
74
 
52
75
  (See [CHANGELOG.md](CHANGELOG.md) for complete Changelog)
53
76
 
@@ -55,8 +78,8 @@ to ideas specified in the **ECMA262 Language Specification**.
55
78
 
56
79
  <a name="setup"></a>
57
80
 
58
- node-addon-api is based on [N-API](https://nodejs.org/api/n-api.html) and supports using different N-API versions.
59
- This allows addons built with it to run with Node.js versions which support the targeted N-API version.
81
+ node-addon-api is based on [Node-API](https://nodejs.org/api/n-api.html) and supports using different Node-API versions.
82
+ This allows addons built with it to run with Node.js versions which support the targeted Node-API version.
60
83
  **However** the node-addon-api support model is to support only the active LTS Node.js versions. This means that
61
84
  every year there will be a new major which drops support for the Node.js LTS version which has gone out of service.
62
85
 
@@ -77,31 +100,25 @@ The oldest Node.js version supported by the current version of node-addon-api is
77
100
 
78
101
  The following is the documentation for node-addon-api.
79
102
 
80
- - [Basic Types](doc/basic_types.md)
81
- - [Array](doc/basic_types.md#array)
82
- - [Symbol](doc/symbol.md)
83
- - [String](doc/string.md)
84
- - [Name](doc/basic_types.md#name)
85
- - [Number](doc/number.md)
86
- - [Date](doc/date.md)
87
- - [BigInt](doc/bigint.md)
88
- - [Boolean](doc/boolean.md)
103
+ - [Full Class Hierarchy](doc/hierarchy.md)
104
+ - [Addon Structure](doc/addon.md)
105
+ - Data Types:
89
106
  - [Env](doc/env.md)
90
- - [Value](doc/value.md)
91
107
  - [CallbackInfo](doc/callbackinfo.md)
92
108
  - [Reference](doc/reference.md)
93
- - [External](doc/external.md)
94
- - [Object](doc/object.md)
95
- - [ObjectReference](doc/object_reference.md)
96
- - [PropertyDescriptor](doc/property_descriptor.md)
97
- - [Error Handling](doc/error_handling.md)
98
- - [Error](doc/error.md)
99
- - [TypeError](doc/type_error.md)
100
- - [RangeError](doc/range_error.md)
101
- - [Object Lifetime Management](doc/object_lifetime_management.md)
102
- - [HandleScope](doc/handle_scope.md)
103
- - [EscapableHandleScope](doc/escapable_handle_scope.md)
104
- - [Working with JavaScript Values](doc/working_with_javascript_values.md)
109
+ - [Value](doc/value.md)
110
+ - [Name](doc/name.md)
111
+ - [Symbol](doc/symbol.md)
112
+ - [String](doc/string.md)
113
+ - [Number](doc/number.md)
114
+ - [Date](doc/date.md)
115
+ - [BigInt](doc/bigint.md)
116
+ - [Boolean](doc/boolean.md)
117
+ - [External](doc/external.md)
118
+ - [Object](doc/object.md)
119
+ - [Array](doc/array.md)
120
+ - [ObjectReference](doc/object_reference.md)
121
+ - [PropertyDescriptor](doc/property_descriptor.md)
105
122
  - [Function](doc/function.md)
106
123
  - [FunctionReference](doc/function_reference.md)
107
124
  - [ObjectWrap](doc/object_wrap.md)
@@ -111,12 +128,21 @@ The following is the documentation for node-addon-api.
111
128
  - [TypedArray](doc/typed_array.md)
112
129
  - [TypedArrayOf](doc/typed_array_of.md)
113
130
  - [DataView](doc/dataview.md)
131
+ - [Error Handling](doc/error_handling.md)
132
+ - [Error](doc/error.md)
133
+ - [TypeError](doc/type_error.md)
134
+ - [RangeError](doc/range_error.md)
135
+ - [Object Lifetime Management](doc/object_lifetime_management.md)
136
+ - [HandleScope](doc/handle_scope.md)
137
+ - [EscapableHandleScope](doc/escapable_handle_scope.md)
114
138
  - [Memory Management](doc/memory_management.md)
115
139
  - [Async Operations](doc/async_operations.md)
116
140
  - [AsyncWorker](doc/async_worker.md)
117
141
  - [AsyncContext](doc/async_context.md)
118
142
  - [AsyncWorker Variants](doc/async_worker_variants.md)
119
- - [Thread-safe Functions](doc/threadsafe_function.md)
143
+ - [Thread-safe Functions](doc/threadsafe.md)
144
+ - [ThreadSafeFunction](doc/threadsafe_function.md)
145
+ - [TypedThreadSafeFunction](doc/typed_threadsafe_function.md)
120
146
  - [Promises](doc/promises.md)
121
147
  - [Version management](doc/version_management.md)
122
148
 
@@ -126,14 +152,14 @@ The following is the documentation for node-addon-api.
126
152
 
127
153
  Are you new to **node-addon-api**? Take a look at our **[examples](https://github.com/nodejs/node-addon-examples)**
128
154
 
129
- - **[Hello World](https://github.com/nodejs/node-addon-examples/tree/master/1_hello_world/node-addon-api)**
130
- - **[Pass arguments to a function](https://github.com/nodejs/node-addon-examples/tree/master/2_function_arguments/node-addon-api)**
131
- - **[Callbacks](https://github.com/nodejs/node-addon-examples/tree/master/3_callbacks/node-addon-api)**
132
- - **[Object factory](https://github.com/nodejs/node-addon-examples/tree/master/4_object_factory/node-addon-api)**
133
- - **[Function factory](https://github.com/nodejs/node-addon-examples/tree/master/5_function_factory/node-addon-api)**
134
- - **[Wrapping C++ Object](https://github.com/nodejs/node-addon-examples/tree/master/6_object_wrap/node-addon-api)**
135
- - **[Factory of wrapped object](https://github.com/nodejs/node-addon-examples/tree/master/7_factory_wrap/node-addon-api)**
136
- - **[Passing wrapped object around](https://github.com/nodejs/node-addon-examples/tree/master/8_passing_wrapped/node-addon-api)**
155
+ - **[Hello World](https://github.com/nodejs/node-addon-examples/tree/HEAD/1_hello_world/node-addon-api)**
156
+ - **[Pass arguments to a function](https://github.com/nodejs/node-addon-examples/tree/HEAD/2_function_arguments/node-addon-api)**
157
+ - **[Callbacks](https://github.com/nodejs/node-addon-examples/tree/HEAD/3_callbacks/node-addon-api)**
158
+ - **[Object factory](https://github.com/nodejs/node-addon-examples/tree/HEAD/4_object_factory/node-addon-api)**
159
+ - **[Function factory](https://github.com/nodejs/node-addon-examples/tree/HEAD/5_function_factory/node-addon-api)**
160
+ - **[Wrapping C++ Object](https://github.com/nodejs/node-addon-examples/tree/HEAD/6_object_wrap/node-addon-api)**
161
+ - **[Factory of wrapped object](https://github.com/nodejs/node-addon-examples/tree/HEAD/7_factory_wrap/node-addon-api)**
162
+ - **[Passing wrapped object around](https://github.com/nodejs/node-addon-examples/tree/HEAD/8_passing_wrapped/node-addon-api)**
137
163
 
138
164
  <a name="tests"></a>
139
165
 
@@ -152,6 +178,15 @@ npm install
152
178
  npm test --disable-deprecated
153
179
  ```
154
180
 
181
+ To run the tests targeting a specific version of Node-API run
182
+ ```
183
+ npm install
184
+ export NAPI_VERSION=X
185
+ npm test --NAPI_VERSION=X
186
+ ```
187
+
188
+ where X is the version of Node-API you want to target.
189
+
155
190
  ### **Debug**
156
191
 
157
192
  To run the **node-addon-api** tests with `--debug` option:
@@ -166,7 +201,7 @@ If you want faster build, you might use the following option:
166
201
  npm run-script dev:incremental
167
202
  ```
168
203
 
169
- Take a look and get inspired by our **[test suite](https://github.com/nodejs/node-addon-api/tree/master/test)**
204
+ Take a look and get inspired by our **[test suite](https://github.com/nodejs/node-addon-api/tree/HEAD/test)**
170
205
 
171
206
  ### **Benchmarks**
172
207
 
@@ -182,10 +217,11 @@ See [benchmark/README.md](benchmark/README.md) for more details about running an
182
217
 
183
218
  ### **More resource and info about native Addons**
184
219
  - **[C++ Addons](https://nodejs.org/dist/latest/docs/api/addons.html)**
185
- - **[N-API](https://nodejs.org/dist/latest/docs/api/n-api.html)**
186
- - **[N-API - Next Generation Node API for Native Modules](https://youtu.be/-Oniup60Afs)**
220
+ - **[Node-API](https://nodejs.org/dist/latest/docs/api/n-api.html)**
221
+ - **[Node-API - Next Generation Node API for Native Modules](https://youtu.be/-Oniup60Afs)**
222
+ - **[How We Migrated Realm JavaScript From NAN to Node-API](https://developer.mongodb.com/article/realm-javascript-nan-to-n-api)**
187
223
 
188
- As node-addon-api's core mission is to expose the plain C N-API as C++
224
+ As node-addon-api's core mission is to expose the plain C Node-API as C++
189
225
  wrappers, tools that facilitate n-api/node-addon-api providing more
190
226
  convenient patterns on developing a Node.js add-ons with n-api/node-addon-api
191
227
  can be published to NPM as standalone packages. It is also recommended to tag
@@ -193,23 +229,31 @@ such packages with `node-addon-api` to provide more visibility to the community.
193
229
 
194
230
  Quick links to NPM searches: [keywords:node-addon-api](https://www.npmjs.com/search?q=keywords%3Anode-addon-api).
195
231
 
232
+ <a name="other-bindings"></a>
233
+
234
+ ### **Other bindings**
235
+
236
+ - **[napi-rs](https://napi.rs)** - (`Rust`)
237
+
196
238
  <a name="badges"></a>
197
239
 
198
240
  ### **Badges**
199
241
 
200
- The use of badges is recommended to indicate the minimum version of N-API
242
+ The use of badges is recommended to indicate the minimum version of Node-API
201
243
  required for the module. This helps to determine which Node.js major versions are
202
- supported. Addon maintainers can consult the [N-API support matrix][] to determine
203
- which Node.js versions provide a given N-API version. The following badges are
244
+ supported. Addon maintainers can consult the [Node-API support matrix][] to determine
245
+ which Node.js versions provide a given Node-API version. The following badges are
204
246
  available:
205
247
 
206
- ![N-API v1 Badge](https://github.com/nodejs/abi-stable-node/blob/doc/assets/N-API%20v1%20Badge.svg)
207
- ![N-API v2 Badge](https://github.com/nodejs/abi-stable-node/blob/doc/assets/N-API%20v2%20Badge.svg)
208
- ![N-API v3 Badge](https://github.com/nodejs/abi-stable-node/blob/doc/assets/N-API%20v3%20Badge.svg)
209
- ![N-API v4 Badge](https://github.com/nodejs/abi-stable-node/blob/doc/assets/N-API%20v4%20Badge.svg)
210
- ![N-API v5 Badge](https://github.com/nodejs/abi-stable-node/blob/doc/assets/N-API%20v5%20Badge.svg)
211
- ![N-API v6 Badge](https://github.com/nodejs/abi-stable-node/blob/doc/assets/N-API%20v6%20Badge.svg)
212
- ![N-API Experimental Version Badge](https://github.com/nodejs/abi-stable-node/blob/doc/assets/N-API%20Experimental%20Version%20Badge.svg)
248
+ ![Node-API v1 Badge](https://github.com/nodejs/abi-stable-node/blob/doc/assets/Node-API%20v1%20Badge.svg)
249
+ ![Node-API v2 Badge](https://github.com/nodejs/abi-stable-node/blob/doc/assets/Node-API%20v2%20Badge.svg)
250
+ ![Node-API v3 Badge](https://github.com/nodejs/abi-stable-node/blob/doc/assets/Node-API%20v3%20Badge.svg)
251
+ ![Node-API v4 Badge](https://github.com/nodejs/abi-stable-node/blob/doc/assets/Node-API%20v4%20Badge.svg)
252
+ ![Node-API v5 Badge](https://github.com/nodejs/abi-stable-node/blob/doc/assets/Node-API%20v5%20Badge.svg)
253
+ ![Node-API v6 Badge](https://github.com/nodejs/abi-stable-node/blob/doc/assets/Node-API%20v6%20Badge.svg)
254
+ ![Node-API v7 Badge](https://github.com/nodejs/abi-stable-node/blob/doc/assets/Node-API%20v7%20Badge.svg)
255
+ ![Node-API v8 Badge](https://github.com/nodejs/abi-stable-node/blob/doc/assets/Node-API%20v8%20Badge.svg)
256
+ ![Node-API Experimental Version Badge](https://github.com/nodejs/abi-stable-node/blob/doc/assets/Node-API%20Experimental%20Version%20Badge.svg)
213
257
 
214
258
  ## **Contributing**
215
259
 
@@ -226,7 +270,6 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for more details on our philosophy around
226
270
  | Anna Henningsen | [addaleax](https://github.com/addaleax) |
227
271
  | Chengzhong Wu | [legendecas](https://github.com/legendecas) |
228
272
  | Gabriel Schulhof | [gabrielschulhof](https://github.com/gabrielschulhof) |
229
- | Hitesh Kanwathirtha | [digitalinfinity](https://github.com/digitalinfinity) |
230
273
  | Jim Schlight | [jschlight](https://github.com/jschlight) |
231
274
  | Michael Dawson | [mhdawson](https://github.com/mhdawson) |
232
275
  | Kevin Eady | [KevinEady](https://github.com/KevinEady)
@@ -238,6 +281,7 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for more details on our philosophy around
238
281
  | Arunesh Chandra | [aruneshchandra](https://github.com/aruneshchandra) |
239
282
  | Benjamin Byholm | [kkoopa](https://github.com/kkoopa) |
240
283
  | Jason Ginchereau | [jasongin](https://github.com/jasongin) |
284
+ | Hitesh Kanwathirtha | [digitalinfinity](https://github.com/digitalinfinity) |
241
285
  | Sampson Gao | [sampsongao](https://github.com/sampsongao) |
242
286
  | Taylor Woll | [boingoing](https://github.com/boingoing) |
243
287
 
@@ -246,4 +290,4 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for more details on our philosophy around
246
290
  Licensed under [MIT](./LICENSE.md)
247
291
 
248
292
  [ABI stability guide]: https://nodejs.org/en/docs/guides/abi-stability/
249
- [N-API support matrix]: https://nodejs.org/dist/latest/docs/api/n-api.html#n_api_n_api_version_matrix
293
+ [Node-API support matrix]: https://nodejs.org/dist/latest/docs/api/n-api.html#n_api_n_api_version_matrix
package/common.gypi CHANGED
@@ -15,7 +15,7 @@
15
15
  }
16
16
  }]
17
17
  ],
18
- 'include_dirs': ["<!@(node -p \"require('../').include\")"],
18
+ 'include_dirs': ["<!(node -p \"require('../').include_dir\")"],
19
19
  'cflags': [ '-Werror', '-Wall', '-Wextra', '-Wpedantic', '-Wunused-parameter' ],
20
20
  'cflags_cc': [ '-Werror', '-Wall', '-Wextra', '-Wpedantic', '-Wunused-parameter' ]
21
21
  }
package/index.js CHANGED
@@ -1,10 +1,11 @@
1
1
  const path = require('path');
2
2
 
3
- const include = path.relative('.', __dirname);
3
+ const include_dir = path.relative('.', __dirname);
4
4
 
5
5
  module.exports = {
6
- include: include,
7
- gyp: path.join(include, 'node_api.gyp:nothing'),
6
+ include: `"${__dirname}"`, // deprecated, can be removed as part of 4.0.0
7
+ include_dir,
8
+ gyp: path.join(include_dir, 'node_api.gyp:nothing'),
8
9
  isNodeApiBuiltin: true,
9
10
  needsFlag: false
10
11
  };
@@ -11,7 +11,7 @@ PropertyDescriptor::Accessor(const char* utf8name,
11
11
  Getter getter,
12
12
  napi_property_attributes attributes,
13
13
  void* /*data*/) {
14
- typedef details::CallbackData<Getter, Napi::Value> CbData;
14
+ using CbData = details::CallbackData<Getter, Napi::Value>;
15
15
  // TODO: Delete when the function is destroyed
16
16
  auto callbackData = new CbData({ getter, nullptr });
17
17
 
@@ -40,7 +40,7 @@ inline PropertyDescriptor PropertyDescriptor::Accessor(napi_value name,
40
40
  Getter getter,
41
41
  napi_property_attributes attributes,
42
42
  void* /*data*/) {
43
- typedef details::CallbackData<Getter, Napi::Value> CbData;
43
+ using CbData = details::CallbackData<Getter, Napi::Value>;
44
44
  // TODO: Delete when the function is destroyed
45
45
  auto callbackData = new CbData({ getter, nullptr });
46
46
 
@@ -71,7 +71,7 @@ inline PropertyDescriptor PropertyDescriptor::Accessor(const char* utf8name,
71
71
  Setter setter,
72
72
  napi_property_attributes attributes,
73
73
  void* /*data*/) {
74
- typedef details::AccessorCallbackData<Getter, Setter> CbData;
74
+ using CbData = details::AccessorCallbackData<Getter, Setter>;
75
75
  // TODO: Delete when the function is destroyed
76
76
  auto callbackData = new CbData({ getter, setter, nullptr });
77
77
 
@@ -102,7 +102,7 @@ inline PropertyDescriptor PropertyDescriptor::Accessor(napi_value name,
102
102
  Setter setter,
103
103
  napi_property_attributes attributes,
104
104
  void* /*data*/) {
105
- typedef details::AccessorCallbackData<Getter, Setter> CbData;
105
+ using CbData = details::AccessorCallbackData<Getter, Setter>;
106
106
  // TODO: Delete when the function is destroyed
107
107
  auto callbackData = new CbData({ getter, setter, nullptr });
108
108
 
@@ -133,8 +133,8 @@ inline PropertyDescriptor PropertyDescriptor::Function(const char* utf8name,
133
133
  Callable cb,
134
134
  napi_property_attributes attributes,
135
135
  void* /*data*/) {
136
- typedef decltype(cb(CallbackInfo(nullptr, nullptr))) ReturnType;
137
- typedef details::CallbackData<Callable, ReturnType> CbData;
136
+ using ReturnType = decltype(cb(CallbackInfo(nullptr, nullptr)));
137
+ using CbData = details::CallbackData<Callable, ReturnType>;
138
138
  // TODO: Delete when the function is destroyed
139
139
  auto callbackData = new CbData({ cb, nullptr });
140
140
 
@@ -163,8 +163,8 @@ inline PropertyDescriptor PropertyDescriptor::Function(napi_value name,
163
163
  Callable cb,
164
164
  napi_property_attributes attributes,
165
165
  void* /*data*/) {
166
- typedef decltype(cb(CallbackInfo(nullptr, nullptr))) ReturnType;
167
- typedef details::CallbackData<Callable, ReturnType> CbData;
166
+ using ReturnType = decltype(cb(CallbackInfo(nullptr, nullptr)));
167
+ using CbData = details::CallbackData<Callable, ReturnType>;
168
168
  // TODO: Delete when the function is destroyed
169
169
  auto callbackData = new CbData({ cb, nullptr });
170
170