-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathmodule.cpp
More file actions
45 lines (37 loc) · 1.68 KB
/
module.cpp
File metadata and controls
45 lines (37 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include "object_async/hello_async.hpp"
#include "object_sync/hello.hpp"
#include "standalone/hello.hpp"
#include "standalone_async/hello_async.hpp"
#include "standalone_promise/hello_promise.hpp"
#include <napi.h>
// #include "your_code.hpp"
Napi::Object init(Napi::Env env, Napi::Object exports)
{
// expose hello method
exports.Set(Napi::String::New(env, "hello"), Napi::Function::New(env, standalone::hello));
// expose helloAsync method
exports.Set(Napi::String::New(env, "helloAsync"), Napi::Function::New(env, standalone_async::helloAsync));
// expose helloPromise method
exports.Set(Napi::String::New(env, "helloPromise"), Napi::Function::New(env, standalone_promise::helloPromise));
// expose HelloObject class
object_sync::HelloObject::Init(env, exports);
// expose HelloObjectAsync class
object_async::HelloObjectAsync::Init(env, exports);
return exports;
/**
* You may have noticed there are multiple "hello" functions as part of this
* module.
* They are exposed a bit differently.
* 1) standalone::hello // exposed above
* 2) HelloObject.hello // exposed in object_sync/hello.cpp as part of
* HelloObject
*/
// add more methods/classes below that youd like to use in Javascript world
// then create a directory in /src with a .cpp and a .hpp file.
// Include your .hpp file at the top of this file.
}
// Initialize the module (we only do this once)
// Mark this NOLINT to avoid the clang-tidy checks
// NODE_GYP_MODULE_NAME is the name of our module as defined in 'target_name'
// variable in the 'binding.gyp', which is passed along as a compiler define
NODE_API_MODULE(NODE_GYP_MODULE_NAME, init) // NOLINT