Use object assign
This commit is contained in:
parent
0564af1e96
commit
6bdcf9abe2
|
@ -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<Napi::Function>();
|
||||
|
||||
std::vector<napi_value> 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
5
index.js
5
index.js
|
@ -1,6 +1,3 @@
|
|||
'use strict';
|
||||
|
||||
module.exports = {
|
||||
...require('./include'),
|
||||
...require('./utils'),
|
||||
};
|
||||
module.exports = Object.assign({}, require('./include'), require('./utils'));
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
'use strict';
|
||||
|
||||
|
||||
module.exports = {
|
||||
...require('./action-zip'),
|
||||
...require('./cpbin'),
|
||||
...require('./download'),
|
||||
...require('./files'),
|
||||
...require('./install'),
|
||||
...require('./writable-buffer'),
|
||||
};
|
||||
module.exports = Object.assign(
|
||||
{},
|
||||
require('./action-zip'),
|
||||
require('./cpbin'),
|
||||
require('./download'),
|
||||
require('./files'),
|
||||
require('./install'),
|
||||
require('./writable-buffer'),
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue