diff --git a/include/addon-tools.hpp b/include/addon-tools.hpp index f5054ef..3ecfcca 100644 --- a/include/addon-tools.hpp +++ b/include/addon-tools.hpp @@ -14,7 +14,7 @@ #ifdef _WIN32 #define DBG_EXPORT __declspec(dllexport) #else -#define DBG_EXPORT __attribute__((visibility("default"))) +#define DBG_EXPORT #endif #define NAPI_ENV Napi::Env env = info.Env(); @@ -474,31 +474,6 @@ inline Napi::Value consoleLog(Napi::Env env, const std::string &message) { inline void eventEmit( - Napi::Object that, - const std::string &name, - int argc = 0, - const Napi::Value *argv = nullptr -) { - if (!that.Has("emit")) { - return; - } - - Napi::Env env = that.Env(); - - Napi::String eventName = JS_STR(name); - Napi::Function thatEmit = that.Get("emit").As(); - - std::vector args; - args.push_back(napi_value(eventName)); - for (int i = 0; i < argc; i++) { - args.push_back(napi_value(argv[i])); - } - - thatEmit.Call(that, args); -} - - -inline void eventEmitAsync( Napi::Object that, const std::string &name, int argc = 0, @@ -520,7 +495,11 @@ inline void eventEmitAsync( args.push_back(napi_value(argv[i])); } - thatEmit.MakeCallback(that, args, context); + if (context) { + thatEmit.MakeCallback(that, args, context); + } else { + thatEmit.Call(that, args); + } } diff --git a/index.js b/index.js index 65f6a68..3a67a1d 100644 --- a/index.js +++ b/index.js @@ -1,6 +1,3 @@ 'use strict'; -module.exports = { - ...require('./include'), - ...require('./utils'), -}; +module.exports = Object.assign({}, require('./include'), require('./utils')); diff --git a/utils/index.js b/utils/index.js index 8051af5..8d00f0f 100644 --- a/utils/index.js +++ b/utils/index.js @@ -1,11 +1,12 @@ 'use strict'; -module.exports = { - ...require('./action-zip'), - ...require('./cpbin'), - ...require('./download'), - ...require('./files'), - ...require('./install'), - ...require('./writable-buffer'), -}; \ No newline at end of file +module.exports = Object.assign( + {}, + require('./action-zip'), + require('./cpbin'), + require('./download'), + require('./files'), + require('./install'), + require('./writable-buffer'), +);