koffi 2.3.4 → 2.3.6-beta.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 (206) hide show
  1. package/CHANGELOG.md +25 -2
  2. package/doc/changelog.md +4 -0
  3. package/doc/index.rst +1 -2
  4. package/doc/types.md +3 -3
  5. package/package.json +5 -5
  6. package/src/cnoke/cnoke.js +40 -834
  7. package/src/cnoke/package.json +1 -0
  8. package/src/cnoke/src/builder.js +447 -0
  9. package/src/cnoke/src/index.js +20 -0
  10. package/src/cnoke/src/tools.js +401 -0
  11. package/src/core/libcc/libcc.cc +2 -2
  12. package/src/koffi/build/2.3.6-beta.1/koffi_darwin_arm64/koffi.node +0 -0
  13. package/src/koffi/build/2.3.6-beta.1/koffi_darwin_x64/koffi.node +0 -0
  14. package/src/koffi/build/2.3.6-beta.1/koffi_freebsd_arm64/koffi.node +0 -0
  15. package/src/koffi/build/2.3.6-beta.1/koffi_freebsd_ia32/koffi.node +0 -0
  16. package/src/koffi/build/2.3.6-beta.1/koffi_freebsd_x64/koffi.node +0 -0
  17. package/src/koffi/build/2.3.6-beta.1/koffi_linux_arm32hf/koffi.node +0 -0
  18. package/src/koffi/build/2.3.6-beta.1/koffi_linux_arm64/koffi.node +0 -0
  19. package/src/koffi/build/2.3.6-beta.1/koffi_linux_ia32/koffi.node +0 -0
  20. package/src/koffi/build/2.3.6-beta.1/koffi_linux_riscv64hf64/koffi.node +0 -0
  21. package/src/koffi/build/2.3.6-beta.1/koffi_linux_x64/koffi.node +0 -0
  22. package/src/koffi/build/2.3.6-beta.1/koffi_openbsd_ia32/koffi.node +0 -0
  23. package/src/koffi/build/2.3.6-beta.1/koffi_openbsd_x64/koffi.node +0 -0
  24. package/src/koffi/build/2.3.6-beta.1/koffi_win32_arm64/koffi.exp +0 -0
  25. package/src/koffi/build/2.3.6-beta.1/koffi_win32_arm64/koffi.lib +0 -0
  26. package/src/koffi/build/2.3.6-beta.1/koffi_win32_arm64/koffi.node +0 -0
  27. package/src/koffi/build/2.3.6-beta.1/koffi_win32_arm64/koffi.pdb +0 -0
  28. package/src/koffi/build/2.3.6-beta.1/koffi_win32_ia32/koffi.exp +0 -0
  29. package/src/koffi/build/2.3.6-beta.1/koffi_win32_ia32/koffi.lib +0 -0
  30. package/src/koffi/build/2.3.6-beta.1/koffi_win32_ia32/koffi.node +0 -0
  31. package/src/koffi/build/2.3.6-beta.1/koffi_win32_ia32/koffi.pdb +0 -0
  32. package/src/koffi/build/2.3.6-beta.1/koffi_win32_x64/koffi.exp +0 -0
  33. package/src/koffi/build/2.3.6-beta.1/koffi_win32_x64/koffi.lib +0 -0
  34. package/src/koffi/build/2.3.6-beta.1/koffi_win32_x64/koffi.node +0 -0
  35. package/src/koffi/build/2.3.6-beta.1/koffi_win32_x64/koffi.pdb +0 -0
  36. package/src/koffi/src/abi_arm32.cc +43 -14
  37. package/src/koffi/src/abi_arm64.cc +95 -21
  38. package/src/koffi/src/abi_riscv64.cc +125 -64
  39. package/src/koffi/src/abi_x64_sysv.cc +38 -20
  40. package/src/koffi/src/abi_x64_win.cc +11 -5
  41. package/src/koffi/src/abi_x86.cc +14 -7
  42. package/src/koffi/src/call.cc +114 -44
  43. package/src/koffi/src/call.hh +6 -4
  44. package/src/koffi/src/ffi.cc +172 -147
  45. package/src/koffi/src/ffi.hh +18 -10
  46. package/src/koffi/src/index.d.ts +28 -7
  47. package/src/koffi/src/index.js +23 -4
  48. package/src/koffi/src/util.cc +261 -69
  49. package/src/koffi/src/util.hh +34 -8
  50. package/vendor/node-addon-api/CHANGELOG.md +122 -9
  51. package/vendor/node-addon-api/CONTRIBUTING.md +10 -10
  52. package/vendor/node-addon-api/README.md +36 -12
  53. package/vendor/node-addon-api/benchmark/function_args.cc +95 -62
  54. package/vendor/node-addon-api/benchmark/function_args.js +6 -6
  55. package/vendor/node-addon-api/benchmark/index.js +1 -1
  56. package/vendor/node-addon-api/benchmark/property_descriptor.cc +27 -34
  57. package/vendor/node-addon-api/benchmark/property_descriptor.js +5 -4
  58. package/vendor/node-addon-api/doc/async_operations.md +1 -1
  59. package/vendor/node-addon-api/doc/async_worker_variants.md +23 -2
  60. package/vendor/node-addon-api/doc/cmake-js.md +1 -1
  61. package/vendor/node-addon-api/doc/error_handling.md +3 -3
  62. package/vendor/node-addon-api/doc/external.md +7 -0
  63. package/vendor/node-addon-api/doc/handle_scope.md +14 -0
  64. package/vendor/node-addon-api/doc/hierarchy.md +1 -1
  65. package/vendor/node-addon-api/doc/object.md +27 -0
  66. package/vendor/node-addon-api/index.js +3 -3
  67. package/vendor/node-addon-api/napi-inl.deprecated.h +121 -127
  68. package/vendor/node-addon-api/napi-inl.h +1178 -1144
  69. package/vendor/node-addon-api/napi.h +2786 -2675
  70. package/vendor/node-addon-api/package.json +42 -1
  71. package/vendor/node-addon-api/test/addon.cc +8 -6
  72. package/vendor/node-addon-api/test/addon_build/index.js +9 -9
  73. package/vendor/node-addon-api/test/addon_build/tpl/addon.cc +2 -1
  74. package/vendor/node-addon-api/test/addon_build/tpl/index.js +4 -4
  75. package/vendor/node-addon-api/test/addon_data.cc +12 -13
  76. package/vendor/node-addon-api/test/array_buffer.js +3 -2
  77. package/vendor/node-addon-api/test/async_progress_queue_worker.cc +13 -3
  78. package/vendor/node-addon-api/test/async_progress_queue_worker.js +5 -5
  79. package/vendor/node-addon-api/test/async_progress_worker.cc +65 -9
  80. package/vendor/node-addon-api/test/async_progress_worker.js +14 -9
  81. package/vendor/node-addon-api/test/async_worker.cc +236 -3
  82. package/vendor/node-addon-api/test/async_worker.js +122 -37
  83. package/vendor/node-addon-api/test/async_worker_nocallback.js +9 -3
  84. package/vendor/node-addon-api/test/async_worker_persistent.js +2 -2
  85. package/vendor/node-addon-api/test/basic_types/array.js +3 -4
  86. package/vendor/node-addon-api/test/basic_types/boolean.cc +4 -2
  87. package/vendor/node-addon-api/test/basic_types/boolean.js +1 -2
  88. package/vendor/node-addon-api/test/basic_types/number.cc +12 -6
  89. package/vendor/node-addon-api/test/basic_types/number.js +19 -18
  90. package/vendor/node-addon-api/test/basic_types/value.cc +52 -1
  91. package/vendor/node-addon-api/test/basic_types/value.js +44 -21
  92. package/vendor/node-addon-api/test/bigint.cc +2 -1
  93. package/vendor/node-addon-api/test/binding.cc +11 -5
  94. package/vendor/node-addon-api/test/binding.gyp +3 -1
  95. package/vendor/node-addon-api/test/buffer.cc +46 -38
  96. package/vendor/node-addon-api/test/buffer.js +12 -12
  97. package/vendor/node-addon-api/test/callbackInfo.cc +27 -0
  98. package/vendor/node-addon-api/test/callbackInfo.js +9 -0
  99. package/vendor/node-addon-api/test/callbackscope.cc +19 -2
  100. package/vendor/node-addon-api/test/callbackscope.js +20 -20
  101. package/vendor/node-addon-api/test/common/index.js +37 -4
  102. package/vendor/node-addon-api/test/dataview/dataview.js +5 -5
  103. package/vendor/node-addon-api/test/dataview/dataview_read_write.js +14 -12
  104. package/vendor/node-addon-api/test/date.cc +2 -1
  105. package/vendor/node-addon-api/test/date.js +2 -2
  106. package/vendor/node-addon-api/test/env_cleanup.cc +12 -0
  107. package/vendor/node-addon-api/test/env_cleanup.js +38 -39
  108. package/vendor/node-addon-api/test/error.cc +6 -5
  109. package/vendor/node-addon-api/test/error_terminating_environment.js +64 -60
  110. package/vendor/node-addon-api/test/external.cc +36 -32
  111. package/vendor/node-addon-api/test/external.js +43 -46
  112. package/vendor/node-addon-api/test/function.cc +58 -44
  113. package/vendor/node-addon-api/test/function.js +4 -0
  114. package/vendor/node-addon-api/test/function_reference.cc +15 -13
  115. package/vendor/node-addon-api/test/globalObject/global_object_delete_property.js +50 -53
  116. package/vendor/node-addon-api/test/globalObject/global_object_get_property.js +33 -34
  117. package/vendor/node-addon-api/test/globalObject/global_object_has_own_property.js +38 -40
  118. package/vendor/node-addon-api/test/globalObject/global_object_set_property.js +47 -49
  119. package/vendor/node-addon-api/test/handlescope.cc +29 -3
  120. package/vendor/node-addon-api/test/handlescope.js +5 -3
  121. package/vendor/node-addon-api/test/index.js +1 -5
  122. package/vendor/node-addon-api/test/maybe/check.cc +49 -3
  123. package/vendor/node-addon-api/test/maybe/index.js +19 -7
  124. package/vendor/node-addon-api/test/memory_management.cc +9 -8
  125. package/vendor/node-addon-api/test/memory_management.js +2 -2
  126. package/vendor/node-addon-api/test/movable_callbacks.js +2 -2
  127. package/vendor/node-addon-api/test/name.js +3 -3
  128. package/vendor/node-addon-api/test/napi_child.js +2 -2
  129. package/vendor/node-addon-api/test/object/delete_property.js +7 -7
  130. package/vendor/node-addon-api/test/object/finalizer.cc +13 -12
  131. package/vendor/node-addon-api/test/object/finalizer.js +2 -2
  132. package/vendor/node-addon-api/test/object/get_property.js +6 -6
  133. package/vendor/node-addon-api/test/object/has_own_property.js +3 -3
  134. package/vendor/node-addon-api/test/object/has_property.js +4 -4
  135. package/vendor/node-addon-api/test/object/object.cc +191 -111
  136. package/vendor/node-addon-api/test/object/object.js +53 -52
  137. package/vendor/node-addon-api/test/object/object_deprecated.cc +24 -20
  138. package/vendor/node-addon-api/test/object/object_deprecated.js +3 -8
  139. package/vendor/node-addon-api/test/object/object_freeze_seal.js +54 -54
  140. package/vendor/node-addon-api/test/object/object_type_tag.cc +39 -0
  141. package/vendor/node-addon-api/test/object/object_type_tag.js +55 -0
  142. package/vendor/node-addon-api/test/object/subscript_operator.js +2 -2
  143. package/vendor/node-addon-api/test/object_reference.js +100 -100
  144. package/vendor/node-addon-api/test/objectwrap.cc +41 -34
  145. package/vendor/node-addon-api/test/objectwrap.js +23 -19
  146. package/vendor/node-addon-api/test/objectwrap_constructor_exception.cc +5 -5
  147. package/vendor/node-addon-api/test/objectwrap_constructor_exception.js +1 -1
  148. package/vendor/node-addon-api/test/objectwrap_multiple_inheritance.cc +7 -7
  149. package/vendor/node-addon-api/test/objectwrap_multiple_inheritance.js +1 -1
  150. package/vendor/node-addon-api/test/objectwrap_removewrap.js +24 -32
  151. package/vendor/node-addon-api/test/objectwrap_worker_thread.js +5 -4
  152. package/vendor/node-addon-api/test/promise.cc +7 -0
  153. package/vendor/node-addon-api/test/promise.js +3 -1
  154. package/vendor/node-addon-api/test/reference.cc +1 -1
  155. package/vendor/node-addon-api/test/reference.js +2 -2
  156. package/vendor/node-addon-api/test/run_script.cc +1 -1
  157. package/vendor/node-addon-api/test/symbol.js +59 -66
  158. package/vendor/node-addon-api/test/testUtil.js +6 -6
  159. package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function.cc +64 -29
  160. package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function.js +71 -34
  161. package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function_ctx.cc +111 -19
  162. package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function_ctx.js +2 -1
  163. package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function_existing_tsfn.cc +36 -26
  164. package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function_existing_tsfn.js +5 -5
  165. package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function_ptr.cc +3 -2
  166. package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function_ptr.js +1 -1
  167. package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function_sum.cc +47 -32
  168. package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function_sum.js +3 -3
  169. package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function_unref.cc +22 -9
  170. package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function_unref.js +76 -31
  171. package/vendor/node-addon-api/test/thunking_manual.cc +61 -74
  172. package/vendor/node-addon-api/test/thunking_manual.js +6 -7
  173. package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function.cc +20 -20
  174. package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function.js +19 -19
  175. package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function_ctx.cc +57 -5
  176. package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function_ctx.js +2 -0
  177. package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function_existing_tsfn.js +5 -5
  178. package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function_ptr.cc +5 -1
  179. package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function_ptr.js +4 -3
  180. package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function_sum.js +3 -3
  181. package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function_unref.cc +14 -0
  182. package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function_unref.js +76 -31
  183. package/vendor/node-addon-api/test/typedarray-bigint.js +2 -2
  184. package/vendor/node-addon-api/test/typedarray.cc +263 -70
  185. package/vendor/node-addon-api/test/typedarray.js +44 -10
  186. package/vendor/node-addon-api/test/version_management.cc +16 -15
  187. package/vendor/node-addon-api/test/version_management.js +18 -20
  188. package/vendor/node-addon-api/tools/check-napi.js +13 -14
  189. package/vendor/node-addon-api/tools/conversion.js +161 -169
  190. package/vendor/node-addon-api/tools/eslint-format.js +9 -1
  191. package/vendor/node-addon-api/unit-test/README.md +4 -4
  192. package/src/koffi/build/2.3.4/koffi_darwin_arm64.tar.gz +0 -0
  193. package/src/koffi/build/2.3.4/koffi_darwin_x64.tar.gz +0 -0
  194. package/src/koffi/build/2.3.4/koffi_freebsd_arm64.tar.gz +0 -0
  195. package/src/koffi/build/2.3.4/koffi_freebsd_ia32.tar.gz +0 -0
  196. package/src/koffi/build/2.3.4/koffi_freebsd_x64.tar.gz +0 -0
  197. package/src/koffi/build/2.3.4/koffi_linux_arm32hf.tar.gz +0 -0
  198. package/src/koffi/build/2.3.4/koffi_linux_arm64.tar.gz +0 -0
  199. package/src/koffi/build/2.3.4/koffi_linux_ia32.tar.gz +0 -0
  200. package/src/koffi/build/2.3.4/koffi_linux_riscv64hf64.tar.gz +0 -0
  201. package/src/koffi/build/2.3.4/koffi_linux_x64.tar.gz +0 -0
  202. package/src/koffi/build/2.3.4/koffi_openbsd_ia32.tar.gz +0 -0
  203. package/src/koffi/build/2.3.4/koffi_openbsd_x64.tar.gz +0 -0
  204. package/src/koffi/build/2.3.4/koffi_win32_arm64.tar.gz +0 -0
  205. package/src/koffi/build/2.3.4/koffi_win32_ia32.tar.gz +0 -0
  206. package/src/koffi/build/2.3.4/koffi_win32_x64.tar.gz +0 -0
@@ -1,5 +1,118 @@
1
1
  # node-addon-api Changelog
2
2
 
3
+ ## 2023-02-03 Version 6.0.0, @NickNaso
4
+
5
+ ### Notable changes
6
+
7
+ #### API
8
+
9
+ - Added `Napi::Object::TypeTag()` and `Napi::Object::CheckTypeTag()` methods.
10
+ - Made operator `napi_callback_info` explicit.
11
+
12
+ #### TEST
13
+
14
+ - Some minor fixes all over the test suite.
15
+ - Added tests related to `Napi::Object::TypeTag()` and `Napi::Object::CheckTypeTag()` methods.
16
+ - Added tests related to `Napi::CallbackScope`.
17
+ - Added tests related to `Napi::EscapableHandleScope`.
18
+ - Added tests related to `Napi::Maybe<T>`.
19
+ - Added tests related to `Napi::ThreadSafeFuntion`.
20
+ - Changed some tests related to `Napi::AsyncWorker`.
21
+
22
+ ### Documentation
23
+
24
+ - Added documentation for `Napi::Object::TypeTag()` and `Napi::Object::CheckTypeTag()` methods.
25
+ - Added documentation about how to run a specific unit test.
26
+
27
+ ### TOOL
28
+
29
+ - Added `x86` architecture to the CI matrix.
30
+
31
+ ### Commits
32
+
33
+ * \[[`e2726193f1`](https://github.com/nodejs/node-addon-api/commit/e2726193f1)] - **src**: remove AsyncWorker move and complete tests (JckXia) [#1266](https://github.com/nodejs/node-addon-api/pull/1266)
34
+ * \[[`ff969485ea`](https://github.com/nodejs/node-addon-api/commit/ff969485ea)] - **chore**: build node-addon-api against X86 (JckXia) [#1276](https://github.com/nodejs/node-addon-api/pull/1276)
35
+ * \[[`a70564cdfd`](https://github.com/nodejs/node-addon-api/commit/a70564cdfd)] - **test**: add cov for ThreadSafeFunction new overloads (JckXia) [#1251](https://github.com/nodejs/node-addon-api/pull/1251)
36
+ * \[[`53f7cf1d48`](https://github.com/nodejs/node-addon-api/commit/53f7cf1d48)] - **src**: make operator napi\_callback\_info explicit (Kevin Eady) [#1275](https://github.com/nodejs/node-addon-api/pull/1275)
37
+ * \[[`78b5a15533`](https://github.com/nodejs/node-addon-api/commit/78b5a15533)] - **test**: Add tests for ThreadSafeFunction's NonBlock function overloads (#1249) (Jack)
38
+ * \[[`fdc6263034`](https://github.com/nodejs/node-addon-api/commit/fdc6263034)] - **test**: Add test covg for Maybe\<T> (#1270) (Jack)
39
+ * \[[`35d9d669b3`](https://github.com/nodejs/node-addon-api/commit/35d9d669b3)] - **test**: add test covg for handle and escapehandle scopes (JckXia) [#1263](https://github.com/nodejs/node-addon-api/pull/1263)
40
+ * \[[`021313409e`](https://github.com/nodejs/node-addon-api/commit/021313409e)] - **test**: add unit test covg for callbackscopes (JckXia) [#1262](https://github.com/nodejs/node-addon-api/pull/1262)
41
+ * \[[`b11e4de2cf`](https://github.com/nodejs/node-addon-api/commit/b11e4de2cf)] - **src**: add Object::TypeTag, Object::CheckTypeTag (Kevin Eady) [#1261](https://github.com/nodejs/node-addon-api/pull/1261)
42
+
43
+ ## 2023-01-13 Version 5.1.0, @NickNaso
44
+
45
+ ### Notable changes
46
+
47
+ #### API
48
+
49
+ - Fixed memory leak in `Napi::AsyncProgressWorkerBase`.
50
+ - Added api to get `callback_info` from `Napi::CallBackInfo`.
51
+ - Fixed erros and warning in VS 2017.
52
+ - Made `Npi::Env::CleanupHook` public.
53
+ - Removed `Napi::TypedArray::unknown_array_type`.
54
+
55
+ #### TEST
56
+
57
+ - Some minor fixes all over the test suite.
58
+ - Added tests related to `Napi::Env`.
59
+ - Added tests related to `Napi::TypedArray`.
60
+ - Added tests related to `Napi::AsyncWorker`.
61
+ - Added tests related to `Napi::TypedThreadSafeFunction`.
62
+ - Added tests related to `Napi::Value`.
63
+ - Added test related to `Napi::Promise`.
64
+
65
+ ### Documentation
66
+
67
+ - Some minor fixes all over the documentation.
68
+ - Added `Napi::HandleScope` example.
69
+ - Added documentation about how to run a specific unit test.
70
+
71
+ ### TOOL
72
+
73
+ - Added Windows with VS 2022 and Node.JS 19.x to the CI matrix.
74
+ - Fixed stale workflow.
75
+ - Updated Node.js versions on CI component.
76
+ - Added condition for Window to find eslint.
77
+
78
+ ### Commits
79
+
80
+ * \[[`79a446fb9c`](https://github.com/nodejs/node-addon-api/commit/79a446fb9c)] - Update contributors (#1265) (Kevin Eady)
81
+ * \[[`01c61690c6`](https://github.com/nodejs/node-addon-api/commit/01c61690c6)] - **src**: napi-inl: Fix a memory leak bug in `AsyncProgressWorkerBase` (Ammar Faizi) [#1264](https://github.com/nodejs/node-addon-api/pull/1264)
82
+ * \[[`55bd08ee26`](https://github.com/nodejs/node-addon-api/commit/55bd08ee26)] - **src**: api to get callback\_info from CallBackInfo (JckXia) [#1253](https://github.com/nodejs/node-addon-api/pull/1253)
83
+ * \[[`ad76256714`](https://github.com/nodejs/node-addon-api/commit/ad76256714)] - **test**: add tests related to env (JckXia) [#1254](https://github.com/nodejs/node-addon-api/pull/1254)
84
+ * \[[`5c3937365d`](https://github.com/nodejs/node-addon-api/commit/5c3937365d)] - **chore**: add Windows with VS 2022 and Node.JS 19.x to the CI matrix (#1252) (Vladimir Morozov)
85
+ * \[[`97736c93f4`](https://github.com/nodejs/node-addon-api/commit/97736c93f4)] - **src**: fix errors and warnings in VS 2017 (Vladimir Morozov) [#1245](https://github.com/nodejs/node-addon-api/pull/1245)
86
+ * \[[`ad7ff92c16`](https://github.com/nodejs/node-addon-api/commit/ad7ff92c16)] - **src**: refactor call js wrapper (#1242) (Jack)
87
+ * \[[`39267baf1b`](https://github.com/nodejs/node-addon-api/commit/39267baf1b)] - **src**: make CleanupHook public (Julian Mesa) [#1240](https://github.com/nodejs/node-addon-api/pull/1240)
88
+ * \[[`edf630cc79`](https://github.com/nodejs/node-addon-api/commit/edf630cc79)] - **src**: fix implementation of Signal (Kevin Eady) [#1216](https://github.com/nodejs/node-addon-api/pull/1216)
89
+ * \[[`de5a502f3c`](https://github.com/nodejs/node-addon-api/commit/de5a502f3c)] - **doc**: Napi::Error is caught (Nicola Del Gobbo) [#1241](https://github.com/nodejs/node-addon-api/pull/1241)
90
+ * \[[`10ad762807`](https://github.com/nodejs/node-addon-api/commit/10ad762807)] - **test**: removed the usage of default\_configuration. (Nicola Del Gobbo) [#1226](https://github.com/nodejs/node-addon-api/pull/1226)
91
+ * \[[`e9db2adef2`](https://github.com/nodejs/node-addon-api/commit/e9db2adef2)] - **test**: Add test coverage to TSFN::New() overloads (#1201) (Jack)
92
+ * \[[`c849ad3f6a`](https://github.com/nodejs/node-addon-api/commit/c849ad3f6a)] - **chore**: fix stale workflow (#1228) (Richard Lau)
93
+ * \[[`e408804ad8`](https://github.com/nodejs/node-addon-api/commit/e408804ad8)] - **test**: adding ref for threadsafefunctions (JckXia) [#1222](https://github.com/nodejs/node-addon-api/pull/1222)
94
+ * \[[`a8afb2d73c`](https://github.com/nodejs/node-addon-api/commit/a8afb2d73c)] - **src**: remove TypedArray::unknown\_array\_type (Kevin Eady) [#1209](https://github.com/nodejs/node-addon-api/pull/1209)
95
+ * \[[`257a52f823`](https://github.com/nodejs/node-addon-api/commit/257a52f823)] - **test**: Add test cased for failed task cancellations (#1214) (Jack)
96
+ * \[[`793268c59f`](https://github.com/nodejs/node-addon-api/commit/793268c59f)] - **test**: Add test case for canceling async worker tasks (#1202) (Jack)
97
+ * \[[`1331856ef1`](https://github.com/nodejs/node-addon-api/commit/1331856ef1)] - **doc**: add HandleScope example (#1210) (Kevin Eady)
98
+ * \[[`d5fc875e5d`](https://github.com/nodejs/node-addon-api/commit/d5fc875e5d)] - **test**: remove update to process.config (#1208) (Michael Dawson)
99
+ * \[[`30cd4a37f0`](https://github.com/nodejs/node-addon-api/commit/30cd4a37f0)] - **test**: add tests for .Data method (JckXia) [#1203](https://github.com/nodejs/node-addon-api/pull/1203)
100
+ * \[[`225ca35963`](https://github.com/nodejs/node-addon-api/commit/225ca35963)] - **test**: Add test coverage for "TSFN::Ref()" (#1196) (Jack)
101
+ * \[[`5a5a213985`](https://github.com/nodejs/node-addon-api/commit/5a5a213985)] - Update CI component versions (#1200) (Vladimir Morozov)
102
+ * \[[`fb27e72b0c`](https://github.com/nodejs/node-addon-api/commit/fb27e72b0c)] - **doc**: Update CONTRIBUTING.md (Saint Gabriel) [#1185](https://github.com/nodejs/node-addon-api/pull/1185)
103
+ * \[[`e9def3ed72`](https://github.com/nodejs/node-addon-api/commit/e9def3ed72)] - **doc**: Update Readme for filter conditions in unit tests (Deepak Rajamohan) [#1199](https://github.com/nodejs/node-addon-api/pull/1199)
104
+ * \[[`efd67876e1`](https://github.com/nodejs/node-addon-api/commit/efd67876e1)] - **doc**: updated npm script for focused tests (Peter Šándor)
105
+ * \[[`134961d853`](https://github.com/nodejs/node-addon-api/commit/134961d853)] - **test**: CallbackInfo NewTarget() basic coverage (#1048) (Peter Šándor)
106
+ * \[[`1dfd03bdd5`](https://github.com/nodejs/node-addon-api/commit/1dfd03bdd5)] - Update README.md (#1187) (Saint Gabriel)
107
+ * \[[`576128fd19`](https://github.com/nodejs/node-addon-api/commit/576128fd19)] - **doc**: fix typo in async\_operations.md (#1189) (Tobias Nießen)
108
+ * \[[`63d3c30ec1`](https://github.com/nodejs/node-addon-api/commit/63d3c30ec1)] - **test**: add tests for TypedArray (Dante Calderon) [#1179](https://github.com/nodejs/node-addon-api/pull/1179)
109
+ * \[[`358ac2f080`](https://github.com/nodejs/node-addon-api/commit/358ac2f080)] - Fix link to CMake.js documentation (#1180) (Kyle Kovacs)
110
+ * \[[`dc4f2bbe4a`](https://github.com/nodejs/node-addon-api/commit/dc4f2bbe4a)] - **test**: Add promise unit test (#1173) (Jenny)
111
+ * \[[`f3124ae0ed`](https://github.com/nodejs/node-addon-api/commit/f3124ae0ed)] - **doc**: fix broken `Napi::ThreadSafeFunction` link (#1172) (Feng Yu)
112
+ * \[[`10b440fe27`](https://github.com/nodejs/node-addon-api/commit/10b440fe27)] - **src**: reformat all code (Kevin Eady) [#1160](https://github.com/nodejs/node-addon-api/pull/1160)
113
+ * \[[`33e402971e`](https://github.com/nodejs/node-addon-api/commit/33e402971e)] - **test**: Add condition for window to find eslint (#1176) (Jack)
114
+ * \[[`d53843b83b`](https://github.com/nodejs/node-addon-api/commit/d53843b83b)] - **test**: add missing value tests (JckXia) [#1170](https://github.com/nodejs/node-addon-api/pull/1170)
115
+
3
116
  ## 2022-05-02 Version 5.0.0, @NickNaso
4
117
 
5
118
  ### Notable changes:
@@ -16,7 +129,7 @@ of `Napi::Value`'s.
16
129
  - Improved the test framework. Added the possibility to run subsets of tests
17
130
  more easily.
18
131
  - Added test for `Napi::AsyncContext` class.
19
- - Fixed ramdom failure on test for `Napi::ThreadSafeFunction` e
132
+ - Fixed ramdom failure on test for `Napi::ThreadSafeFunction` e
20
133
  `Napi::TypedThreadSafeFunction` class.
21
134
  - Fixed compilation problem on debian 8 system.
22
135
  - Added test for `Napi::Object::Set()` method.
@@ -142,10 +255,10 @@ more easily.
142
255
 
143
256
  #### API
144
257
 
145
- - `Napi::Reference` updated the default value to reflect the most possible
258
+ - `Napi::Reference` updated the default value to reflect the most possible
146
259
  values when there are any errors occurred on `napi_reference_unref`.
147
260
  - Added the check for nullpointer on `Napi::String` initialization.
148
- - Added the wraps for `napi_add_env_cleanup_hook` and
261
+ - Added the wraps for `napi_add_env_cleanup_hook` and
149
262
  `napi_remove_env_cleanup_hook`.
150
263
  - Added `Napi::Maybe<T>` class to handle pending exception when cpp exception
151
264
  disabled.
@@ -176,9 +289,9 @@ disabled.
176
289
 
177
290
  #### API
178
291
 
179
- - Fixed a crashing issue in `Napi::Error::ThrowAsJavaScriptException`
292
+ - Fixed a crashing issue in `Napi::Error::ThrowAsJavaScriptException`
180
293
  introducing the preprocessor directive `NODE_API_SWALLOW_UNTHROWABLE_EXCEPTIONS`.
181
- - Fixed compilation problem for GCC 11 and C++20.
294
+ - Fixed compilation problem for GCC 11 and C++20.
182
295
 
183
296
  #### TEST
184
297
 
@@ -297,12 +410,12 @@ introducing the preprocessor directive `NODE_API_SWALLOW_UNTHROWABLE_EXCEPTIONS`
297
410
  #### API
298
411
 
299
412
  - Added `Napi::TypedThreadSafeFunction` class that is a new implementation for
300
- thread-safe functions.
413
+ thread-safe functions.
301
414
  - Fixed leak on `Napi::AsyncProgressWorkerBase`.
302
- - Fixed empty data on `Napi::AsyncProgressWorker::OnProgress` caused by race
415
+ - Fixed empty data on `Napi::AsyncProgressWorker::OnProgress` caused by race
303
416
  conditions of `Napi::AsyncProgressWorker`.
304
417
  - Added `Napi::ArrayBuffer::Detach()` and `Napi::ArrayBuffer::IsDetached()`.
305
- - Fixed problem on `Napi::FinalizeCallback` it needs to create a
418
+ - Fixed problem on `Napi::FinalizeCallback` it needs to create a
306
419
  `Napi::HandleScope` when it calls `Napi::ObjectWrap::~ObjectWrap()`.
307
420
 
308
421
  #### Documentation
@@ -373,7 +486,7 @@ conditions of `Napi::AsyncProgressWorker`.
373
486
  #### API
374
487
 
375
488
  - Introduced `include_dir` for use with **gyp** in a scalar context.
376
- - Added `Napi::Addon` to help handle the loading of a native add-on into
489
+ - Added `Napi::Addon` to help handle the loading of a native add-on into
377
490
  multiple threads and or multiple times in the same thread.
378
491
  - Concentrate callbacks provided to core N-API.
379
492
  - Make sure wrapcallback is used.
@@ -4,19 +4,19 @@
4
4
  By making a contribution to this project, I certify that:
5
5
 
6
6
  (a) The contribution was created in whole or in part by me and I
7
- have the right to submit it under the open source license
7
+ have the right to submit it under the open-source license
8
8
  indicated in the file; or
9
9
 
10
10
  (b) The contribution is based upon previous work that, to the best
11
11
  of my knowledge, is covered under an appropriate open source
12
12
  license and I have the right under that license to submit that
13
13
  work with modifications, whether created in whole or in part
14
- by me, under the same open source license (unless I am
14
+ by me, under the same open-source license (unless I am
15
15
  permitted to submit under a different license), as indicated
16
16
  in the file; or
17
17
 
18
18
  (c) The contribution was provided directly to me by some other
19
- person who certified (a), (b) or (c) and I have not modified
19
+ person who certified (a), (b), or (c) and I have not modified
20
20
  it.
21
21
 
22
22
  (d) I understand and agree that this project and the contribution
@@ -38,7 +38,7 @@ contribute to **node-addon-api**:
38
38
 
39
39
  **node-addon-api** is meant to be a thin convenience wrapper around Node-API. With this
40
40
  in mind, contributions of any new APIs that wrap around a core Node-API API will
41
- be considered for merge. However, changes that wrap existing **node-addon-api**
41
+ be considered for merging. However, changes that wrap existing **node-addon-api**
42
42
  APIs are encouraged to instead be provided as an ecosystem module. The
43
43
  **node-addon-api** team is happy to link to a curated set of modules that build on
44
44
  top of **node-addon-api** if they have broad usefulness to the community and promote
@@ -46,13 +46,13 @@ a recommended idiom or pattern.
46
46
 
47
47
  ### Rationale
48
48
 
49
- The Node-API team considered a couple different approaches with regards to changes
49
+ The Node-API team considered a couple of different approaches with regard to changes
50
50
  extending **node-addon-api**
51
51
  - Larger core module - Incorporate these helpers and patterns into **node-addon-api**
52
52
  - Extras package - Create a new package (strawman name '**node-addon-api**-extras')
53
53
  that contain utility classes and methods that help promote good patterns and
54
54
  idioms while writing native addons with **node-addon-api**.
55
- - Ecosystem - Encourage creation of a module ecosystem around **node-addon-api**
55
+ - Ecosystem - Encourage the creation of a module ecosystem around **node-addon-api**
56
56
  where folks can build on top of it.
57
57
 
58
58
  #### Larger Core
@@ -65,9 +65,9 @@ The downside of the approach is the following:
65
65
  - More maintenance burden on the Node-API WG core team.
66
66
 
67
67
  #### Extras Package
68
- This involves us spinning up a new package which contains the utility classes
68
+ This involves us spinning up a new package that contains the utility classes
69
69
  and methods. This has the benefit of having a separate module where helpers
70
- which make it easier to implement certain patterns and idioms for native addons
70
+ make it easier to implement certain patterns and idioms for native addons
71
71
  easier.
72
72
 
73
73
  The downside of this approach is the following:
@@ -86,8 +86,8 @@ modules (listing them out on the repository/wiki, using them in workshops/tutori
86
86
  etc).
87
87
 
88
88
  The downside of this approach is the following:
89
- - Potential for lack of visibility - evangelism and education is hard, and module
90
- authors might not find right patterns and instead implement things themselves
89
+ - Potential for lack of visibility. Evangelism and education are hard, and module
90
+ authors might not find the right patterns and instead implement things themselves
91
91
  - There might be greater friction for the Node-API WG in evolving APIs since the
92
92
  ecosystem would have taken dependencies on the API shape of **node-addon-api**
93
93
 
@@ -16,15 +16,15 @@ provided by Node.js when using C++. It provides a C++ object model
16
16
  and exception handling semantics with low overhead.
17
17
 
18
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
19
+ use of internal V8, libuv, and Node.js libraries. Unless there is a need for
20
+ direct access to functionality that is not exposed by Node-API as outlined
21
21
  in [C/C++ addons](https://nodejs.org/dist/latest/docs/api/addons.html)
22
22
  in Node.js core, use Node-API. Refer to
23
23
  [C/C++ addons with Node-API](https://nodejs.org/dist/latest/docs/api/n-api.html)
24
24
  for more information on Node-API.
25
25
 
26
26
  Node-API is an ABI stable C interface provided by Node.js for building native
27
- addons. It is independent from the underlying JavaScript runtime (e.g. V8 or ChakraCore)
27
+ addons. It is independent of the underlying JavaScript runtime (e.g. V8 or ChakraCore)
28
28
  and is maintained as part of Node.js itself. It is intended to insulate
29
29
  native addons from changes in the underlying JavaScript engine and allow
30
30
  modules compiled for one version to run on later versions of Node.js without
@@ -46,7 +46,7 @@ provides an [ABI stability guide][] containing a detailed explanation of ABI
46
46
  stability in general, and the Node-API ABI stability guarantee in particular.
47
47
 
48
48
  As new APIs are added to Node-API, node-addon-api must be updated to provide
49
- wrappers for those new APIs. For this reason node-addon-api provides
49
+ wrappers for those new APIs. For this reason, node-addon-api provides
50
50
  methods that allow callers to obtain the underlying Node-API handles so
51
51
  direct calls to Node-API and the use of the objects/methods provided by
52
52
  node-addon-api can be used together. For example, in order to be able
@@ -56,7 +56,7 @@ APIs exposed by node-addon-api are generally used to create and
56
56
  manipulate JavaScript values. Concepts and operations generally map
57
57
  to ideas specified in the **ECMA262 Language Specification**.
58
58
 
59
- The [Node-API Resource](https://nodejs.github.io/node-addon-examples/) offers an
59
+ The [Node-API Resource](https://nodejs.github.io/node-addon-examples/) offers an
60
60
  excellent orientation and tips for developers just getting started with Node-API
61
61
  and node-addon-api.
62
62
 
@@ -70,7 +70,7 @@ and node-addon-api.
70
70
  - **[Contributors](#contributors)**
71
71
  - **[License](#license)**
72
72
 
73
- ## **Current version: 5.0.0**
73
+ ## **Current version: 6.0.0**
74
74
 
75
75
  (See [CHANGELOG.md](CHANGELOG.md) for complete Changelog)
76
76
 
@@ -187,6 +187,28 @@ npm test --NAPI_VERSION=X
187
187
 
188
188
  where X is the version of Node-API you want to target.
189
189
 
190
+ To run a specific unit test, filter conditions are available
191
+
192
+ **Example:**
193
+ compile and run only tests on objectwrap.cc and objectwrap.js
194
+ ```
195
+ npm run unit --filter=objectwrap
196
+ ```
197
+
198
+ Multiple unit tests cane be selected with wildcards
199
+
200
+ **Example:**
201
+ compile and run all test files ending with "reference" -> function_reference.cc, object_reference.cc, reference.cc
202
+ ```
203
+ npm run unit --filter=*reference
204
+ ```
205
+
206
+ Multiple filter conditions can be joined to broaden the test selection
207
+
208
+ **Example:**
209
+ compile and run all tests under folders threadsafe_function and typed_threadsafe_function and also the objectwrap.cc file
210
+ npm run unit --filter='*function objectwrap'
211
+
190
212
  ### **Debug**
191
213
 
192
214
  To run the **node-addon-api** tests with `--debug` option:
@@ -195,7 +217,7 @@ To run the **node-addon-api** tests with `--debug` option:
195
217
  npm run-script dev
196
218
  ```
197
219
 
198
- If you want faster build, you might use the following option:
220
+ If you want a faster build, you might use the following option:
199
221
 
200
222
  ```
201
223
  npm run-script dev:incremental
@@ -223,7 +245,7 @@ See [benchmark/README.md](benchmark/README.md) for more details about running an
223
245
 
224
246
  As node-addon-api's core mission is to expose the plain C Node-API as C++
225
247
  wrappers, tools that facilitate n-api/node-addon-api providing more
226
- convenient patterns on developing a Node.js add-ons with n-api/node-addon-api
248
+ convenient patterns for developing a Node.js add-on with n-api/node-addon-api
227
249
  can be published to NPM as standalone packages. It is also recommended to tag
228
250
  such packages with `node-addon-api` to provide more visibility to the community.
229
251
 
@@ -269,19 +291,21 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for more details on our philosophy around
269
291
  | ------------------- | ----------------------------------------------------- |
270
292
  | Anna Henningsen | [addaleax](https://github.com/addaleax) |
271
293
  | Chengzhong Wu | [legendecas](https://github.com/legendecas) |
272
- | Gabriel Schulhof | [gabrielschulhof](https://github.com/gabrielschulhof) |
273
- | Jim Schlight | [jschlight](https://github.com/jschlight) |
294
+ | Jack Xia | [JckXia](https://github.com/JckXia) |
295
+ | Kevin Eady | [KevinEady](https://github.com/KevinEady) |
274
296
  | Michael Dawson | [mhdawson](https://github.com/mhdawson) |
275
- | Kevin Eady | [KevinEady](https://github.com/KevinEady)
276
297
  | Nicola Del Gobbo | [NickNaso](https://github.com/NickNaso) |
298
+ | Vladimir Morozov | [vmoroz](https://github.com/vmoroz) |
277
299
 
278
300
  ### Emeritus
279
301
  | Name | GitHub Link |
280
302
  | ------------------- | ----------------------------------------------------- |
281
303
  | Arunesh Chandra | [aruneshchandra](https://github.com/aruneshchandra) |
282
304
  | Benjamin Byholm | [kkoopa](https://github.com/kkoopa) |
283
- | Jason Ginchereau | [jasongin](https://github.com/jasongin) |
305
+ | Gabriel Schulhof | [gabrielschulhof](https://github.com/gabrielschulhof) |
284
306
  | Hitesh Kanwathirtha | [digitalinfinity](https://github.com/digitalinfinity) |
307
+ | Jason Ginchereau | [jasongin](https://github.com/jasongin) |
308
+ | Jim Schlight | [jschlight](https://github.com/jschlight) |
285
309
  | Sampson Gao | [sampsongao](https://github.com/sampsongao) |
286
310
  | Taylor Woll | [boingoing](https://github.com/boingoing) |
287
311
 
@@ -1,8 +1,8 @@
1
1
  #include "napi.h"
2
2
 
3
3
  static napi_value NoArgFunction_Core(napi_env env, napi_callback_info info) {
4
- (void) env;
5
- (void) info;
4
+ (void)env;
5
+ (void)info;
6
6
  return nullptr;
7
7
  }
8
8
 
@@ -12,7 +12,7 @@ static napi_value OneArgFunction_Core(napi_env env, napi_callback_info info) {
12
12
  if (napi_get_cb_info(env, info, &argc, &argv, nullptr, nullptr) != napi_ok) {
13
13
  return nullptr;
14
14
  }
15
- (void) argv;
15
+ (void)argv;
16
16
  return nullptr;
17
17
  }
18
18
 
@@ -22,8 +22,8 @@ static napi_value TwoArgFunction_Core(napi_env env, napi_callback_info info) {
22
22
  if (napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr) != napi_ok) {
23
23
  return nullptr;
24
24
  }
25
- (void) argv[0];
26
- (void) argv[1];
25
+ (void)argv[0];
26
+ (void)argv[1];
27
27
  return nullptr;
28
28
  }
29
29
 
@@ -33,9 +33,9 @@ static napi_value ThreeArgFunction_Core(napi_env env, napi_callback_info info) {
33
33
  if (napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr) != napi_ok) {
34
34
  return nullptr;
35
35
  }
36
- (void) argv[0];
37
- (void) argv[1];
38
- (void) argv[2];
36
+ (void)argv[0];
37
+ (void)argv[1];
38
+ (void)argv[2];
39
39
  return nullptr;
40
40
  }
41
41
 
@@ -45,95 +45,128 @@ static napi_value FourArgFunction_Core(napi_env env, napi_callback_info info) {
45
45
  if (napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr) != napi_ok) {
46
46
  return nullptr;
47
47
  }
48
- (void) argv[0];
49
- (void) argv[1];
50
- (void) argv[2];
51
- (void) argv[3];
48
+ (void)argv[0];
49
+ (void)argv[1];
50
+ (void)argv[2];
51
+ (void)argv[3];
52
52
  return nullptr;
53
53
  }
54
54
 
55
55
  static void NoArgFunction(const Napi::CallbackInfo& info) {
56
- (void) info;
56
+ (void)info;
57
57
  }
58
58
 
59
59
  static void OneArgFunction(const Napi::CallbackInfo& info) {
60
- Napi::Value argv0 = info[0]; (void) argv0;
60
+ Napi::Value argv0 = info[0];
61
+ (void)argv0;
61
62
  }
62
63
 
63
64
  static void TwoArgFunction(const Napi::CallbackInfo& info) {
64
- Napi::Value argv0 = info[0]; (void) argv0;
65
- Napi::Value argv1 = info[1]; (void) argv1;
65
+ Napi::Value argv0 = info[0];
66
+ (void)argv0;
67
+ Napi::Value argv1 = info[1];
68
+ (void)argv1;
66
69
  }
67
70
 
68
71
  static void ThreeArgFunction(const Napi::CallbackInfo& info) {
69
- Napi::Value argv0 = info[0]; (void) argv0;
70
- Napi::Value argv1 = info[1]; (void) argv1;
71
- Napi::Value argv2 = info[2]; (void) argv2;
72
+ Napi::Value argv0 = info[0];
73
+ (void)argv0;
74
+ Napi::Value argv1 = info[1];
75
+ (void)argv1;
76
+ Napi::Value argv2 = info[2];
77
+ (void)argv2;
72
78
  }
73
79
 
74
80
  static void FourArgFunction(const Napi::CallbackInfo& info) {
75
- Napi::Value argv0 = info[0]; (void) argv0;
76
- Napi::Value argv1 = info[1]; (void) argv1;
77
- Napi::Value argv2 = info[2]; (void) argv2;
78
- Napi::Value argv3 = info[3]; (void) argv3;
81
+ Napi::Value argv0 = info[0];
82
+ (void)argv0;
83
+ Napi::Value argv1 = info[1];
84
+ (void)argv1;
85
+ Napi::Value argv2 = info[2];
86
+ (void)argv2;
87
+ Napi::Value argv3 = info[3];
88
+ (void)argv3;
79
89
  }
80
90
 
81
91
  #if NAPI_VERSION > 5
82
92
  class FunctionArgsBenchmark : public Napi::Addon<FunctionArgsBenchmark> {
83
93
  public:
84
94
  FunctionArgsBenchmark(Napi::Env env, Napi::Object exports) {
85
- DefineAddon(exports, {
86
- InstanceValue("addon", DefineProperties(Napi::Object::New(env), {
87
- InstanceMethod("noArgFunction", &FunctionArgsBenchmark::NoArgFunction),
88
- InstanceMethod("oneArgFunction",
89
- &FunctionArgsBenchmark::OneArgFunction),
90
- InstanceMethod("twoArgFunction",
91
- &FunctionArgsBenchmark::TwoArgFunction),
92
- InstanceMethod("threeArgFunction",
93
- &FunctionArgsBenchmark::ThreeArgFunction),
94
- InstanceMethod("fourArgFunction",
95
- &FunctionArgsBenchmark::FourArgFunction),
96
- }), napi_enumerable),
97
- InstanceValue("addon_templated",
98
- DefineProperties(Napi::Object::New(env), {
99
- InstanceMethod<&FunctionArgsBenchmark::NoArgFunction>(
100
- "noArgFunction"),
101
- InstanceMethod<&FunctionArgsBenchmark::OneArgFunction>(
102
- "oneArgFunction"),
103
- InstanceMethod<&FunctionArgsBenchmark::TwoArgFunction>(
104
- "twoArgFunction"),
105
- InstanceMethod<&FunctionArgsBenchmark::ThreeArgFunction>(
106
- "threeArgFunction"),
107
- InstanceMethod<&FunctionArgsBenchmark::FourArgFunction>(
108
- "fourArgFunction"),
109
- }), napi_enumerable),
110
- });
95
+ DefineAddon(
96
+ exports,
97
+ {
98
+ InstanceValue(
99
+ "addon",
100
+ DefineProperties(
101
+ Napi::Object::New(env),
102
+ {
103
+ InstanceMethod("noArgFunction",
104
+ &FunctionArgsBenchmark::NoArgFunction),
105
+ InstanceMethod("oneArgFunction",
106
+ &FunctionArgsBenchmark::OneArgFunction),
107
+ InstanceMethod("twoArgFunction",
108
+ &FunctionArgsBenchmark::TwoArgFunction),
109
+ InstanceMethod(
110
+ "threeArgFunction",
111
+ &FunctionArgsBenchmark::ThreeArgFunction),
112
+ InstanceMethod("fourArgFunction",
113
+ &FunctionArgsBenchmark::FourArgFunction),
114
+ }),
115
+ napi_enumerable),
116
+ InstanceValue(
117
+ "addon_templated",
118
+ DefineProperties(
119
+ Napi::Object::New(env),
120
+ {
121
+ InstanceMethod<&FunctionArgsBenchmark::NoArgFunction>(
122
+ "noArgFunction"),
123
+ InstanceMethod<&FunctionArgsBenchmark::OneArgFunction>(
124
+ "oneArgFunction"),
125
+ InstanceMethod<&FunctionArgsBenchmark::TwoArgFunction>(
126
+ "twoArgFunction"),
127
+ InstanceMethod<
128
+ &FunctionArgsBenchmark::ThreeArgFunction>(
129
+ "threeArgFunction"),
130
+ InstanceMethod<&FunctionArgsBenchmark::FourArgFunction>(
131
+ "fourArgFunction"),
132
+ }),
133
+ napi_enumerable),
134
+ });
111
135
  }
136
+
112
137
  private:
113
- void NoArgFunction(const Napi::CallbackInfo& info) {
114
- (void) info;
115
- }
138
+ void NoArgFunction(const Napi::CallbackInfo& info) { (void)info; }
116
139
 
117
140
  void OneArgFunction(const Napi::CallbackInfo& info) {
118
- Napi::Value argv0 = info[0]; (void) argv0;
141
+ Napi::Value argv0 = info[0];
142
+ (void)argv0;
119
143
  }
120
144
 
121
145
  void TwoArgFunction(const Napi::CallbackInfo& info) {
122
- Napi::Value argv0 = info[0]; (void) argv0;
123
- Napi::Value argv1 = info[1]; (void) argv1;
146
+ Napi::Value argv0 = info[0];
147
+ (void)argv0;
148
+ Napi::Value argv1 = info[1];
149
+ (void)argv1;
124
150
  }
125
151
 
126
152
  void ThreeArgFunction(const Napi::CallbackInfo& info) {
127
- Napi::Value argv0 = info[0]; (void) argv0;
128
- Napi::Value argv1 = info[1]; (void) argv1;
129
- Napi::Value argv2 = info[2]; (void) argv2;
153
+ Napi::Value argv0 = info[0];
154
+ (void)argv0;
155
+ Napi::Value argv1 = info[1];
156
+ (void)argv1;
157
+ Napi::Value argv2 = info[2];
158
+ (void)argv2;
130
159
  }
131
160
 
132
161
  void FourArgFunction(const Napi::CallbackInfo& info) {
133
- Napi::Value argv0 = info[0]; (void) argv0;
134
- Napi::Value argv1 = info[1]; (void) argv1;
135
- Napi::Value argv2 = info[2]; (void) argv2;
136
- Napi::Value argv3 = info[3]; (void) argv3;
162
+ Napi::Value argv0 = info[0];
163
+ (void)argv0;
164
+ Napi::Value argv1 = info[1];
165
+ (void)argv1;
166
+ Napi::Value argv2 = info[2];
167
+ (void)argv2;
168
+ Napi::Value argv3 = info[3];
169
+ (void)argv3;
137
170
  }
138
171
  };
139
172
  #endif // NAPI_VERSION > 5
@@ -2,7 +2,7 @@ const path = require('path');
2
2
  const Benchmark = require('benchmark');
3
3
  const addonName = path.basename(__filename, '.js');
4
4
 
5
- [ addonName, addonName + '_noexcept' ]
5
+ [addonName, addonName + '_noexcept']
6
6
  .forEach((addonName) => {
7
7
  const rootAddon = require('bindings')({
8
8
  bindings: addonName,
@@ -20,7 +20,7 @@ const addonName = path.basename(__filename, '.js');
20
20
  implems.reduce((suite, implem) => {
21
21
  const fn = rootAddon[implem].noArgFunction;
22
22
  return suite.add(implem.padStart(maxNameLength, ' '), () => fn());
23
- }, new Benchmark.Suite)
23
+ }, new Benchmark.Suite())
24
24
  .on('cycle', (event) => console.log(String(event.target)))
25
25
  .run();
26
26
 
@@ -28,7 +28,7 @@ const addonName = path.basename(__filename, '.js');
28
28
  implems.reduce((suite, implem) => {
29
29
  const fn = rootAddon[implem].oneArgFunction;
30
30
  return suite.add(implem.padStart(maxNameLength, ' '), () => fn('x'));
31
- }, new Benchmark.Suite)
31
+ }, new Benchmark.Suite())
32
32
  .on('cycle', (event) => console.log(String(event.target)))
33
33
  .run();
34
34
 
@@ -36,7 +36,7 @@ const addonName = path.basename(__filename, '.js');
36
36
  implems.reduce((suite, implem) => {
37
37
  const fn = rootAddon[implem].twoArgFunction;
38
38
  return suite.add(implem.padStart(maxNameLength, ' '), () => fn('x', 12));
39
- }, new Benchmark.Suite)
39
+ }, new Benchmark.Suite())
40
40
  .on('cycle', (event) => console.log(String(event.target)))
41
41
  .run();
42
42
 
@@ -45,7 +45,7 @@ const addonName = path.basename(__filename, '.js');
45
45
  const fn = rootAddon[implem].threeArgFunction;
46
46
  return suite.add(implem.padStart(maxNameLength, ' '),
47
47
  () => fn('x', 12, true));
48
- }, new Benchmark.Suite)
48
+ }, new Benchmark.Suite())
49
49
  .on('cycle', (event) => console.log(String(event.target)))
50
50
  .run();
51
51
 
@@ -54,7 +54,7 @@ const addonName = path.basename(__filename, '.js');
54
54
  const fn = rootAddon[implem].fourArgFunction;
55
55
  return suite.add(implem.padStart(maxNameLength, ' '),
56
56
  () => fn('x', 12, true, anObject));
57
- }, new Benchmark.Suite)
57
+ }, new Benchmark.Suite())
58
58
  .on('cycle', (event) => console.log(String(event.target)))
59
59
  .run();
60
60
  });
@@ -6,7 +6,7 @@ const path = require('path');
6
6
 
7
7
  let benchmarks = [];
8
8
 
9
- if (!!process.env.npm_config_benchmarks) {
9
+ if (process.env.npm_config_benchmarks) {
10
10
  benchmarks = process.env.npm_config_benchmarks
11
11
  .split(';')
12
12
  .map((item) => (item + '.js'));