koffi 2.16.0-beta.2 → 2.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (425) hide show
  1. package/CHANGELOG.md +59 -0
  2. package/build/koffi/darwin_arm64/koffi.node +0 -0
  3. package/build/koffi/darwin_x64/koffi.node +0 -0
  4. package/build/koffi/freebsd_arm64/koffi.node +0 -0
  5. package/build/koffi/freebsd_ia32/koffi.node +0 -0
  6. package/build/koffi/freebsd_x64/koffi.node +0 -0
  7. package/build/koffi/linux_arm64/koffi.node +0 -0
  8. package/build/koffi/linux_armhf/koffi.node +0 -0
  9. package/build/koffi/linux_ia32/koffi.node +0 -0
  10. package/build/koffi/linux_loong64/koffi.node +0 -0
  11. package/build/koffi/linux_riscv64d/koffi.node +0 -0
  12. package/build/koffi/linux_x64/koffi.node +0 -0
  13. package/build/koffi/musl_arm64/koffi.node +0 -0
  14. package/build/koffi/musl_x64/koffi.node +0 -0
  15. package/build/koffi/openbsd_ia32/koffi.node +0 -0
  16. package/build/koffi/openbsd_x64/koffi.node +0 -0
  17. package/build/koffi/win32_arm64/koffi.exp +0 -0
  18. package/build/koffi/win32_arm64/koffi.lib +0 -0
  19. package/build/koffi/win32_arm64/koffi.node +0 -0
  20. package/build/koffi/win32_ia32/koffi.exp +0 -0
  21. package/build/koffi/win32_ia32/koffi.lib +0 -0
  22. package/build/koffi/win32_ia32/koffi.node +0 -0
  23. package/build/koffi/win32_x64/koffi.exp +0 -0
  24. package/build/koffi/win32_x64/koffi.lib +0 -0
  25. package/build/koffi/win32_x64/koffi.node +0 -0
  26. package/index.d.ts +9 -11
  27. package/index.js +6 -9
  28. package/indirect.js +6 -9
  29. package/lib/native/base/base.cc +1 -6
  30. package/package.json +3 -3
  31. package/src/cnoke/assets/FindCNoke.cmake +27 -16
  32. package/src/cnoke/assets/toolchains.json +126 -0
  33. package/src/cnoke/cnoke.js +27 -33
  34. package/src/cnoke/src/builder.js +124 -63
  35. package/src/cnoke/src/tools.js +1 -5
  36. package/src/koffi/CMakeLists.txt +32 -21
  37. package/src/koffi/src/{abi/arm32.cc → abi_arm32.cc} +235 -238
  38. package/src/koffi/src/{abi/arm32_asm.S → abi_arm32_asm.S} +19 -15
  39. package/src/koffi/src/{abi/arm64.cc → abi_arm64.cc} +253 -274
  40. package/src/koffi/src/{abi/arm64_asm.S → abi_arm64_asm.S} +16 -10
  41. package/src/koffi/src/{abi/arm64_asm.asm → abi_arm64_asm.asm} +17 -10
  42. package/src/koffi/src/{abi/loong64_asm.S → abi_loong64_asm.S} +16 -10
  43. package/src/koffi/src/{abi/riscv64.cc → abi_riscv64.cc} +233 -236
  44. package/src/koffi/src/{abi/riscv64_asm.S → abi_riscv64_asm.S} +16 -10
  45. package/src/koffi/src/{abi/x64_sysv.cc → abi_x64_sysv.cc} +208 -212
  46. package/src/koffi/src/{abi/x64_sysv_asm.S → abi_x64_sysv_asm.S} +17 -10
  47. package/src/koffi/src/{abi/x64_win.cc → abi_x64_win.cc} +175 -206
  48. package/src/koffi/src/{abi/x64_win_asm.S → abi_x64_win_asm.S} +49 -27
  49. package/src/koffi/src/{abi/x64_win_asm.asm → abi_x64_win_asm.asm} +54 -27
  50. package/src/koffi/src/{abi/x86.cc → abi_x86.cc} +187 -226
  51. package/src/koffi/src/{abi/x86_asm.S → abi_x86_asm.S} +36 -21
  52. package/src/koffi/src/{abi/x86_asm.asm → abi_x86_asm.asm} +31 -16
  53. package/src/koffi/src/call.cc +473 -287
  54. package/src/koffi/src/call.hh +15 -18
  55. package/src/koffi/src/ffi.cc +167 -183
  56. package/src/koffi/src/ffi.hh +59 -13
  57. package/src/koffi/src/init.js +1 -0
  58. package/src/koffi/src/util.cc +113 -159
  59. package/src/koffi/src/util.hh +23 -74
  60. package/src/koffi/src/win32.cc +13 -0
  61. package/src/koffi/src/win32.hh +7 -0
  62. package/src/koffi/tools/write_trampolines.js +77 -0
  63. package/doc/README.md +0 -27
  64. package/doc/assets.ini +0 -24
  65. package/doc/build.sh +0 -9
  66. package/doc/develop.sh +0 -15
  67. package/doc/pages/404.md +0 -17
  68. package/doc/pages.ini +0 -86
  69. package/doc/static/highlight.js +0 -8
  70. package/doc/static/koffi.css +0 -11
  71. package/doc/static/koffi.png +0 -0
  72. package/doc/static/logo.webp +0 -0
  73. package/doc/static/perf_linux.png +0 -0
  74. package/doc/static/perf_windows.png +0 -0
  75. package/doc/static/print.css +0 -10
  76. package/doc/templates/code.html +0 -48
  77. package/doc/templates/page.html +0 -47
  78. package/src/koffi/cmake/raylib.cmake +0 -85
  79. package/src/koffi/cmake/sqlite3.cmake +0 -9
  80. package/src/koffi/examples/electron-builder/README.md +0 -11
  81. package/src/koffi/examples/electron-builder/package.json +0 -21
  82. package/src/koffi/examples/electron-builder/src/app.js +0 -20
  83. package/src/koffi/examples/electron-builder/src/index.html +0 -143
  84. package/src/koffi/examples/electron-builder/src/preload.js +0 -5
  85. package/src/koffi/examples/electron-forge/README.md +0 -25
  86. package/src/koffi/examples/electron-forge/forge.config.js +0 -63
  87. package/src/koffi/examples/electron-forge/package.json +0 -39
  88. package/src/koffi/examples/electron-forge/src/index.css +0 -7
  89. package/src/koffi/examples/electron-forge/src/index.html +0 -143
  90. package/src/koffi/examples/electron-forge/src/main.js +0 -52
  91. package/src/koffi/examples/electron-forge/src/preload.js +0 -5
  92. package/src/koffi/examples/electron-forge/src/renderer.js +0 -31
  93. package/src/koffi/examples/electron-forge/webpack.main.config.js +0 -11
  94. package/src/koffi/examples/electron-forge/webpack.renderer.config.js +0 -13
  95. package/src/koffi/examples/electron-forge/webpack.rules.js +0 -35
  96. package/src/koffi/examples/node-esbuild/README.md +0 -19
  97. package/src/koffi/examples/node-esbuild/index.js +0 -2
  98. package/src/koffi/examples/node-esbuild/package.json +0 -16
  99. package/src/koffi/examples/nwjs/README.md +0 -20
  100. package/src/koffi/examples/nwjs/package.json +0 -11
  101. package/src/koffi/examples/nwjs/src/index.html +0 -145
  102. package/src/koffi/examples/nwjs/src/package.json +0 -10
  103. package/src/koffi/examples/yao-pkg/README.md +0 -17
  104. package/src/koffi/examples/yao-pkg/index.js +0 -2
  105. package/src/koffi/examples/yao-pkg/package.json +0 -22
  106. package/src/koffi/src/primitives.inc +0 -39
  107. package/src/koffi/src/trampolines/armasm.inc +0 -32771
  108. package/src/koffi/src/trampolines/gnu.inc +0 -24577
  109. package/src/koffi/src/trampolines/masm32.inc +0 -32769
  110. package/src/koffi/src/trampolines/masm64.inc +0 -32769
  111. package/src/koffi/src/trampolines/prototypes.inc +0 -16388
  112. package/vendor/node-addon-api/CHANGELOG.md +0 -1272
  113. package/vendor/node-addon-api/CODE_OF_CONDUCT.md +0 -4
  114. package/vendor/node-addon-api/CONTRIBUTING.md +0 -203
  115. package/vendor/node-addon-api/appveyor.yml +0 -37
  116. package/vendor/node-addon-api/benchmark/README.md +0 -47
  117. package/vendor/node-addon-api/benchmark/binding.gyp +0 -25
  118. package/vendor/node-addon-api/benchmark/function_args.cc +0 -250
  119. package/vendor/node-addon-api/benchmark/function_args.js +0 -60
  120. package/vendor/node-addon-api/benchmark/index.js +0 -34
  121. package/vendor/node-addon-api/benchmark/property_descriptor.cc +0 -84
  122. package/vendor/node-addon-api/benchmark/property_descriptor.js +0 -38
  123. package/vendor/node-addon-api/common.gypi +0 -21
  124. package/vendor/node-addon-api/doc/README.md +0 -145
  125. package/vendor/node-addon-api/doc/addon.md +0 -163
  126. package/vendor/node-addon-api/doc/array.md +0 -81
  127. package/vendor/node-addon-api/doc/array_buffer.md +0 -165
  128. package/vendor/node-addon-api/doc/async_context.md +0 -86
  129. package/vendor/node-addon-api/doc/async_operations.md +0 -31
  130. package/vendor/node-addon-api/doc/async_worker.md +0 -428
  131. package/vendor/node-addon-api/doc/async_worker_variants.md +0 -578
  132. package/vendor/node-addon-api/doc/basic_env.md +0 -200
  133. package/vendor/node-addon-api/doc/bigint.md +0 -97
  134. package/vendor/node-addon-api/doc/boolean.md +0 -68
  135. package/vendor/node-addon-api/doc/buffer.md +0 -245
  136. package/vendor/node-addon-api/doc/callback_scope.md +0 -54
  137. package/vendor/node-addon-api/doc/callbackinfo.md +0 -97
  138. package/vendor/node-addon-api/doc/checker-tool.md +0 -32
  139. package/vendor/node-addon-api/doc/class_property_descriptor.md +0 -123
  140. package/vendor/node-addon-api/doc/cmake-js.md +0 -87
  141. package/vendor/node-addon-api/doc/contributing/creating_a_release.md +0 -95
  142. package/vendor/node-addon-api/doc/conversion-tool.md +0 -28
  143. package/vendor/node-addon-api/doc/dataview.md +0 -248
  144. package/vendor/node-addon-api/doc/date.md +0 -68
  145. package/vendor/node-addon-api/doc/env.md +0 -87
  146. package/vendor/node-addon-api/doc/error.md +0 -120
  147. package/vendor/node-addon-api/doc/error_handling.md +0 -266
  148. package/vendor/node-addon-api/doc/escapable_handle_scope.md +0 -80
  149. package/vendor/node-addon-api/doc/external.md +0 -79
  150. package/vendor/node-addon-api/doc/external_buffer.md +0 -18
  151. package/vendor/node-addon-api/doc/finalization.md +0 -153
  152. package/vendor/node-addon-api/doc/function.md +0 -402
  153. package/vendor/node-addon-api/doc/function_reference.md +0 -238
  154. package/vendor/node-addon-api/doc/generator.md +0 -13
  155. package/vendor/node-addon-api/doc/handle_scope.md +0 -77
  156. package/vendor/node-addon-api/doc/hierarchy.md +0 -95
  157. package/vendor/node-addon-api/doc/instance_wrap.md +0 -408
  158. package/vendor/node-addon-api/doc/maybe.md +0 -76
  159. package/vendor/node-addon-api/doc/memory_management.md +0 -27
  160. package/vendor/node-addon-api/doc/name.md +0 -29
  161. package/vendor/node-addon-api/doc/node-gyp.md +0 -82
  162. package/vendor/node-addon-api/doc/number.md +0 -163
  163. package/vendor/node-addon-api/doc/object.md +0 -411
  164. package/vendor/node-addon-api/doc/object_lifetime_management.md +0 -83
  165. package/vendor/node-addon-api/doc/object_reference.md +0 -117
  166. package/vendor/node-addon-api/doc/object_wrap.md +0 -604
  167. package/vendor/node-addon-api/doc/prebuild_tools.md +0 -16
  168. package/vendor/node-addon-api/doc/promises.md +0 -130
  169. package/vendor/node-addon-api/doc/property_descriptor.md +0 -286
  170. package/vendor/node-addon-api/doc/propertylvalue.md +0 -50
  171. package/vendor/node-addon-api/doc/range_error.md +0 -59
  172. package/vendor/node-addon-api/doc/reference.md +0 -113
  173. package/vendor/node-addon-api/doc/setup.md +0 -115
  174. package/vendor/node-addon-api/doc/string.md +0 -93
  175. package/vendor/node-addon-api/doc/symbol.md +0 -61
  176. package/vendor/node-addon-api/doc/syntax_error.md +0 -66
  177. package/vendor/node-addon-api/doc/threadsafe.md +0 -121
  178. package/vendor/node-addon-api/doc/threadsafe_function.md +0 -290
  179. package/vendor/node-addon-api/doc/type_error.md +0 -59
  180. package/vendor/node-addon-api/doc/type_taggable.md +0 -40
  181. package/vendor/node-addon-api/doc/typed_array.md +0 -78
  182. package/vendor/node-addon-api/doc/typed_array_of.md +0 -137
  183. package/vendor/node-addon-api/doc/typed_threadsafe_function.md +0 -306
  184. package/vendor/node-addon-api/doc/value.md +0 -368
  185. package/vendor/node-addon-api/doc/version_management.md +0 -43
  186. package/vendor/node-addon-api/eslint.config.js +0 -5
  187. package/vendor/node-addon-api/except.gypi +0 -25
  188. package/vendor/node-addon-api/index.js +0 -14
  189. package/vendor/node-addon-api/node_addon_api.gyp +0 -42
  190. package/vendor/node-addon-api/node_api.gyp +0 -9
  191. package/vendor/node-addon-api/noexcept.gypi +0 -26
  192. package/vendor/node-addon-api/nothing.c +0 -0
  193. package/vendor/node-addon-api/package-support.json +0 -21
  194. package/vendor/node-addon-api/package.json +0 -480
  195. package/vendor/node-addon-api/release-please-config.json +0 -15
  196. package/vendor/node-addon-api/test/README.md +0 -91
  197. package/vendor/node-addon-api/test/addon.cc +0 -44
  198. package/vendor/node-addon-api/test/addon.js +0 -7
  199. package/vendor/node-addon-api/test/addon_build/index.js +0 -49
  200. package/vendor/node-addon-api/test/addon_build/tpl/addon.cc +0 -18
  201. package/vendor/node-addon-api/test/addon_build/tpl/binding.gyp +0 -63
  202. package/vendor/node-addon-api/test/addon_build/tpl/index.js +0 -9
  203. package/vendor/node-addon-api/test/addon_build/tpl/package.json +0 -11
  204. package/vendor/node-addon-api/test/addon_data.cc +0 -98
  205. package/vendor/node-addon-api/test/addon_data.js +0 -24
  206. package/vendor/node-addon-api/test/array_buffer.cc +0 -243
  207. package/vendor/node-addon-api/test/array_buffer.js +0 -70
  208. package/vendor/node-addon-api/test/async_context.cc +0 -36
  209. package/vendor/node-addon-api/test/async_context.js +0 -122
  210. package/vendor/node-addon-api/test/async_progress_queue_worker.cc +0 -248
  211. package/vendor/node-addon-api/test/async_progress_queue_worker.js +0 -180
  212. package/vendor/node-addon-api/test/async_progress_worker.cc +0 -357
  213. package/vendor/node-addon-api/test/async_progress_worker.js +0 -200
  214. package/vendor/node-addon-api/test/async_worker.cc +0 -341
  215. package/vendor/node-addon-api/test/async_worker.js +0 -264
  216. package/vendor/node-addon-api/test/async_worker_nocallback.js +0 -19
  217. package/vendor/node-addon-api/test/async_worker_persistent.cc +0 -63
  218. package/vendor/node-addon-api/test/async_worker_persistent.js +0 -24
  219. package/vendor/node-addon-api/test/basic_types/array.cc +0 -40
  220. package/vendor/node-addon-api/test/basic_types/array.js +0 -34
  221. package/vendor/node-addon-api/test/basic_types/boolean.cc +0 -40
  222. package/vendor/node-addon-api/test/basic_types/boolean.js +0 -34
  223. package/vendor/node-addon-api/test/basic_types/number.cc +0 -105
  224. package/vendor/node-addon-api/test/basic_types/number.js +0 -115
  225. package/vendor/node-addon-api/test/basic_types/value.cc +0 -177
  226. package/vendor/node-addon-api/test/basic_types/value.js +0 -173
  227. package/vendor/node-addon-api/test/bigint.cc +0 -91
  228. package/vendor/node-addon-api/test/bigint.js +0 -53
  229. package/vendor/node-addon-api/test/binding-swallowexcept.cc +0 -12
  230. package/vendor/node-addon-api/test/binding.cc +0 -200
  231. package/vendor/node-addon-api/test/binding.gyp +0 -160
  232. package/vendor/node-addon-api/test/buffer.cc +0 -185
  233. package/vendor/node-addon-api/test/buffer.h +0 -26
  234. package/vendor/node-addon-api/test/buffer.js +0 -150
  235. package/vendor/node-addon-api/test/buffer_new_or_copy-inl.h +0 -68
  236. package/vendor/node-addon-api/test/buffer_no_external.cc +0 -24
  237. package/vendor/node-addon-api/test/callbackInfo.cc +0 -27
  238. package/vendor/node-addon-api/test/callbackInfo.js +0 -9
  239. package/vendor/node-addon-api/test/callbackscope.cc +0 -39
  240. package/vendor/node-addon-api/test/callbackscope.js +0 -49
  241. package/vendor/node-addon-api/test/child_processes/addon.js +0 -11
  242. package/vendor/node-addon-api/test/child_processes/addon_data.js +0 -24
  243. package/vendor/node-addon-api/test/child_processes/objectwrap_function.js +0 -22
  244. package/vendor/node-addon-api/test/child_processes/threadsafe_function_exception.js +0 -33
  245. package/vendor/node-addon-api/test/child_processes/typed_threadsafe_function_exception.js +0 -19
  246. package/vendor/node-addon-api/test/common/index.js +0 -246
  247. package/vendor/node-addon-api/test/common/test_helper.h +0 -71
  248. package/vendor/node-addon-api/test/dataview/dataview.cc +0 -48
  249. package/vendor/node-addon-api/test/dataview/dataview.js +0 -35
  250. package/vendor/node-addon-api/test/dataview/dataview_read_write.cc +0 -115
  251. package/vendor/node-addon-api/test/dataview/dataview_read_write.js +0 -92
  252. package/vendor/node-addon-api/test/date.cc +0 -45
  253. package/vendor/node-addon-api/test/date.js +0 -18
  254. package/vendor/node-addon-api/test/env_cleanup.cc +0 -100
  255. package/vendor/node-addon-api/test/env_cleanup.js +0 -55
  256. package/vendor/node-addon-api/test/env_misc.cc +0 -25
  257. package/vendor/node-addon-api/test/env_misc.js +0 -12
  258. package/vendor/node-addon-api/test/error.cc +0 -436
  259. package/vendor/node-addon-api/test/error.js +0 -111
  260. package/vendor/node-addon-api/test/error_handling_for_primitives.cc +0 -13
  261. package/vendor/node-addon-api/test/error_handling_for_primitives.js +0 -29
  262. package/vendor/node-addon-api/test/error_terminating_environment.js +0 -99
  263. package/vendor/node-addon-api/test/except_all.cc +0 -22
  264. package/vendor/node-addon-api/test/except_all.js +0 -14
  265. package/vendor/node-addon-api/test/exports.js +0 -19
  266. package/vendor/node-addon-api/test/external.cc +0 -85
  267. package/vendor/node-addon-api/test/external.js +0 -85
  268. package/vendor/node-addon-api/test/finalizer_order.cc +0 -152
  269. package/vendor/node-addon-api/test/finalizer_order.js +0 -98
  270. package/vendor/node-addon-api/test/function.cc +0 -338
  271. package/vendor/node-addon-api/test/function.js +0 -137
  272. package/vendor/node-addon-api/test/function_reference.cc +0 -204
  273. package/vendor/node-addon-api/test/function_reference.js +0 -157
  274. package/vendor/node-addon-api/test/globalObject/global_object.cc +0 -61
  275. package/vendor/node-addon-api/test/globalObject/global_object_delete_property.cc +0 -31
  276. package/vendor/node-addon-api/test/globalObject/global_object_delete_property.js +0 -58
  277. package/vendor/node-addon-api/test/globalObject/global_object_get_property.cc +0 -40
  278. package/vendor/node-addon-api/test/globalObject/global_object_get_property.js +0 -56
  279. package/vendor/node-addon-api/test/globalObject/global_object_has_own_property.cc +0 -28
  280. package/vendor/node-addon-api/test/globalObject/global_object_has_own_property.js +0 -46
  281. package/vendor/node-addon-api/test/globalObject/global_object_set_property.cc +0 -31
  282. package/vendor/node-addon-api/test/globalObject/global_object_set_property.js +0 -56
  283. package/vendor/node-addon-api/test/handlescope.cc +0 -86
  284. package/vendor/node-addon-api/test/handlescope.js +0 -16
  285. package/vendor/node-addon-api/test/index.js +0 -160
  286. package/vendor/node-addon-api/test/maybe/check.cc +0 -69
  287. package/vendor/node-addon-api/test/maybe/index.js +0 -50
  288. package/vendor/node-addon-api/test/memory_management.cc +0 -18
  289. package/vendor/node-addon-api/test/memory_management.js +0 -9
  290. package/vendor/node-addon-api/test/movable_callbacks.cc +0 -23
  291. package/vendor/node-addon-api/test/movable_callbacks.js +0 -21
  292. package/vendor/node-addon-api/test/name.cc +0 -110
  293. package/vendor/node-addon-api/test/name.js +0 -59
  294. package/vendor/node-addon-api/test/napi_child.js +0 -14
  295. package/vendor/node-addon-api/test/object/delete_property.cc +0 -38
  296. package/vendor/node-addon-api/test/object/delete_property.js +0 -41
  297. package/vendor/node-addon-api/test/object/finalizer.cc +0 -30
  298. package/vendor/node-addon-api/test/object/finalizer.js +0 -28
  299. package/vendor/node-addon-api/test/object/get_property.cc +0 -34
  300. package/vendor/node-addon-api/test/object/get_property.js +0 -40
  301. package/vendor/node-addon-api/test/object/has_own_property.cc +0 -34
  302. package/vendor/node-addon-api/test/object/has_own_property.js +0 -34
  303. package/vendor/node-addon-api/test/object/has_property.cc +0 -38
  304. package/vendor/node-addon-api/test/object/has_property.js +0 -37
  305. package/vendor/node-addon-api/test/object/object.cc +0 -430
  306. package/vendor/node-addon-api/test/object/object.js +0 -218
  307. package/vendor/node-addon-api/test/object/object_deprecated.cc +0 -70
  308. package/vendor/node-addon-api/test/object/object_deprecated.js +0 -42
  309. package/vendor/node-addon-api/test/object/object_freeze_seal.cc +0 -25
  310. package/vendor/node-addon-api/test/object/object_freeze_seal.js +0 -61
  311. package/vendor/node-addon-api/test/object/set_property.cc +0 -45
  312. package/vendor/node-addon-api/test/object/set_property.js +0 -30
  313. package/vendor/node-addon-api/test/object/subscript_operator.cc +0 -58
  314. package/vendor/node-addon-api/test/object/subscript_operator.js +0 -17
  315. package/vendor/node-addon-api/test/object_reference.cc +0 -417
  316. package/vendor/node-addon-api/test/object_reference.js +0 -262
  317. package/vendor/node-addon-api/test/objectwrap.cc +0 -295
  318. package/vendor/node-addon-api/test/objectwrap.js +0 -309
  319. package/vendor/node-addon-api/test/objectwrap_constructor_exception.cc +0 -26
  320. package/vendor/node-addon-api/test/objectwrap_constructor_exception.js +0 -18
  321. package/vendor/node-addon-api/test/objectwrap_function.cc +0 -43
  322. package/vendor/node-addon-api/test/objectwrap_function.js +0 -6
  323. package/vendor/node-addon-api/test/objectwrap_multiple_inheritance.cc +0 -30
  324. package/vendor/node-addon-api/test/objectwrap_multiple_inheritance.js +0 -13
  325. package/vendor/node-addon-api/test/objectwrap_removewrap.cc +0 -45
  326. package/vendor/node-addon-api/test/objectwrap_removewrap.js +0 -32
  327. package/vendor/node-addon-api/test/objectwrap_worker_thread.js +0 -20
  328. package/vendor/node-addon-api/test/promise.cc +0 -111
  329. package/vendor/node-addon-api/test/promise.js +0 -43
  330. package/vendor/node-addon-api/test/reference.cc +0 -78
  331. package/vendor/node-addon-api/test/reference.js +0 -20
  332. package/vendor/node-addon-api/test/require_basic_finalizers/index.js +0 -38
  333. package/vendor/node-addon-api/test/require_basic_finalizers/tpl/addon.cc +0 -12
  334. package/vendor/node-addon-api/test/require_basic_finalizers/tpl/binding.gyp +0 -48
  335. package/vendor/node-addon-api/test/require_basic_finalizers/tpl/index.js +0 -3
  336. package/vendor/node-addon-api/test/require_basic_finalizers/tpl/package.json +0 -11
  337. package/vendor/node-addon-api/test/run_script.cc +0 -56
  338. package/vendor/node-addon-api/test/run_script.js +0 -45
  339. package/vendor/node-addon-api/test/symbol.cc +0 -79
  340. package/vendor/node-addon-api/test/symbol.js +0 -66
  341. package/vendor/node-addon-api/test/testUtil.js +0 -54
  342. package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function.cc +0 -230
  343. package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function.js +0 -225
  344. package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function_ctx.cc +0 -155
  345. package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function_ctx.js +0 -13
  346. package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function_exception.cc +0 -50
  347. package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function_exception.js +0 -20
  348. package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function_existing_tsfn.cc +0 -125
  349. package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function_existing_tsfn.js +0 -14
  350. package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function_ptr.cc +0 -27
  351. package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function_ptr.js +0 -7
  352. package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function_sum.cc +0 -240
  353. package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function_sum.js +0 -59
  354. package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function_unref.cc +0 -55
  355. package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function_unref.js +0 -98
  356. package/vendor/node-addon-api/test/thunking_manual.cc +0 -127
  357. package/vendor/node-addon-api/test/thunking_manual.js +0 -16
  358. package/vendor/node-addon-api/test/type_taggable.cc +0 -66
  359. package/vendor/node-addon-api/test/type_taggable.js +0 -59
  360. package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function.cc +0 -215
  361. package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function.js +0 -188
  362. package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function_ctx.cc +0 -120
  363. package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function_ctx.js +0 -14
  364. package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function_exception.cc +0 -39
  365. package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function_exception.js +0 -13
  366. package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function_existing_tsfn.cc +0 -127
  367. package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function_existing_tsfn.js +0 -14
  368. package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function_ptr.cc +0 -32
  369. package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function_ptr.js +0 -8
  370. package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function_sum.cc +0 -237
  371. package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function_sum.js +0 -59
  372. package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function_unref.cc +0 -67
  373. package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function_unref.js +0 -98
  374. package/vendor/node-addon-api/test/typedarray-bigint.js +0 -58
  375. package/vendor/node-addon-api/test/typedarray.cc +0 -413
  376. package/vendor/node-addon-api/test/typedarray.js +0 -103
  377. package/vendor/node-addon-api/test/value_type_cast.cc +0 -60
  378. package/vendor/node-addon-api/test/value_type_cast.js +0 -106
  379. package/vendor/node-addon-api/test/version_management.cc +0 -28
  380. package/vendor/node-addon-api/test/version_management.js +0 -29
  381. package/vendor/node-addon-api/tools/README.md +0 -73
  382. package/vendor/node-addon-api/tools/check-napi.js +0 -99
  383. package/vendor/node-addon-api/tools/clang-format.js +0 -71
  384. package/vendor/node-addon-api/tools/conversion.js +0 -301
  385. package/vendor/node-addon-api/unit-test/README.md +0 -28
  386. package/vendor/node-addon-api/unit-test/binding-file-template.js +0 -39
  387. package/vendor/node-addon-api/unit-test/binding.gyp +0 -72
  388. package/vendor/node-addon-api/unit-test/exceptions.js +0 -32
  389. package/vendor/node-addon-api/unit-test/generate-binding-cc.js +0 -61
  390. package/vendor/node-addon-api/unit-test/injectTestParams.js +0 -101
  391. package/vendor/node-addon-api/unit-test/listOfTestModules.js +0 -88
  392. package/vendor/node-addon-api/unit-test/matchModules.js +0 -65
  393. package/vendor/node-addon-api/unit-test/setup.js +0 -13
  394. package/vendor/node-addon-api/unit-test/spawnTask.js +0 -26
  395. package/vendor/node-addon-api/unit-test/test.js +0 -30
  396. package/vendor/node-api-headers/CHANGELOG.md +0 -130
  397. package/vendor/node-api-headers/CODE_OF_CONDUCT.md +0 -4
  398. package/vendor/node-api-headers/CONTRIBUTING.md +0 -32
  399. package/vendor/node-api-headers/CREATING_A_RELEASE.md +0 -68
  400. package/vendor/node-api-headers/index.js +0 -17
  401. package/vendor/node-api-headers/lib/clang-utils.js +0 -50
  402. package/vendor/node-api-headers/lib/parse-utils.js +0 -92
  403. package/vendor/node-api-headers/package.json +0 -59
  404. package/vendor/node-api-headers/release-please-config.json +0 -12
  405. package/vendor/node-api-headers/scripts/update-headers.js +0 -246
  406. package/vendor/node-api-headers/scripts/write-symbols.js +0 -154
  407. package/vendor/node-api-headers/scripts/write-win32-def.js +0 -52
  408. package/vendor/node-api-headers/symbols.js +0 -257
  409. package/vendor/node-api-headers/test/parse-utils.js +0 -21
  410. /package/doc/{pages/benchmarks.md → benchmarks.md} +0 -0
  411. /package/doc/{pages/callbacks.md → callbacks.md} +0 -0
  412. /package/doc/{pages/contribute.md → contribute.md} +0 -0
  413. /package/doc/{pages/functions.md → functions.md} +0 -0
  414. /package/doc/{pages/index.md → index.md} +0 -0
  415. /package/doc/{pages/input.md → input.md} +0 -0
  416. /package/doc/{pages/migration.md → migration.md} +0 -0
  417. /package/doc/{pages/misc.md → misc.md} +0 -0
  418. /package/doc/{pages/output.md → output.md} +0 -0
  419. /package/doc/{pages/packaging.md → packaging.md} +0 -0
  420. /package/doc/{pages/platforms.md → platforms.md} +0 -0
  421. /package/doc/{pages/pointers.md → pointers.md} +0 -0
  422. /package/doc/{pages/start.md → start.md} +0 -0
  423. /package/doc/{pages/unions.md → unions.md} +0 -0
  424. /package/doc/{pages/variables.md → variables.md} +0 -0
  425. /package/src/koffi/src/{abi/loong64.cc → abi_loong64.cc} +0 -0
@@ -1,306 +0,0 @@
1
- # TypedThreadSafeFunction
2
-
3
- The `Napi::TypedThreadSafeFunction` type provides APIs for threads to
4
- communicate with the addon's main thread to invoke JavaScript functions on their
5
- behalf. The type is a three-argument templated class, each argument representing
6
- the type of:
7
- - `ContextType = std::nullptr_t`: The thread-safe function's context. By
8
- default, a TSFN has no context.
9
- - `DataType = void*`: The data to use in the native callback. By default, a TSFN
10
- can accept any data type.
11
- - `Callback = void(*)(Napi::Env, Napi::Function jsCallback, ContextType*,
12
- DataType*)`: The callback to run for each item added to the queue. If no
13
- `Callback` is given, the API will call the function `jsCallback` with no
14
- arguments.
15
-
16
- Documentation can be found for an [overview of the API](threadsafe.md), as well
17
- as [differences between the two thread-safe function
18
- APIs](threadsafe.md#implementation-differences).
19
-
20
- ## Methods
21
-
22
- ### Constructor
23
-
24
- Creates a new empty instance of `Napi::TypedThreadSafeFunction`.
25
-
26
- ```cpp
27
- Napi::Function::TypedThreadSafeFunction<ContextType, DataType, Callback>::TypedThreadSafeFunction();
28
- ```
29
-
30
- ### Constructor
31
-
32
- Creates a new instance of the `Napi::TypedThreadSafeFunction` object.
33
-
34
- ```cpp
35
- Napi::TypedThreadSafeFunction<ContextType, DataType, Callback>::TypedThreadSafeFunction(napi_threadsafe_function tsfn);
36
- ```
37
-
38
- - `tsfn`: The `napi_threadsafe_function` which is a handle for an existing
39
- thread-safe function.
40
-
41
- Returns a non-empty `Napi::TypedThreadSafeFunction` instance. To ensure the API
42
- statically handles the correct return type for `GetContext()` and
43
- `[Non]BlockingCall()`, pass the proper template arguments to
44
- `Napi::TypedThreadSafeFunction`.
45
-
46
- ### New
47
-
48
- Creates a new instance of the `Napi::TypedThreadSafeFunction` object. The `New`
49
- function has several overloads for the various optional parameters: skip the
50
- optional parameter for that specific overload.
51
-
52
- ```cpp
53
- New(napi_env env,
54
- CallbackType callback,
55
- const Object& resource,
56
- ResourceString resourceName,
57
- size_t maxQueueSize,
58
- size_t initialThreadCount,
59
- ContextType* context,
60
- Finalizer finalizeCallback,
61
- FinalizerDataType* data = nullptr);
62
- ```
63
-
64
- - `env`: The `napi_env` environment in which to construct the
65
- `Napi::ThreadSafeFunction` object.
66
- - `[optional] callback`: The `Function` to call from another thread.
67
- - `[optional] resource`: An object associated with the async work that will be
68
- passed to possible async_hooks init hooks.
69
- - `resourceName`: A JavaScript string to provide an identifier for the kind of
70
- resource that is being provided for diagnostic information exposed by the
71
- async_hooks API.
72
- - `maxQueueSize`: Maximum size of the queue. `0` for no limit.
73
- - `initialThreadCount`: The initial number of threads, including the main
74
- thread, which will be making use of this function.
75
- - `[optional] context`: Data to attach to the resulting `ThreadSafeFunction`. It
76
- can be retrieved via `GetContext()`.
77
- - `[optional] finalizeCallback`: Function to call when the
78
- `TypedThreadSafeFunction` is being destroyed. This callback will be invoked
79
- on the main thread when the thread-safe function is about to be destroyed. It
80
- receives the context and the finalize data given during construction (if
81
- given), and provides an opportunity for cleaning up after the threads e.g. by
82
- calling `uv_thread_join()`. It is important that, aside from the main loop
83
- thread, there be no threads left using the thread-safe function after the
84
- finalize callback completes. Must implement `void operator()(Env env,
85
- FinalizerDataType* data, ContextType* hint)`.
86
- - `[optional] data`: Data to be passed to `finalizeCallback`.
87
-
88
- Returns a non-empty `Napi::TypedThreadSafeFunction` instance.
89
-
90
- Depending on the targeted `NAPI_VERSION`, the API has different implementations
91
- for `CallbackType callback`.
92
-
93
- When targeting version 4, `callback` may be:
94
- - of type `const Function&`
95
- - not provided as a parameter, in which case the API creates a new no-op
96
- `Function`
97
-
98
- When targeting version 5+, `callback` may be:
99
- - of type `const Function&`
100
- - of type `std::nullptr_t`
101
- - not provided as a parameter, in which case the API passes `std::nullptr`
102
-
103
- ### Acquire
104
-
105
- Adds a thread to this thread-safe function object, indicating that a new thread
106
- will start making use of the thread-safe function.
107
-
108
- ```cpp
109
- napi_status Napi::TypedThreadSafeFunction<ContextType, DataType, Callback>::Acquire()
110
- ```
111
-
112
- Returns one of:
113
- - `napi_ok`: The thread has successfully acquired the thread-safe function for
114
- its use.
115
- - `napi_closing`: The thread-safe function has been marked as closing via a
116
- previous call to `Abort()`.
117
-
118
- ### Release
119
-
120
- Indicates that an existing thread will stop making use of the thread-safe
121
- function. A thread should call this API when it stops making use of this
122
- thread-safe function. Using any thread-safe APIs after having called this API
123
- has undefined results in the current thread, as the thread-safe function may
124
- have been destroyed.
125
-
126
- ```cpp
127
- napi_status Napi::TypedThreadSafeFunction<ContextType, DataType, Callback>::Release() const
128
- ```
129
-
130
- Returns one of:
131
- - `napi_ok`: The thread-safe function has been successfully released.
132
- - `napi_invalid_arg`: The thread-safe function's thread-count is zero.
133
- - `napi_generic_failure`: A generic error occurred when attempting to release the
134
- thread-safe function.
135
-
136
- ### Abort
137
-
138
- "Aborts" the thread-safe function. This will cause all subsequent APIs
139
- associated with the thread-safe function except `Release()` to return
140
- `napi_closing` even before its reference count reaches zero. In particular,
141
- `BlockingCall` and `NonBlockingCall()` will return `napi_closing`, thus
142
- informing the threads that it is no longer possible to make asynchronous calls
143
- to the thread-safe function. This can be used as a criterion for terminating the
144
- thread. Upon receiving a return value of `napi_closing` from a thread-safe
145
- function call a thread must make no further use of the thread-safe function
146
- because it is no longer guaranteed to be allocated.
147
-
148
- ```cpp
149
- napi_status Napi::TypedThreadSafeFunction<ContextType, DataType, Callback>::Abort() const
150
- ```
151
-
152
- Returns one of:
153
- - `napi_ok`: The thread-safe function has been successfully aborted.
154
- - `napi_invalid_arg`: The thread-safe function's thread-count is zero.
155
- - `napi_generic_failure`: A generic error occurred when attempting to abort the
156
- thread-safe function.
157
-
158
- ### BlockingCall / NonBlockingCall
159
-
160
- Calls the Javascript function in either a blocking or non-blocking fashion.
161
- - `BlockingCall()`: the API blocks until space becomes available in the queue.
162
- Will never block if the thread-safe function was created with a maximum queue
163
- size of `0`.
164
- - `NonBlockingCall()`: will return `napi_queue_full` if the queue was full,
165
- preventing data from being successfully added to the queue.
166
-
167
- ```cpp
168
- napi_status Napi::TypedThreadSafeFunction<ContextType, DataType, Callback>::BlockingCall(DataType* data = nullptr) const
169
-
170
- napi_status Napi::TypedThreadSafeFunction<ContextType, DataType, Callback>::NonBlockingCall(DataType* data = nullptr) const
171
- ```
172
-
173
- - `[optional] data`: Data to pass to the callback which was passed to
174
- `TypedThreadSafeFunction::New()`.
175
-
176
- Returns one of:
177
- - `napi_ok`: `data` was successfully added to the queue.
178
- - `napi_queue_full`: The queue was full when trying to call in a non-blocking
179
- method.
180
- - `napi_closing`: The thread-safe function is aborted and no further calls can
181
- be made.
182
- - `napi_invalid_arg`: The thread-safe function is closed.
183
- - `napi_generic_failure`: A generic error occurred when attempting to add to the
184
- queue.
185
-
186
-
187
- ## Example
188
-
189
- ```cpp
190
- #include <chrono>
191
- #include <napi.h>
192
- #include <thread>
193
-
194
- using namespace Napi;
195
-
196
- using Context = Reference<Value>;
197
- using DataType = int;
198
- void CallJs(Napi::Env env, Function callback, Context *context, DataType *data);
199
- using TSFN = TypedThreadSafeFunction<Context, DataType, CallJs>;
200
- using FinalizerDataType = void;
201
-
202
- std::thread nativeThread;
203
- TSFN tsfn;
204
-
205
- Value Start(const CallbackInfo &info) {
206
- Napi::Env env = info.Env();
207
-
208
- if (info.Length() < 2) {
209
- throw TypeError::New(env, "Expected two arguments");
210
- } else if (!info[0].IsFunction()) {
211
- throw TypeError::New(env, "Expected first arg to be function");
212
- } else if (!info[1].IsNumber()) {
213
- throw TypeError::New(env, "Expected second arg to be number");
214
- }
215
-
216
- int count = info[1].As<Number>().Int32Value();
217
-
218
- // Create a new context set to the receiver (ie, `this`) of the function call
219
- Context *context = new Reference<Value>(Persistent(info.This()));
220
-
221
- // Create a ThreadSafeFunction
222
- tsfn = TSFN::New(
223
- env,
224
- info[0].As<Function>(), // JavaScript function called asynchronously
225
- "Resource Name", // Name
226
- 0, // Unlimited queue
227
- 1, // Only one thread will use this initially
228
- context,
229
- [](Napi::Env, FinalizerDataType *,
230
- Context *ctx) { // Finalizer used to clean threads up
231
- nativeThread.join();
232
- delete ctx;
233
- });
234
-
235
- // Create a native thread
236
- nativeThread = std::thread([count] {
237
- for (int i = 0; i < count; i++) {
238
- // Create new data
239
- int *value = new int(clock());
240
-
241
- // Perform a blocking call
242
- napi_status status = tsfn.BlockingCall(value);
243
- if (status != napi_ok) {
244
- // Handle error
245
- break;
246
- }
247
-
248
- std::this_thread::sleep_for(std::chrono::seconds(1));
249
- }
250
-
251
- // Release the thread-safe function
252
- tsfn.Release();
253
- });
254
-
255
- return Boolean::New(env, true);
256
- }
257
-
258
- // Transform native data into JS data, passing it to the provided
259
- // `callback` -- the TSFN's JavaScript function.
260
- void CallJs(Napi::Env env, Function callback, Context *context,
261
- DataType *data) {
262
- // Is the JavaScript environment still available to call into, eg. the TSFN is
263
- // not aborted
264
- if (env != nullptr) {
265
- // On Node-API 5+, the `callback` parameter is optional; however, this example
266
- // does ensure a callback is provided.
267
- if (callback != nullptr) {
268
- callback.Call(context->Value(), {Number::New(env, *data)});
269
- }
270
- }
271
- if (data != nullptr) {
272
- // We're finished with the data.
273
- delete data;
274
- }
275
- }
276
-
277
- Napi::Object Init(Napi::Env env, Object exports) {
278
- exports.Set("start", Function::New(env, Start));
279
- return exports;
280
- }
281
-
282
- NODE_API_MODULE(clock, Init)
283
- ```
284
-
285
- The above code can be used from JavaScript as follows:
286
-
287
- ```js
288
- const { start } = require('bindings')('clock');
289
-
290
- start.call(new Date(), function (clock) {
291
- const context = this;
292
- console.log(context, clock);
293
- }, 5);
294
- ```
295
-
296
- When executed, the output will show the value of `clock()` five times at one
297
- second intervals, prefixed with the TSFN's context -- `start`'s receiver (ie,
298
- `new Date()`):
299
-
300
- ```
301
- 2020-08-18T21:04:25.116Z 49824
302
- 2020-08-18T21:04:25.116Z 62493
303
- 2020-08-18T21:04:25.116Z 62919
304
- 2020-08-18T21:04:25.116Z 63228
305
- 2020-08-18T21:04:25.116Z 63531
306
- ```
@@ -1,368 +0,0 @@
1
- # Value
2
-
3
- `Napi::Value` is the C++ manifestation of a JavaScript value. It is the base
4
- class upon which other JavaScript values such as `Napi::Number`,
5
- `Napi::Boolean`, `Napi::String`, and `Napi::Object` are based. It represents a
6
- JavaScript value of an unknown type. It is a thin wrapper around the Node-API
7
- datatype `napi_value`. Methods on this class can be used to check the JavaScript
8
- type of the underlying Node-API `napi_value` and also to convert to C++ types.
9
-
10
- ## Constructors
11
-
12
- ### Empty Constructor
13
-
14
- ```cpp
15
- Napi::Value::Value();
16
- ```
17
-
18
- Creates a new *empty* `Napi::Value` instance.
19
-
20
- ### Constructor
21
-
22
- ```cpp
23
- Napi::Value::Value(napi_env env, napi_value value);
24
- ```
25
-
26
- - `[in] env`: The `napi_env` environment in which to construct the `Napi::Value`
27
- object.
28
- - `[in] value`: The C++ primitive from which to instantiate the `Napi::Value`.
29
- value` may be any of:
30
- - `bool`
31
- - Any integer type
32
- - Any floating point type
33
- - `const char*` (encoded using UTF-8, null-terminated)
34
- - `const char16_t*` (encoded using UTF-16-LE, null-terminated)
35
- - `std::string` (encoded using UTF-8)
36
- - `std::u16string`
37
- - `Napi::Value`
38
- - `napi_value`
39
-
40
- ## Operators
41
-
42
- ### operator napi_value
43
-
44
- ```cpp
45
- Napi::Value::operator napi_value() const;
46
- ```
47
-
48
- Returns the underlying Node-API `napi_value`. If the instance is _empty_, this
49
- returns `nullptr`.
50
-
51
- ### operator ==
52
-
53
- ```cpp
54
- bool Napi::Value::operator ==(const Napi::Value& other) const;
55
- ```
56
-
57
- Returns `true` if this value strictly equals another value, or `false`
58
- otherwise.
59
-
60
- ### operator !=
61
-
62
- ```cpp
63
- bool Napi::Value::operator !=(const Napi::Value& other) const;
64
- ```
65
-
66
- Returns `false` if this value strictly equals another value, or `true`
67
- otherwise.
68
-
69
- ## Methods
70
-
71
- ### As
72
-
73
- ```cpp
74
- template <typename T> T Napi::Value::As() const;
75
- ```
76
-
77
- Casts to another type of `Napi::Value`, when the actual type is known or
78
- assumed.
79
-
80
- This conversion does not coerce the type. Calling any methods inappropriate for
81
- the actual value type will throw `Napi::Error`. When C++ exceptions are
82
- disabled, the thrown error will not be reflected before control returns to
83
- JavaScript.
84
-
85
- In order to enforce expected type, use `Napi::Value::Is*()` methods to check
86
- the type before calling `Napi::Value::As()`, or compile with definition
87
- `NODE_ADDON_API_ENABLE_TYPE_CHECK_ON_AS` to enforce type checks.
88
-
89
- ### UnsafeAs
90
-
91
- ```cpp
92
- template <typename T> T Napi::Value::UnsafeAs() const;
93
- ```
94
-
95
- Casts to another type of `Napi::Value`, when the actual type is known or
96
- assumed.
97
-
98
- This conversion does not coerce the type. This does not check the type even if
99
- `NODE_ADDON_API_ENABLE_TYPE_CHECK_ON_AS` is defined. This indicates intentional
100
- unsafe type cast. Use `Napi::Value::As()` if possible.
101
-
102
- ### Env
103
-
104
- ```cpp
105
- Napi::Env Napi::Value::Env() const;
106
- ```
107
-
108
- Returns the `Napi::Env` environment this value is associated with. See
109
- [`Napi::Env`](env.md) for more details about environments.
110
-
111
- ### From
112
-
113
- ```cpp
114
- template <typename T>
115
- static Napi::Value Napi::Value::From(napi_env env, const T& value);
116
- ```
117
-
118
- - `[in] env`: The `napi_env` environment in which to create the `Napi::Value`
119
- object.
120
- - `[in] value`: The Node-API primitive value from which to create the `Napi::Value`
121
- object.
122
-
123
- Returns a `Napi::Value` object from an Node-API primitive value.
124
-
125
- This method is used to convert from a C++ type to a JavaScript value.
126
- Here, `value` may be any of:
127
- - `bool` - returns a `Napi::Boolean`.
128
- - Any integer type - returns a `Napi::Number`.
129
- - Any floating point type - returns a `Napi::Number`.
130
- - `const char*` (encoded using UTF-8, null-terminated) - returns a
131
- `Napi::String`.
132
- - `const char16_t*` (encoded using UTF-16-LE, null-terminated) - returns a
133
- `Napi::String`.
134
- - `std::string` (encoded using UTF-8) - returns a `Napi::String`.
135
- - `std::u16string` - returns a `Napi::String`.
136
- - `Napi::Value` - returns a `Napi::Value`.
137
- - `Napi_value` - returns a `Napi::Value`.
138
-
139
- ### IsArray
140
-
141
- ```cpp
142
- bool Napi::Value::IsArray() const;
143
- ```
144
-
145
- Returns `true` if the underlying value is a JavaScript `Napi::Array` or `false`
146
- otherwise.
147
-
148
- ### IsArrayBuffer
149
-
150
- ```cpp
151
- bool Napi::Value::IsArrayBuffer() const;
152
- ```
153
-
154
- Returns `true` if the underlying value is a JavaScript `Napi::ArrayBuffer` or
155
- `false` otherwise.
156
-
157
- ### IsBigInt
158
-
159
- ```cpp
160
- bool Napi::Value::IsBigInt() const;
161
- ```
162
-
163
- Returns `true` if the underlying value is a JavaScript `Napi::BigInt` or `false`
164
- otherwise.
165
-
166
- ### IsBoolean
167
-
168
- ```cpp
169
- bool Napi::Value::IsBoolean() const;
170
- ```
171
-
172
- Returns `true` if the underlying value is a JavaScript `true` or JavaScript
173
- `false`, or `false` if the value is not a `Napi::Boolean` value in JavaScript.
174
-
175
- ### IsBuffer
176
-
177
- ```cpp
178
- bool Napi::Value::IsBuffer() const;
179
- ```
180
-
181
- Returns `true` if the underlying value is a Node.js `Napi::Buffer` or `false`
182
- otherwise.
183
-
184
- ### IsDataView
185
- ```cpp
186
- bool Napi::Value::IsDataView() const;
187
- ```
188
-
189
- Returns `true` if the underlying value is a JavaScript `Napi::DataView` or
190
- `false` otherwise.
191
-
192
- ### IsDate
193
-
194
- ```cpp
195
- bool Napi::Value::IsDate() const;
196
- ```
197
-
198
- Returns `true` if the underlying value is a JavaScript `Date` or `false`
199
- otherwise.
200
-
201
- ### IsEmpty
202
-
203
- ```cpp
204
- bool Napi::Value::IsEmpty() const;
205
- ```
206
-
207
- Returns `true` if the value is uninitialized.
208
-
209
- An empty `Napi::Value` is invalid, and most attempts to perform an operation on
210
- an empty `Napi::Value` will result in an exception. An empty `Napi::Value` is
211
- distinct from JavaScript `null` or `undefined`, which are valid values.
212
-
213
- When C++ exceptions are disabled at compile time, a method with a `Napi::Value`
214
- return type may return an empty `Napi::Value` to indicate a pending exception.
215
- Thus, when C++ exceptions are not being used, callers should check the result of
216
- `Env::IsExceptionPending` before attempting to use the value.
217
-
218
- ### IsExternal
219
- ```cpp
220
- bool Napi::Value::IsExternal() const;
221
- ```
222
-
223
- Returns `true` if the underlying value is a Node-API external object or `false`
224
- otherwise.
225
-
226
- ### IsFunction
227
-
228
- ```cpp
229
- bool Napi::Value::IsFunction() const;
230
- ```
231
-
232
- Returns `true` if the underlying value is a JavaScript `Napi::Function` or
233
- `false` otherwise.
234
-
235
- ### IsNull
236
-
237
- ```cpp
238
- bool Napi::Value::IsNull() const;
239
- ```
240
-
241
- Returns `true` if the underlying value is a JavaScript `null` or `false`
242
- otherwise.
243
-
244
- ### IsNumber
245
-
246
- ```cpp
247
- bool Napi::Value::IsNumber() const;
248
- ```
249
-
250
- Returns `true` if the underlying value is a JavaScript `Napi::Number` or `false`
251
- otherwise.
252
-
253
- ### IsObject
254
-
255
- ```cpp
256
- bool Napi::Value::IsObject() const;
257
- ```
258
-
259
- Returns `true` if the underlying value is a JavaScript `Napi::Object` or `false`
260
- otherwise.
261
-
262
- ### IsPromise
263
-
264
- ```cpp
265
- bool Napi::Value::IsPromise() const;
266
- ```
267
-
268
- Returns `true` if the underlying value is a JavaScript `Napi::Promise` or
269
- `false` otherwise.
270
-
271
- ### IsString
272
-
273
- ```cpp
274
- bool Napi::Value::IsString() const;
275
- ```
276
-
277
- Returns `true` if the underlying value is a JavaScript `Napi::String` or `false`
278
- otherwise.
279
-
280
- ### IsSymbol
281
-
282
- ```cpp
283
- bool Napi::Value::IsSymbol() const;
284
- ```
285
-
286
- Returns `true` if the underlying value is a JavaScript `Napi::Symbol` or `false`
287
- otherwise.
288
-
289
- ### IsTypedArray
290
-
291
- ```cpp
292
- bool Napi::Value::IsTypedArray() const;
293
- ```
294
-
295
- Returns `true` if the underlying value is a JavaScript `Napi::TypedArray` or
296
- `false` otherwise.
297
-
298
- ### IsUndefined
299
-
300
- ```cpp
301
- bool Napi::Value::IsUndefined() const;
302
- ```
303
-
304
- Returns `true` if the underlying value is a JavaScript `undefined` or `false`
305
- otherwise.
306
-
307
- ### StrictEquals
308
-
309
- ```cpp
310
- bool Napi::Value::StrictEquals(const Napi::Value& other) const;
311
- ```
312
- - `[in] other`: The `Napi::Value` object to be compared.
313
-
314
- Returns a `bool` indicating if this `Napi::Value` strictly equals another
315
- `Napi::Value`.
316
-
317
- ### ToBoolean
318
-
319
- ```cpp
320
- Napi::Boolean Napi::Value::ToBoolean() const;
321
- ```
322
-
323
- Returns a `Napi::Boolean` representing the `Napi::Value`.
324
-
325
- This is a wrapper around `napi_coerce_to_boolean`. This will throw a JavaScript
326
- exception if the coercion fails. If C++ exceptions are not being used, callers
327
- should check the result of `Env::IsExceptionPending` before attempting to use
328
- the returned value.
329
-
330
- ### ToNumber
331
-
332
- ```cpp
333
- Napi::Number Napi::Value::ToNumber() const;
334
- ```
335
-
336
- Returns the `Napi::Value` coerced to a JavaScript number.
337
-
338
- ### ToObject
339
-
340
- ```cpp
341
- Napi::Object Napi::Value::ToObject() const;
342
- ```
343
-
344
- Returns the `Napi::Value` coerced to a JavaScript object.
345
-
346
- ### ToString
347
-
348
- ```cpp
349
- Napi::String Napi::Value::ToString() const;
350
- ```
351
-
352
- Returns the `Napi::Value` coerced to a JavaScript string.
353
-
354
- ### Type
355
-
356
- ```cpp
357
- napi_valuetype Napi::Value::Type() const;
358
- ```
359
-
360
- Returns the `napi_valuetype` type of the `Napi::Value`.
361
-
362
- [`Napi::Boolean`]: ./boolean.md
363
- [`Napi::BigInt`]: ./bigint.md
364
- [`Napi::Date`]: ./date.md
365
- [`Napi::External`]: ./external.md
366
- [`Napi::Name`]: ./name.md
367
- [`Napi::Number`]: ./number.md
368
- [`Napi::Object`]: ./object.md
@@ -1,43 +0,0 @@
1
- # VersionManagement
2
-
3
- The `Napi::VersionManagement` class contains methods that allow information
4
- to be retrieved about the version of Node-API and Node.js. In some cases it is
5
- important to make decisions based on different versions of the system.
6
-
7
- ## Methods
8
-
9
- ### GetNapiVersion
10
-
11
- Retrieves the highest Node-API version supported by Node.js runtime.
12
-
13
- ```cpp
14
- static uint32_t Napi::VersionManagement::GetNapiVersion(Napi::BasicEnv env);
15
- ```
16
-
17
- - `[in] env`: The environment in which the API is invoked under.
18
-
19
- Returns the highest Node-API version supported by Node.js runtime.
20
-
21
- ### GetNodeVersion
22
-
23
- Retrieves information about Node.js version present on the system. All the
24
- information is stored in the `napi_node_version` structure that is defined as
25
- shown below:
26
-
27
- ```cpp
28
- typedef struct {
29
- uint32_t major;
30
- uint32_t minor;
31
- uint32_t patch;
32
- const char* release;
33
- } napi_node_version;
34
- ````
35
-
36
- ```cpp
37
- static const napi_node_version* Napi::VersionManagement::GetNodeVersion(Napi::BasicEnv env);
38
- ```
39
-
40
- - `[in] env`: The environment in which the API is invoked under.
41
-
42
- Returns the structure a pointer to the structure `napi_node_version` populated by
43
- the version information of Node.js runtime.