Use object assign
This commit is contained in:
parent
0564af1e96
commit
6bdcf9abe2
|
@ -14,7 +14,7 @@
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#define DBG_EXPORT __declspec(dllexport)
|
#define DBG_EXPORT __declspec(dllexport)
|
||||||
#else
|
#else
|
||||||
#define DBG_EXPORT __attribute__((visibility("default")))
|
#define DBG_EXPORT
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define NAPI_ENV Napi::Env env = info.Env();
|
#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(
|
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,
|
Napi::Object that,
|
||||||
const std::string &name,
|
const std::string &name,
|
||||||
int argc = 0,
|
int argc = 0,
|
||||||
|
@ -520,7 +495,11 @@ inline void eventEmitAsync(
|
||||||
args.push_back(napi_value(argv[i]));
|
args.push_back(napi_value(argv[i]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (context) {
|
||||||
thatEmit.MakeCallback(that, args, context);
|
thatEmit.MakeCallback(that, args, context);
|
||||||
|
} else {
|
||||||
|
thatEmit.Call(that, args);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
5
index.js
5
index.js
|
@ -1,6 +1,3 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
module.exports = {
|
module.exports = Object.assign({}, require('./include'), require('./utils'));
|
||||||
...require('./include'),
|
|
||||||
...require('./utils'),
|
|
||||||
};
|
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = Object.assign(
|
||||||
...require('./action-zip'),
|
{},
|
||||||
...require('./cpbin'),
|
require('./action-zip'),
|
||||||
...require('./download'),
|
require('./cpbin'),
|
||||||
...require('./files'),
|
require('./download'),
|
||||||
...require('./install'),
|
require('./files'),
|
||||||
...require('./writable-buffer'),
|
require('./install'),
|
||||||
};
|
require('./writable-buffer'),
|
||||||
|
);
|
||||||
|
|
Loading…
Reference in New Issue