docs/api/module.md
Napa.js follows Node.js' convention to support modules, that means:
.node for addons, Napa.JS searches .napa.But there are also differences:
uv functionalities, thus built-ins and core modules have its own implementation. To write async function in addon, methods DoAsyncWork/PostAsyncWork are introduced to work for both Napa.js and Node.js.A quick glance at NPM will reveal that most modules are pure JavaScript. These are only a few reasons that you may want to create a C++ module.
This post gives a good introduction on creating a JavaScript module. For creating a Napa.JS C++ module, please refer to the API section or checkout examples in the quick reference section.
| Description | Transportable | Example code |
|---|---|---|
| Standard JavaScript module | Blog post | |
| Share JavaScript object across isolates | X |
| Description | ObjectWrap | Transportable | Async function | Example code |
|---|---|---|---|---|
| Export JavaScript function only | hello-world [.md .cpp test] | |||
| Export JavaScript object (ObjectWrap) | X | plus-number [.md .cpp test] | ||
| Share C++ object across isolates | X | X | allocator-wrap [.h .cpp] | |
| Export asynchronous JavaScript function | X | X | async-number [.md .cpp test] |
See API reference.
TBD
TBD
TBD
TBD
TBD
TBD