@@ -102,10 +102,10 @@ Module::Global::Shared Module::Global::Instance() {
102102 return instance;
103103}
104104
105- Module::Module (Napi::Object exports) : MsgTrash(exports.Env() ) {
106- exports.Set (" version" , zmq::Version (exports. Env () ));
107- exports.Set (" capability" , zmq::Capabilities (exports. Env () ));
108- exports.Set (" curveKeyPair" , Napi::Function::New (exports. Env () , zmq::CurveKeyPair));
105+ Module::Module (Napi::Env env, Napi:: Object exports) : MsgTrash(env ) {
106+ exports.Set (" version" , zmq::Version (env ));
107+ exports.Set (" capability" , zmq::Capabilities (env ));
108+ exports.Set (" curveKeyPair" , Napi::Function::New (env , zmq::CurveKeyPair));
109109
110110 Context::Initialize (*this , exports);
111111 Socket::Initialize (*this , exports);
@@ -117,13 +117,5 @@ Module::Module(Napi::Object exports) : MsgTrash(exports.Env()) {
117117}
118118} // namespace zmq
119119
120- /* This initializer can be called in multiple contexts, like worker threads. */
121- NAPI_MODULE_INIT (/* env, exports */ ) {
122- auto * module = new zmq::Module (Napi::Object (env, exports));
123- auto terminate = [](void * data) { delete reinterpret_cast <zmq::Module*>(data); };
124-
125- /* Tear down the module class when the env/agent/thread is closed.*/
126- [[maybe_unused]] auto status = napi_add_env_cleanup_hook (env, terminate, module );
127- assert (status == napi_ok);
128- return exports;
129- }
120+ using Module = zmq::Module;
121+ NODE_API_ADDON (Module)
0 commit comments