koffi 1.0.3 → 1.1.0-beta.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.
- package/README.md +48 -22
- package/build/qemu/1.1.0-beta.0/koffi_darwin_x64.tar.gz +0 -0
- package/build/qemu/1.1.0-beta.0/koffi_freebsd_arm64.tar.gz +0 -0
- package/build/qemu/1.1.0-beta.0/koffi_freebsd_ia32.tar.gz +0 -0
- package/build/qemu/1.1.0-beta.0/koffi_freebsd_x64.tar.gz +0 -0
- package/build/qemu/1.1.0-beta.0/koffi_linux_arm.tar.gz +0 -0
- package/build/qemu/1.1.0-beta.0/koffi_linux_arm64.tar.gz +0 -0
- package/build/qemu/1.1.0-beta.0/koffi_linux_ia32.tar.gz +0 -0
- package/build/qemu/1.1.0-beta.0/koffi_linux_x64.tar.gz +0 -0
- package/build/qemu/1.1.0-beta.0/koffi_win32_ia32.tar.gz +0 -0
- package/build/qemu/1.1.0-beta.0/koffi_win32_x64.tar.gz +0 -0
- package/package.json +1 -1
- package/qemu/qemu.js +11 -5
- package/qemu/registry/machines.json +20 -10
- package/src/abi_arm32.cc +130 -215
- package/src/abi_arm64.cc +103 -117
- package/src/abi_x64_sysv.cc +117 -135
- package/src/abi_x64_win.cc +89 -98
- package/src/abi_x86.cc +91 -99
- package/src/call.cc +164 -40
- package/src/call.hh +53 -31
- package/src/ffi.cc +163 -19
- package/src/ffi.hh +30 -22
- package/src/util.cc +0 -127
- package/src/util.hh +0 -16
- package/test/misc.c +68 -2
- package/vendor/libcc/libcc.hh +1 -1
- package/build/qemu/1.0.3/koffi_darwin_x64.tar.gz +0 -0
- package/build/qemu/1.0.3/koffi_freebsd_arm64.tar.gz +0 -0
- package/build/qemu/1.0.3/koffi_freebsd_ia32.tar.gz +0 -0
- package/build/qemu/1.0.3/koffi_freebsd_x64.tar.gz +0 -0
- package/build/qemu/1.0.3/koffi_linux_arm.tar.gz +0 -0
- package/build/qemu/1.0.3/koffi_linux_arm64.tar.gz +0 -0
- package/build/qemu/1.0.3/koffi_linux_ia32.tar.gz +0 -0
- package/build/qemu/1.0.3/koffi_linux_x64.tar.gz +0 -0
- package/build/qemu/1.0.3/koffi_win32_ia32.tar.gz +0 -0
- package/build/qemu/1.0.3/koffi_win32_x64.tar.gz +0 -0
- package/test/misc.js +0 -180
- package/vendor/node-addon-api/CODE_OF_CONDUCT.md +0 -4
- package/vendor/node-addon-api/CONTRIBUTING.md +0 -93
- package/vendor/node-addon-api/appveyor.yml +0 -37
- package/vendor/node-addon-api/benchmark/README.md +0 -47
- package/vendor/node-addon-api/benchmark/binding.gyp +0 -25
- package/vendor/node-addon-api/benchmark/function_args.cc +0 -217
- package/vendor/node-addon-api/benchmark/function_args.js +0 -60
- package/vendor/node-addon-api/benchmark/index.js +0 -34
- package/vendor/node-addon-api/benchmark/property_descriptor.cc +0 -91
- package/vendor/node-addon-api/benchmark/property_descriptor.js +0 -37
- package/vendor/node-addon-api/doc/addon.md +0 -163
- package/vendor/node-addon-api/doc/array.md +0 -81
- package/vendor/node-addon-api/doc/array_buffer.md +0 -155
- package/vendor/node-addon-api/doc/async_context.md +0 -86
- package/vendor/node-addon-api/doc/async_operations.md +0 -31
- package/vendor/node-addon-api/doc/async_worker.md +0 -427
- package/vendor/node-addon-api/doc/async_worker_variants.md +0 -557
- package/vendor/node-addon-api/doc/bigint.md +0 -97
- package/vendor/node-addon-api/doc/boolean.md +0 -68
- package/vendor/node-addon-api/doc/buffer.md +0 -150
- package/vendor/node-addon-api/doc/callback_scope.md +0 -54
- package/vendor/node-addon-api/doc/callbackinfo.md +0 -97
- package/vendor/node-addon-api/doc/checker-tool.md +0 -32
- package/vendor/node-addon-api/doc/class_property_descriptor.md +0 -123
- package/vendor/node-addon-api/doc/cmake-js.md +0 -68
- package/vendor/node-addon-api/doc/conversion-tool.md +0 -28
- package/vendor/node-addon-api/doc/creating_a_release.md +0 -62
- package/vendor/node-addon-api/doc/dataview.md +0 -248
- package/vendor/node-addon-api/doc/date.md +0 -68
- package/vendor/node-addon-api/doc/env.md +0 -196
- package/vendor/node-addon-api/doc/error.md +0 -120
- package/vendor/node-addon-api/doc/error_handling.md +0 -254
- package/vendor/node-addon-api/doc/escapable_handle_scope.md +0 -80
- package/vendor/node-addon-api/doc/external.md +0 -63
- package/vendor/node-addon-api/doc/function.md +0 -402
- package/vendor/node-addon-api/doc/function_reference.md +0 -238
- package/vendor/node-addon-api/doc/generator.md +0 -13
- package/vendor/node-addon-api/doc/handle_scope.md +0 -63
- package/vendor/node-addon-api/doc/hierarchy.md +0 -91
- package/vendor/node-addon-api/doc/instance_wrap.md +0 -408
- package/vendor/node-addon-api/doc/maybe.md +0 -76
- package/vendor/node-addon-api/doc/memory_management.md +0 -27
- package/vendor/node-addon-api/doc/name.md +0 -29
- package/vendor/node-addon-api/doc/node-gyp.md +0 -82
- package/vendor/node-addon-api/doc/number.md +0 -163
- package/vendor/node-addon-api/doc/object.md +0 -411
- package/vendor/node-addon-api/doc/object_lifetime_management.md +0 -83
- package/vendor/node-addon-api/doc/object_reference.md +0 -117
- package/vendor/node-addon-api/doc/object_wrap.md +0 -588
- package/vendor/node-addon-api/doc/prebuild_tools.md +0 -16
- package/vendor/node-addon-api/doc/promises.md +0 -79
- package/vendor/node-addon-api/doc/property_descriptor.md +0 -286
- package/vendor/node-addon-api/doc/propertylvalue.md +0 -50
- package/vendor/node-addon-api/doc/range_error.md +0 -59
- package/vendor/node-addon-api/doc/reference.md +0 -113
- package/vendor/node-addon-api/doc/setup.md +0 -110
- package/vendor/node-addon-api/doc/string.md +0 -93
- package/vendor/node-addon-api/doc/symbol.md +0 -61
- package/vendor/node-addon-api/doc/threadsafe.md +0 -121
- package/vendor/node-addon-api/doc/threadsafe_function.md +0 -290
- package/vendor/node-addon-api/doc/type_error.md +0 -59
- package/vendor/node-addon-api/doc/typed_array.md +0 -78
- package/vendor/node-addon-api/doc/typed_array_of.md +0 -137
- package/vendor/node-addon-api/doc/typed_threadsafe_function.md +0 -306
- package/vendor/node-addon-api/doc/value.md +0 -340
- package/vendor/node-addon-api/doc/version_management.md +0 -43
- package/vendor/node-addon-api/package.json +0 -415
- package/vendor/node-addon-api/test/README.md +0 -91
- package/vendor/node-addon-api/test/addon.cc +0 -36
- package/vendor/node-addon-api/test/addon.js +0 -11
- package/vendor/node-addon-api/test/addon_build/index.js +0 -49
- package/vendor/node-addon-api/test/addon_build/tpl/addon.cc +0 -17
- package/vendor/node-addon-api/test/addon_build/tpl/binding.gyp +0 -62
- package/vendor/node-addon-api/test/addon_build/tpl/index.js +0 -9
- package/vendor/node-addon-api/test/addon_build/tpl/package.json +0 -11
- package/vendor/node-addon-api/test/addon_data.cc +0 -99
- package/vendor/node-addon-api/test/addon_data.js +0 -46
- package/vendor/node-addon-api/test/array_buffer.cc +0 -243
- package/vendor/node-addon-api/test/array_buffer.js +0 -69
- package/vendor/node-addon-api/test/async_context.cc +0 -36
- package/vendor/node-addon-api/test/async_context.js +0 -122
- package/vendor/node-addon-api/test/async_progress_queue_worker.cc +0 -83
- package/vendor/node-addon-api/test/async_progress_queue_worker.js +0 -46
- package/vendor/node-addon-api/test/async_progress_worker.cc +0 -134
- package/vendor/node-addon-api/test/async_progress_worker.js +0 -61
- package/vendor/node-addon-api/test/async_worker.cc +0 -106
- package/vendor/node-addon-api/test/async_worker.js +0 -179
- package/vendor/node-addon-api/test/async_worker_nocallback.js +0 -13
- package/vendor/node-addon-api/test/async_worker_persistent.cc +0 -63
- package/vendor/node-addon-api/test/async_worker_persistent.js +0 -24
- package/vendor/node-addon-api/test/basic_types/array.cc +0 -40
- package/vendor/node-addon-api/test/basic_types/array.js +0 -35
- package/vendor/node-addon-api/test/basic_types/boolean.cc +0 -38
- package/vendor/node-addon-api/test/basic_types/boolean.js +0 -35
- package/vendor/node-addon-api/test/basic_types/number.cc +0 -99
- package/vendor/node-addon-api/test/basic_types/number.js +0 -114
- package/vendor/node-addon-api/test/basic_types/value.cc +0 -120
- package/vendor/node-addon-api/test/basic_types/value.js +0 -133
- package/vendor/node-addon-api/test/bigint.cc +0 -91
- package/vendor/node-addon-api/test/bigint.js +0 -53
- package/vendor/node-addon-api/test/binding-swallowexcept.cc +0 -12
- package/vendor/node-addon-api/test/binding.cc +0 -173
- package/vendor/node-addon-api/test/binding.gyp +0 -124
- package/vendor/node-addon-api/test/buffer.cc +0 -183
- package/vendor/node-addon-api/test/buffer.js +0 -69
- package/vendor/node-addon-api/test/callbackscope.cc +0 -22
- package/vendor/node-addon-api/test/callbackscope.js +0 -49
- package/vendor/node-addon-api/test/common/index.js +0 -114
- package/vendor/node-addon-api/test/common/test_helper.h +0 -71
- package/vendor/node-addon-api/test/dataview/dataview.cc +0 -48
- package/vendor/node-addon-api/test/dataview/dataview.js +0 -35
- package/vendor/node-addon-api/test/dataview/dataview_read_write.cc +0 -115
- package/vendor/node-addon-api/test/dataview/dataview_read_write.js +0 -90
- package/vendor/node-addon-api/test/date.cc +0 -44
- package/vendor/node-addon-api/test/date.js +0 -18
- package/vendor/node-addon-api/test/env_cleanup.cc +0 -88
- package/vendor/node-addon-api/test/env_cleanup.js +0 -56
- package/vendor/node-addon-api/test/error.cc +0 -287
- package/vendor/node-addon-api/test/error.js +0 -81
- package/vendor/node-addon-api/test/error_handling_for_primitives.cc +0 -13
- package/vendor/node-addon-api/test/error_handling_for_primitives.js +0 -29
- package/vendor/node-addon-api/test/error_terminating_environment.js +0 -95
- package/vendor/node-addon-api/test/external.cc +0 -81
- package/vendor/node-addon-api/test/external.js +0 -88
- package/vendor/node-addon-api/test/function.cc +0 -324
- package/vendor/node-addon-api/test/function.js +0 -133
- package/vendor/node-addon-api/test/function_reference.cc +0 -202
- package/vendor/node-addon-api/test/function_reference.js +0 -157
- package/vendor/node-addon-api/test/globalObject/global_object.cc +0 -61
- package/vendor/node-addon-api/test/globalObject/global_object_delete_property.cc +0 -31
- package/vendor/node-addon-api/test/globalObject/global_object_delete_property.js +0 -61
- package/vendor/node-addon-api/test/globalObject/global_object_get_property.cc +0 -40
- package/vendor/node-addon-api/test/globalObject/global_object_get_property.js +0 -57
- package/vendor/node-addon-api/test/globalObject/global_object_has_own_property.cc +0 -28
- package/vendor/node-addon-api/test/globalObject/global_object_has_own_property.js +0 -48
- package/vendor/node-addon-api/test/globalObject/global_object_set_property.cc +0 -31
- package/vendor/node-addon-api/test/globalObject/global_object_set_property.js +0 -58
- package/vendor/node-addon-api/test/handlescope.cc +0 -60
- package/vendor/node-addon-api/test/handlescope.js +0 -14
- package/vendor/node-addon-api/test/index.js +0 -159
- package/vendor/node-addon-api/test/maybe/check.cc +0 -23
- package/vendor/node-addon-api/test/maybe/index.js +0 -38
- package/vendor/node-addon-api/test/memory_management.cc +0 -17
- package/vendor/node-addon-api/test/memory_management.js +0 -9
- package/vendor/node-addon-api/test/movable_callbacks.cc +0 -23
- package/vendor/node-addon-api/test/movable_callbacks.js +0 -21
- package/vendor/node-addon-api/test/name.cc +0 -108
- package/vendor/node-addon-api/test/name.js +0 -59
- package/vendor/node-addon-api/test/napi_child.js +0 -14
- package/vendor/node-addon-api/test/object/delete_property.cc +0 -38
- package/vendor/node-addon-api/test/object/delete_property.js +0 -41
- package/vendor/node-addon-api/test/object/finalizer.cc +0 -29
- package/vendor/node-addon-api/test/object/finalizer.js +0 -28
- package/vendor/node-addon-api/test/object/get_property.cc +0 -34
- package/vendor/node-addon-api/test/object/get_property.js +0 -40
- package/vendor/node-addon-api/test/object/has_own_property.cc +0 -34
- package/vendor/node-addon-api/test/object/has_own_property.js +0 -34
- package/vendor/node-addon-api/test/object/has_property.cc +0 -38
- package/vendor/node-addon-api/test/object/has_property.js +0 -37
- package/vendor/node-addon-api/test/object/object.cc +0 -350
- package/vendor/node-addon-api/test/object/object.js +0 -217
- package/vendor/node-addon-api/test/object/object_deprecated.cc +0 -66
- package/vendor/node-addon-api/test/object/object_deprecated.js +0 -47
- package/vendor/node-addon-api/test/object/object_freeze_seal.cc +0 -25
- package/vendor/node-addon-api/test/object/object_freeze_seal.js +0 -61
- package/vendor/node-addon-api/test/object/set_property.cc +0 -45
- package/vendor/node-addon-api/test/object/set_property.js +0 -30
- package/vendor/node-addon-api/test/object/subscript_operator.cc +0 -58
- package/vendor/node-addon-api/test/object/subscript_operator.js +0 -17
- package/vendor/node-addon-api/test/object_reference.cc +0 -219
- package/vendor/node-addon-api/test/object_reference.js +0 -259
- package/vendor/node-addon-api/test/objectwrap.cc +0 -268
- package/vendor/node-addon-api/test/objectwrap.js +0 -284
- package/vendor/node-addon-api/test/objectwrap_constructor_exception.cc +0 -26
- package/vendor/node-addon-api/test/objectwrap_constructor_exception.js +0 -18
- package/vendor/node-addon-api/test/objectwrap_function.cc +0 -45
- package/vendor/node-addon-api/test/objectwrap_function.js +0 -22
- package/vendor/node-addon-api/test/objectwrap_multiple_inheritance.cc +0 -30
- package/vendor/node-addon-api/test/objectwrap_multiple_inheritance.js +0 -13
- package/vendor/node-addon-api/test/objectwrap_removewrap.cc +0 -45
- package/vendor/node-addon-api/test/objectwrap_removewrap.js +0 -40
- package/vendor/node-addon-api/test/objectwrap_worker_thread.js +0 -19
- package/vendor/node-addon-api/test/promise.cc +0 -29
- package/vendor/node-addon-api/test/promise.js +0 -18
- package/vendor/node-addon-api/test/reference.cc +0 -24
- package/vendor/node-addon-api/test/reference.js +0 -14
- package/vendor/node-addon-api/test/run_script.cc +0 -56
- package/vendor/node-addon-api/test/run_script.js +0 -45
- package/vendor/node-addon-api/test/symbol.cc +0 -79
- package/vendor/node-addon-api/test/symbol.js +0 -73
- package/vendor/node-addon-api/test/testUtil.js +0 -54
- package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function.cc +0 -195
- package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function.js +0 -188
- package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function_ctx.cc +0 -63
- package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function_ctx.js +0 -12
- package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function_existing_tsfn.cc +0 -115
- package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function_existing_tsfn.js +0 -14
- package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function_ptr.cc +0 -26
- package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function_ptr.js +0 -7
- package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function_sum.cc +0 -225
- package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function_sum.js +0 -59
- package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function_unref.cc +0 -42
- package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function_unref.js +0 -53
- package/vendor/node-addon-api/test/thunking_manual.cc +0 -140
- package/vendor/node-addon-api/test/thunking_manual.js +0 -17
- package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function.cc +0 -215
- package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function.js +0 -188
- package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function_ctx.cc +0 -68
- package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function_ctx.js +0 -12
- package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function_existing_tsfn.cc +0 -127
- package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function_existing_tsfn.js +0 -14
- package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function_ptr.cc +0 -28
- package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function_ptr.js +0 -7
- package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function_sum.cc +0 -237
- package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function_sum.js +0 -59
- package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function_unref.cc +0 -53
- package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function_unref.js +0 -53
- package/vendor/node-addon-api/test/typedarray-bigint.js +0 -58
- package/vendor/node-addon-api/test/typedarray.cc +0 -216
- package/vendor/node-addon-api/test/typedarray.js +0 -69
- package/vendor/node-addon-api/test/version_management.cc +0 -27
- package/vendor/node-addon-api/test/version_management.js +0 -31
- package/vendor/node-addon-api/unit-test/README.md +0 -28
- package/vendor/node-addon-api/unit-test/binding-file-template.js +0 -39
- package/vendor/node-addon-api/unit-test/binding.gyp +0 -72
- package/vendor/node-addon-api/unit-test/exceptions.js +0 -32
- package/vendor/node-addon-api/unit-test/generate-binding-cc.js +0 -61
- package/vendor/node-addon-api/unit-test/injectTestParams.js +0 -101
- package/vendor/node-addon-api/unit-test/listOfTestModules.js +0 -88
- package/vendor/node-addon-api/unit-test/matchModules.js +0 -65
- package/vendor/node-addon-api/unit-test/setup.js +0 -13
- package/vendor/node-addon-api/unit-test/spawnTask.js +0 -26
- package/vendor/node-addon-api/unit-test/test.js +0 -30
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
# Add-on Structure
|
|
2
|
-
|
|
3
|
-
Class `Napi::Addon<T>` inherits from class [`Napi::InstanceWrap<T>`][].
|
|
4
|
-
|
|
5
|
-
Creating add-ons that work correctly when loaded multiple times from the same
|
|
6
|
-
source package into multiple Node.js threads and/or multiple times into the same
|
|
7
|
-
Node.js thread requires that all global data they hold be associated with the
|
|
8
|
-
environment in which they run. It is not safe to store global data in static
|
|
9
|
-
variables because doing so does not take into account the fact that an add-on
|
|
10
|
-
may be loaded into multiple threads nor that an add-on may be loaded multiple
|
|
11
|
-
times into a single thread.
|
|
12
|
-
|
|
13
|
-
The `Napi::Addon<T>` class can be used to define an entire add-on. Instances of
|
|
14
|
-
`Napi::Addon<T>` subclasses become instances of the add-on, stored safely by
|
|
15
|
-
Node.js on its various threads and into its various contexts. Thus, any data
|
|
16
|
-
stored in the instance variables of a `Napi::Addon<T>` subclass instance are
|
|
17
|
-
stored safely by Node.js. Functions exposed to JavaScript using
|
|
18
|
-
`Napi::Addon<T>::InstanceMethod` and/or `Napi::Addon<T>::DefineAddon` are
|
|
19
|
-
instance methods of the `Napi::Addon` subclass and thus have access to data
|
|
20
|
-
stored inside the instance.
|
|
21
|
-
|
|
22
|
-
`Napi::Addon<T>::DefineProperties` may be used to attach `Napi::Addon<T>`
|
|
23
|
-
subclass instance methods to objects other than the one that will be returned to
|
|
24
|
-
Node.js as the add-on instance.
|
|
25
|
-
|
|
26
|
-
The `Napi::Addon<T>` class can be used together with the `NODE_API_ADDON()` and
|
|
27
|
-
`NODE_API_NAMED_ADDON()` macros to define add-ons.
|
|
28
|
-
|
|
29
|
-
## Example
|
|
30
|
-
|
|
31
|
-
```cpp
|
|
32
|
-
#include <napi.h>
|
|
33
|
-
|
|
34
|
-
class ExampleAddon : public Napi::Addon<ExampleAddon> {
|
|
35
|
-
public:
|
|
36
|
-
ExampleAddon(Napi::Env env, Napi::Object exports) {
|
|
37
|
-
// In the constructor we declare the functions the add-on makes available
|
|
38
|
-
// to JavaScript.
|
|
39
|
-
DefineAddon(exports, {
|
|
40
|
-
InstanceMethod("increment", &ExampleAddon::Increment),
|
|
41
|
-
|
|
42
|
-
// We can also attach plain objects to `exports`, and instance methods as
|
|
43
|
-
// properties of those sub-objects.
|
|
44
|
-
InstanceValue("subObject", DefineProperties(Napi::Object::New(env), {
|
|
45
|
-
InstanceMethod("decrement", &ExampleAddon::Decrement)
|
|
46
|
-
}), napi_enumerable)
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
private:
|
|
50
|
-
|
|
51
|
-
// This method has access to the data stored in the environment because it is
|
|
52
|
-
// an instance method of `ExampleAddon` and because it was listed among the
|
|
53
|
-
// property descriptors passed to `DefineAddon()` in the constructor.
|
|
54
|
-
Napi::Value Increment(const Napi::CallbackInfo& info) {
|
|
55
|
-
return Napi::Number::New(info.Env(), ++value);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// This method has access to the data stored in the environment because it is
|
|
59
|
-
// an instance method of `ExampleAddon` and because it was exposed to
|
|
60
|
-
// JavaScript by calling `DefineProperties()` with the object onto which it is
|
|
61
|
-
// attached.
|
|
62
|
-
Napi::Value Decrement(const Napi::CallbackInfo& info) {
|
|
63
|
-
return Napi::Number::New(info.Env(), --value);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// Data stored in these variables is unique to each instance of the add-on.
|
|
67
|
-
uint32_t value = 42;
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
// The macro announces that instances of the class `ExampleAddon` will be
|
|
71
|
-
// created for each instance of the add-on that must be loaded into Node.js.
|
|
72
|
-
NODE_API_ADDON(ExampleAddon)
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
The above code can be used from JavaScript as follows:
|
|
76
|
-
|
|
77
|
-
```js
|
|
78
|
-
'use strict'
|
|
79
|
-
|
|
80
|
-
const exampleAddon = require('bindings')('example_addon');
|
|
81
|
-
console.log(exampleAddon.increment()); // prints 43
|
|
82
|
-
console.log(exampleAddon.increment()); // prints 44
|
|
83
|
-
console.log(exampleAddon.subObject.decrement()); // prints 43
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
When Node.js loads an instance of the add-on, a new instance of the class is
|
|
87
|
-
created. Its constructor receives the environment `Napi::Env env` and the
|
|
88
|
-
exports object `Napi::Object exports`. It can then use the method `DefineAddon`
|
|
89
|
-
to either attach methods, accessors, and/or values to the `exports` object or to
|
|
90
|
-
create its own `exports` object and attach methods, accessors, and/or values to
|
|
91
|
-
it.
|
|
92
|
-
|
|
93
|
-
**Note:** `Napi::Addon<T>` uses `Napi::Env::SetInstanceData()` internally. This
|
|
94
|
-
means that the add-on should only use `Napi::Env::GetInstanceData` explicitly to
|
|
95
|
-
retrieve the instance of the `Napi::Addon<T>` class. Variables whose scope would
|
|
96
|
-
otherwise be global should be stored as instance variables in the
|
|
97
|
-
`Napi::Addon<T>` class.
|
|
98
|
-
|
|
99
|
-
Functions created with `Napi::Function::New()`, accessors created with
|
|
100
|
-
`PropertyDescriptor::Accessor()`, and values can also be attached. If their
|
|
101
|
-
implementation requires the `ExampleAddon` instance, it can be retrieved from
|
|
102
|
-
the `Napi::Env env` with `GetInstanceData()`:
|
|
103
|
-
|
|
104
|
-
```cpp
|
|
105
|
-
void ExampleBinding(const Napi::CallbackInfo& info) {
|
|
106
|
-
ExampleAddon* addon = info.Env().GetInstanceData<ExampleAddon>();
|
|
107
|
-
}
|
|
108
|
-
```
|
|
109
|
-
|
|
110
|
-
## Methods
|
|
111
|
-
|
|
112
|
-
### Constructor
|
|
113
|
-
|
|
114
|
-
Creates a new instance of the add-on.
|
|
115
|
-
|
|
116
|
-
```cpp
|
|
117
|
-
Napi::Addon(Napi::Env env, Napi::Object exports);
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
- `[in] env`: The environment into which the add-on is being loaded.
|
|
121
|
-
- `[in] exports`: The exports object received from JavaScript.
|
|
122
|
-
|
|
123
|
-
Typically, the constructor calls `DefineAddon()` to attach methods, accessors,
|
|
124
|
-
and/or values to `exports`. The constructor may also create a new object and
|
|
125
|
-
pass it to `DefineAddon()` as its first parameter if it wishes to replace the
|
|
126
|
-
`exports` object as provided by Node.js.
|
|
127
|
-
|
|
128
|
-
### DefineAddon
|
|
129
|
-
|
|
130
|
-
Defines an add-on instance with functions, accessors, and/or values.
|
|
131
|
-
|
|
132
|
-
```cpp
|
|
133
|
-
template <typename T>
|
|
134
|
-
void Napi::Addon<T>::DefineAddon(Napi::Object exports,
|
|
135
|
-
const std::initializer_list<PropertyDescriptor>& properties);
|
|
136
|
-
```
|
|
137
|
-
|
|
138
|
-
* `[in] exports`: The object to return to Node.js as an instance of the add-on.
|
|
139
|
-
* `[in] properties`: Initializer list of add-on property descriptors of the
|
|
140
|
-
methods, property accessors, and values that define the add-on. They will be
|
|
141
|
-
set on `exports`.
|
|
142
|
-
See: [`Class property and descriptor`](class_property_descriptor.md).
|
|
143
|
-
|
|
144
|
-
### DefineProperties
|
|
145
|
-
|
|
146
|
-
Defines function, accessor, and/or value properties on an object using add-on
|
|
147
|
-
instance methods.
|
|
148
|
-
|
|
149
|
-
```cpp
|
|
150
|
-
template <typename T>
|
|
151
|
-
Napi::Object
|
|
152
|
-
Napi::Addon<T>::DefineProperties(Napi::Object object,
|
|
153
|
-
const std::initializer_list<PropertyDescriptor>& properties);
|
|
154
|
-
```
|
|
155
|
-
|
|
156
|
-
* `[in] object`: The object that will receive the new properties.
|
|
157
|
-
* `[in] properties`: Initializer list of property descriptors of the methods,
|
|
158
|
-
property accessors, and values to attach to `object`.
|
|
159
|
-
See: [`Class property and descriptor`](class_property_descriptor.md).
|
|
160
|
-
|
|
161
|
-
Returns `object`.
|
|
162
|
-
|
|
163
|
-
[`Napi::InstanceWrap<T>`]: ./instance_wrap.md
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
# Array
|
|
2
|
-
|
|
3
|
-
Class [`Napi::Array`][] inherits from class [`Napi::Object`][].
|
|
4
|
-
|
|
5
|
-
Arrays are native representations of JavaScript Arrays. `Napi::Array` is a wrapper
|
|
6
|
-
around `napi_value` representing a JavaScript Array.
|
|
7
|
-
|
|
8
|
-
[`Napi::TypedArray`][] and [`Napi::ArrayBuffer`][] correspond to JavaScript data
|
|
9
|
-
types such as [`Napi::Int32Array`][] and [`Napi::ArrayBuffer`][], respectively,
|
|
10
|
-
that can be used for transferring large amounts of data from JavaScript to the
|
|
11
|
-
native side. An example illustrating the use of a JavaScript-provided
|
|
12
|
-
`ArrayBuffer` in native code is available [here](https://github.com/nodejs/node-addon-examples/tree/HEAD/array_buffer_to_native/node-addon-api).
|
|
13
|
-
|
|
14
|
-
## Constructor
|
|
15
|
-
```cpp
|
|
16
|
-
Napi::Array::Array();
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
Returns an empty array.
|
|
20
|
-
|
|
21
|
-
If an error occurs, a `Napi::Error` will be thrown. If C++ exceptions are not
|
|
22
|
-
being used, callers should check the result of `Env::IsExceptionPending` before
|
|
23
|
-
attempting to use the returned value.
|
|
24
|
-
|
|
25
|
-
```cpp
|
|
26
|
-
Napi::Array::Array(napi_env env, napi_value value);
|
|
27
|
-
```
|
|
28
|
-
- `[in] env` - The environment in which to create the array.
|
|
29
|
-
- `[in] value` - The primitive to wrap.
|
|
30
|
-
|
|
31
|
-
Returns a `Napi::Array` wrapping a `napi_value`.
|
|
32
|
-
|
|
33
|
-
If an error occurs, a `Napi::Error` will get thrown. If C++ exceptions are not
|
|
34
|
-
being used, callers should check the result of `Env::IsExceptionPending` before
|
|
35
|
-
attempting to use the returned value.
|
|
36
|
-
|
|
37
|
-
## Methods
|
|
38
|
-
|
|
39
|
-
### New
|
|
40
|
-
```cpp
|
|
41
|
-
static Napi::Array Napi::Array::New(napi_env env);
|
|
42
|
-
```
|
|
43
|
-
- `[in] env` - The environment in which to create the array.
|
|
44
|
-
|
|
45
|
-
Returns a new `Napi::Array`.
|
|
46
|
-
|
|
47
|
-
If an error occurs, a `Napi::Error` will get thrown. If C++ exceptions are not
|
|
48
|
-
being used, callers should check the result of `Env::IsExceptionPending` before
|
|
49
|
-
attempting to use the returned value.
|
|
50
|
-
|
|
51
|
-
### New
|
|
52
|
-
|
|
53
|
-
```cpp
|
|
54
|
-
static Napi::Array Napi::Array::New(napi_env env, size_t length);
|
|
55
|
-
```
|
|
56
|
-
- `[in] env` - The environment in which to create the array.
|
|
57
|
-
- `[in] length` - The length of the array.
|
|
58
|
-
|
|
59
|
-
Returns a new `Napi::Array` with the given length.
|
|
60
|
-
|
|
61
|
-
If an error occurs, a `Napi::Error` will get thrown. If C++ exceptions are not
|
|
62
|
-
being used, callers should check the result of `Env::IsExceptionPending` before
|
|
63
|
-
attempting to use the returned value.
|
|
64
|
-
|
|
65
|
-
### Length
|
|
66
|
-
```cpp
|
|
67
|
-
uint32_t Napi::Array::Length() const;
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
Returns the length of the array.
|
|
71
|
-
|
|
72
|
-
Note:
|
|
73
|
-
This can execute JavaScript code implicitly according to JavaScript semantics.
|
|
74
|
-
If an error occurs, a `Napi::Error` will get thrown. If C++ exceptions are not
|
|
75
|
-
being used, callers should check the result of `Env::IsExceptionPending` before
|
|
76
|
-
attempting to use the returned value.
|
|
77
|
-
|
|
78
|
-
[`Napi::ArrayBuffer`]: ./array_buffer.md
|
|
79
|
-
[`Napi::Int32Array`]: ./typed_array_of.md
|
|
80
|
-
[`Napi::Object`]: ./object.md
|
|
81
|
-
[`Napi::TypedArray`]: ./typed_array.md
|
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
# ArrayBuffer
|
|
2
|
-
|
|
3
|
-
Class `Napi::ArrayBuffer` inherits from class [`Napi::Object`][].
|
|
4
|
-
|
|
5
|
-
The `Napi::ArrayBuffer` class corresponds to the
|
|
6
|
-
[JavaScript `ArrayBuffer`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer)
|
|
7
|
-
class.
|
|
8
|
-
|
|
9
|
-
## Methods
|
|
10
|
-
|
|
11
|
-
### New
|
|
12
|
-
|
|
13
|
-
Allocates a new `Napi::ArrayBuffer` instance with a given length.
|
|
14
|
-
|
|
15
|
-
```cpp
|
|
16
|
-
static Napi::ArrayBuffer Napi::ArrayBuffer::New(napi_env env, size_t byteLength);
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
- `[in] env`: The environment in which to create the `Napi::ArrayBuffer` instance.
|
|
20
|
-
- `[in] byteLength`: The length to be allocated, in bytes.
|
|
21
|
-
|
|
22
|
-
Returns a new `Napi::ArrayBuffer` instance.
|
|
23
|
-
|
|
24
|
-
### New
|
|
25
|
-
|
|
26
|
-
Wraps the provided external data into a new `Napi::ArrayBuffer` instance.
|
|
27
|
-
|
|
28
|
-
The `Napi::ArrayBuffer` instance does not assume ownership for the data and
|
|
29
|
-
expects it to be valid for the lifetime of the instance. Since the
|
|
30
|
-
`Napi::ArrayBuffer` is subject to garbage collection this overload is only
|
|
31
|
-
suitable for data which is static and never needs to be freed.
|
|
32
|
-
This factory method will not provide the caller with an opportunity to free the
|
|
33
|
-
data when the `Napi::ArrayBuffer` gets garbage-collected. If you need to free
|
|
34
|
-
the data retained by the `Napi::ArrayBuffer` object please use other
|
|
35
|
-
variants of the `Napi::ArrayBuffer::New` factory method that accept
|
|
36
|
-
`Napi::Finalizer`, which is a function that will be invoked when the
|
|
37
|
-
`Napi::ArrayBuffer` object has been destroyed.
|
|
38
|
-
|
|
39
|
-
```cpp
|
|
40
|
-
static Napi::ArrayBuffer Napi::ArrayBuffer::New(napi_env env, void* externalData, size_t byteLength);
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
- `[in] env`: The environment in which to create the `Napi::ArrayBuffer` instance.
|
|
44
|
-
- `[in] externalData`: The pointer to the external data to wrap.
|
|
45
|
-
- `[in] byteLength`: The length of the `externalData`, in bytes.
|
|
46
|
-
|
|
47
|
-
Returns a new `Napi::ArrayBuffer` instance.
|
|
48
|
-
|
|
49
|
-
### New
|
|
50
|
-
|
|
51
|
-
Wraps the provided external data into a new `Napi::ArrayBuffer` instance.
|
|
52
|
-
|
|
53
|
-
The `Napi::ArrayBuffer` instance does not assume ownership for the data and
|
|
54
|
-
expects it to be valid for the lifetime of the instance. The data can only be
|
|
55
|
-
freed once the `finalizeCallback` is invoked to indicate that the
|
|
56
|
-
`Napi::ArrayBuffer` has been released.
|
|
57
|
-
|
|
58
|
-
```cpp
|
|
59
|
-
template <typename Finalizer>
|
|
60
|
-
static Napi::ArrayBuffer Napi::ArrayBuffer::New(napi_env env,
|
|
61
|
-
void* externalData,
|
|
62
|
-
size_t byteLength,
|
|
63
|
-
Finalizer finalizeCallback);
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
- `[in] env`: The environment in which to create the `Napi::ArrayBuffer` instance.
|
|
67
|
-
- `[in] externalData`: The pointer to the external data to wrap.
|
|
68
|
-
- `[in] byteLength`: The length of the `externalData`, in bytes.
|
|
69
|
-
- `[in] finalizeCallback`: A function to be called when the `Napi::ArrayBuffer` is
|
|
70
|
-
destroyed. It must implement `operator()`, accept an Napi::Env, a `void*` (which is the
|
|
71
|
-
`externalData` pointer), and return `void`.
|
|
72
|
-
|
|
73
|
-
Returns a new `Napi::ArrayBuffer` instance.
|
|
74
|
-
|
|
75
|
-
### New
|
|
76
|
-
|
|
77
|
-
Wraps the provided external data into a new `Napi::ArrayBuffer` instance.
|
|
78
|
-
|
|
79
|
-
The `Napi::ArrayBuffer` instance does not assume ownership for the data and expects it
|
|
80
|
-
to be valid for the lifetime of the instance. The data can only be freed once
|
|
81
|
-
the `finalizeCallback` is invoked to indicate that the `Napi::ArrayBuffer` has been
|
|
82
|
-
released.
|
|
83
|
-
|
|
84
|
-
```cpp
|
|
85
|
-
template <typename Finalizer, typename Hint>
|
|
86
|
-
static Napi::ArrayBuffer Napi::ArrayBuffer::New(napi_env env,
|
|
87
|
-
void* externalData,
|
|
88
|
-
size_t byteLength,
|
|
89
|
-
Finalizer finalizeCallback,
|
|
90
|
-
Hint* finalizeHint);
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
- `[in] env`: The environment in which to create the `Napi::ArrayBuffer` instance.
|
|
94
|
-
- `[in] externalData`: The pointer to the external data to wrap.
|
|
95
|
-
- `[in] byteLength`: The length of the `externalData`, in bytes.
|
|
96
|
-
- `[in] finalizeCallback`: The function to be called when the `Napi::ArrayBuffer` is
|
|
97
|
-
destroyed. It must implement `operator()`, accept an Napi::Env, a `void*` (which is the
|
|
98
|
-
`externalData` pointer) and `Hint*`, and return `void`.
|
|
99
|
-
- `[in] finalizeHint`: The hint to be passed as the second parameter of the
|
|
100
|
-
finalize callback.
|
|
101
|
-
|
|
102
|
-
Returns a new `Napi::ArrayBuffer` instance.
|
|
103
|
-
|
|
104
|
-
### Constructor
|
|
105
|
-
|
|
106
|
-
Initializes an empty instance of the `Napi::ArrayBuffer` class.
|
|
107
|
-
|
|
108
|
-
```cpp
|
|
109
|
-
Napi::ArrayBuffer::ArrayBuffer();
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
### Constructor
|
|
113
|
-
|
|
114
|
-
Initializes a wrapper instance of an existing `Napi::ArrayBuffer` object.
|
|
115
|
-
|
|
116
|
-
```cpp
|
|
117
|
-
Napi::ArrayBuffer::ArrayBuffer(napi_env env, napi_value value);
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
- `[in] env`: The environment in which to create the `Napi::ArrayBuffer` instance.
|
|
121
|
-
- `[in] value`: The `Napi::ArrayBuffer` reference to wrap.
|
|
122
|
-
|
|
123
|
-
### ByteLength
|
|
124
|
-
|
|
125
|
-
```cpp
|
|
126
|
-
size_t Napi::ArrayBuffer::ByteLength() const;
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
Returns the length of the wrapped data, in bytes.
|
|
130
|
-
|
|
131
|
-
### Data
|
|
132
|
-
|
|
133
|
-
```cpp
|
|
134
|
-
void* Napi::ArrayBuffer::Data() const;
|
|
135
|
-
```
|
|
136
|
-
|
|
137
|
-
Returns a pointer the wrapped data.
|
|
138
|
-
|
|
139
|
-
### Detach
|
|
140
|
-
|
|
141
|
-
```cpp
|
|
142
|
-
void Napi::ArrayBuffer::Detach();
|
|
143
|
-
```
|
|
144
|
-
|
|
145
|
-
Invokes the `ArrayBuffer` detach operation on a detachable `ArrayBuffer`.
|
|
146
|
-
|
|
147
|
-
### IsDetached
|
|
148
|
-
|
|
149
|
-
```cpp
|
|
150
|
-
bool Napi::ArrayBuffer::IsDetached() const;
|
|
151
|
-
```
|
|
152
|
-
|
|
153
|
-
Returns `true` if this `ArrayBuffer` has been detached.
|
|
154
|
-
|
|
155
|
-
[`Napi::Object`]: ./object.md
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
# AsyncContext
|
|
2
|
-
|
|
3
|
-
The [Napi::AsyncWorker](async_worker.md) class may not be appropriate for every
|
|
4
|
-
scenario. When using any other async mechanism, introducing a new class
|
|
5
|
-
`Napi::AsyncContext` is necessary to ensure an async operation is properly
|
|
6
|
-
tracked by the runtime. The `Napi::AsyncContext` class can be passed to
|
|
7
|
-
[Napi::Function::MakeCallback()](function.md) method to properly restore the
|
|
8
|
-
correct async execution context.
|
|
9
|
-
|
|
10
|
-
## Methods
|
|
11
|
-
|
|
12
|
-
### Constructor
|
|
13
|
-
|
|
14
|
-
Creates a new `Napi::AsyncContext`.
|
|
15
|
-
|
|
16
|
-
```cpp
|
|
17
|
-
explicit Napi::AsyncContext::AsyncContext(napi_env env, const char* resource_name);
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
- `[in] env`: The environment in which to create the `Napi::AsyncContext`.
|
|
21
|
-
- `[in] resource_name`: Null-terminated strings that represents the
|
|
22
|
-
identifier for the kind of resource that is being provided for diagnostic
|
|
23
|
-
information exposed by the `async_hooks` API.
|
|
24
|
-
|
|
25
|
-
### Constructor
|
|
26
|
-
|
|
27
|
-
Creates a new `Napi::AsyncContext`.
|
|
28
|
-
|
|
29
|
-
```cpp
|
|
30
|
-
explicit Napi::AsyncContext::AsyncContext(napi_env env, const char* resource_name, const Napi::Object& resource);
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
- `[in] env`: The environment in which to create the `Napi::AsyncContext`.
|
|
34
|
-
- `[in] resource_name`: Null-terminated strings that represents the
|
|
35
|
-
identifier for the kind of resource that is being provided for diagnostic
|
|
36
|
-
information exposed by the `async_hooks` API.
|
|
37
|
-
- `[in] resource`: Object associated with the asynchronous operation that
|
|
38
|
-
will be passed to possible `async_hooks`.
|
|
39
|
-
|
|
40
|
-
### Destructor
|
|
41
|
-
|
|
42
|
-
The `Napi::AsyncContext` to be destroyed.
|
|
43
|
-
|
|
44
|
-
```cpp
|
|
45
|
-
virtual Napi::AsyncContext::~AsyncContext();
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
### Env
|
|
49
|
-
|
|
50
|
-
Requests the environment in which the async context has been initially created.
|
|
51
|
-
|
|
52
|
-
```cpp
|
|
53
|
-
Napi::Env Env() const;
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
Returns the `Napi::Env` environment in which the async context has been created.
|
|
57
|
-
|
|
58
|
-
## Operator
|
|
59
|
-
|
|
60
|
-
```cpp
|
|
61
|
-
Napi::AsyncContext::operator napi_async_context() const;
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
Returns the Node-API `napi_async_context` wrapped by the `Napi::AsyncContext`
|
|
65
|
-
object. This can be used to mix usage of the C Node-API and node-addon-api.
|
|
66
|
-
|
|
67
|
-
## Example
|
|
68
|
-
|
|
69
|
-
```cpp
|
|
70
|
-
#include "napi.h"
|
|
71
|
-
|
|
72
|
-
void MakeCallbackWithAsyncContext(const Napi::CallbackInfo& info) {
|
|
73
|
-
Napi::Function callback = info[0].As<Napi::Function>();
|
|
74
|
-
Napi::Object resource = info[1].As<Napi::Object>();
|
|
75
|
-
|
|
76
|
-
// Create a new async context instance.
|
|
77
|
-
Napi::AsyncContext context(info.Env(), "async_context_test", resource);
|
|
78
|
-
|
|
79
|
-
// Invoke the callback with the async context instance.
|
|
80
|
-
callback.MakeCallback(Napi::Object::New(info.Env()),
|
|
81
|
-
std::initializer_list<napi_value>{}, context);
|
|
82
|
-
|
|
83
|
-
// The async context instance is automatically destroyed here because it's
|
|
84
|
-
// block-scope like `Napi::HandleScope`.
|
|
85
|
-
}
|
|
86
|
-
```
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
# Asynchronous operations
|
|
2
|
-
|
|
3
|
-
Node.js native add-ons often need to execute long running tasks and to avoid
|
|
4
|
-
blocking the **event loop** they have to run them asynchronously from the
|
|
5
|
-
**event loop**.
|
|
6
|
-
In the Node.js model of execution the event loop thread represents the thread
|
|
7
|
-
where JavaScript code is executing. The Node.js guidance is to avoid blocking
|
|
8
|
-
other work queued on the event loop thread. Therefore, we need to do this work on
|
|
9
|
-
another thread.
|
|
10
|
-
|
|
11
|
-
All this means that native add-ons need to leverage async helpers from libuv as
|
|
12
|
-
part of their implementation. This allows them to schedule work to be executed
|
|
13
|
-
asynchronously so that their methods can return in advance of the work being
|
|
14
|
-
completed.
|
|
15
|
-
|
|
16
|
-
Node Addon API provides an interface to support functions that cover
|
|
17
|
-
the most common asynchronous use cases. There is an abstract classes to implement
|
|
18
|
-
asynchronous operations:
|
|
19
|
-
|
|
20
|
-
- **[`Napi::AsyncWorker`](async_worker.md)**
|
|
21
|
-
|
|
22
|
-
These class helps manage asynchronous operations through an abstraction
|
|
23
|
-
of the concept of moving data between the **event loop** and **worker threads**.
|
|
24
|
-
|
|
25
|
-
Also, the above class may not be appropriate for every scenario. When using any
|
|
26
|
-
other asynchronous mechanism, the following API is necessary to ensure an
|
|
27
|
-
asynchronous operation is properly tracked by the runtime:
|
|
28
|
-
|
|
29
|
-
- **[AsyncContext](async_context.md)**
|
|
30
|
-
|
|
31
|
-
- **[CallbackScope](callback_scope.md)**
|