| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 8f48e77 commit 844a156
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1841,8 +1841,8 @@ napi_value Init(napi_env env, napi_value exports) { | |||
| 1841 | 1841 | } | |
| 1842 | 1842 | ``` | |
| 1843 | 1843 | ||
| 1844 | - If the module will be loaded multiple times during the lifetime of the Node.js | ||
| 1845 | - process, use the `NAPI_MODULE_INIT` macro to initialize the module: | ||
| 1844 | + You can also use the `NAPI_MODULE_INIT` macro, which acts as a shorthand | ||
| 1845 | + for `NAPI_MODULE` and defining an `Init` function: | ||
| 1846 | 1846 | ||
| 1847 | 1847 | ```c | |
| 1848 | 1848 | NAPI_MODULE_INIT() { | |
@@ -1859,13 +1859,9 @@ NAPI_MODULE_INIT() { | |||
| 1859 | 1859 | } | |
| 1860 | 1860 | ``` | |
| 1861 | 1861 | ||
| 1862 | - This macro includes `NAPI_MODULE`, and declares an `Init` function with a | ||
| 1863 | - special name and with visibility beyond the addon. This will allow Node.js to | ||
| 1864 | - initialize the module even if it is loaded multiple times. | ||
| 1865 | - | ||
| 1866 | - There are a few design considerations when declaring a module that may be loaded | ||
| 1867 | - multiple times. The documentation of [context-aware addons][] provides more | ||
| 1868 | - details. | ||
| 1862 | + All N-API addons are context-aware, meaning they may be loaded multiple | ||
| 1863 | + times. There are a few design considerations when declaring such a module. | ||
| 1864 | + The documentation on [context-aware addons][] provides more details. | ||
| 1869 | 1865 | ||
| 1870 | 1866 | The variables `env` and `exports` will be available inside the function body | |
| 1871 | 1867 | following the macro invocation. | |
| Back | FazBrowse Home | New Git URL |
0 commit comments