add more event methods
This commit is contained in:
parent
b6a7936344
commit
59dc5dc5df
13
.npmignore
13
.npmignore
|
@ -1,11 +1,14 @@
|
|||
.idea
|
||||
*.log
|
||||
.cproject
|
||||
.project
|
||||
.lock-wscript
|
||||
.DS_Store
|
||||
.eslintrc
|
||||
.gitignore
|
||||
.idea
|
||||
.lock-wscript
|
||||
.project
|
||||
CPPLINT.cfg
|
||||
Debug
|
||||
examples
|
||||
node_modules
|
||||
package-lock.json
|
||||
*.log
|
||||
.gitignore
|
||||
test
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
set noparent
|
||||
linelength=110
|
||||
filter=-legal/copyright
|
||||
filter=-build/include_order
|
||||
filter=-build/header_guard
|
||||
filter=-build/namespaces
|
||||
filter=-build/include_what_you_use
|
||||
filter=-whitespace/blank_line
|
||||
filter=-whitespace/comments
|
||||
filter=-whitespace/tab
|
||||
filter=-whitespace/end_of_line
|
||||
filter=-whitespace/indent
|
||||
filter=-readability/todo
|
|
@ -57,16 +57,19 @@ public:
|
|||
// -------- dynamic
|
||||
|
||||
Nan::SetPrototypeMethod(proto, "listenerCount", jsListenerCount);
|
||||
Nan::SetPrototypeMethod(proto, "addEventListener", jsAddListener);
|
||||
Nan::SetPrototypeMethod(proto, "addListener", jsAddListener);
|
||||
Nan::SetPrototypeMethod(proto, "dispatchEvent", jsDispatchEvent);
|
||||
Nan::SetPrototypeMethod(proto, "emit", jsEmit);
|
||||
Nan::SetPrototypeMethod(proto, "eventNames", jsEventNames);
|
||||
Nan::SetPrototypeMethod(proto, "getMaxListeners", jsGetMaxListeners);
|
||||
Nan::SetPrototypeMethod(proto, "listeners", jsListeners);
|
||||
Nan::SetPrototypeMethod(proto, "on", jsOn);
|
||||
Nan::SetPrototypeMethod(proto, "once", jsOnce);
|
||||
Nan::SetPrototypeMethod(proto, "on", jsAddListener);
|
||||
Nan::SetPrototypeMethod(proto, "once", jsAddListener);
|
||||
Nan::SetPrototypeMethod(proto, "prependListener", jsPrependListener);
|
||||
Nan::SetPrototypeMethod(proto, "prependOnceListener", jsPrependOnceListener);
|
||||
Nan::SetPrototypeMethod(proto, "removeAllListeners", jsRemoveAllListeners);
|
||||
Nan::SetPrototypeMethod(proto, "removeEventListener", jsRemoveListener);
|
||||
Nan::SetPrototypeMethod(proto, "removeListener", jsRemoveListener);
|
||||
Nan::SetPrototypeMethod(proto, "setMaxListeners", jsSetMaxListeners);
|
||||
Nan::SetPrototypeMethod(proto, "rawListeners", jsRawListeners);
|
||||
|
@ -199,6 +202,23 @@ private:
|
|||
static NAN_METHOD(jsAddListener) { _wrapListener(info); }
|
||||
|
||||
|
||||
static NAN_METHOD(jsDispatchEvent) { THIS_EVENT_EMITTER;
|
||||
|
||||
REQ_OBJ_ARG(0, event);
|
||||
|
||||
if (!event->Has(JS_STR("type"))) {
|
||||
return Nan::ThrowError("Event must have the `type` property.");
|
||||
}
|
||||
|
||||
Nan::Utf8String name(event->Get(JS_STR("type")));
|
||||
|
||||
V8_VAR_VAL args = event;
|
||||
|
||||
eventEmitter->emit(*name, 1, &args);
|
||||
|
||||
}
|
||||
|
||||
|
||||
static NAN_METHOD(jsEmit) { THIS_EVENT_EMITTER;
|
||||
|
||||
REQ_UTF8_ARG(0, name);
|
||||
|
@ -416,8 +436,6 @@ private:
|
|||
}
|
||||
|
||||
|
||||
static NAN_METHOD(jsOn) { _wrapListener(info); }
|
||||
|
||||
static NAN_METHOD(jsOnce) { _wrapOnceListener(info); }
|
||||
|
||||
static NAN_METHOD(jsPrependListener) { _wrapListener(info, true); }
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "addon-tools-raub",
|
||||
"version": "0.1.5",
|
||||
"version": "0.1.6",
|
||||
"author": "Luis Blanco <raubtierxxx@gmail.com>",
|
||||
"description": "A set of extra tools for Node.js addons",
|
||||
"main": "index.js",
|
||||
|
|
Loading…
Reference in New Issue