better function test in addEventListener
This commit is contained in:
parent
61308a5bff
commit
ac9d9f4e9f
@ -110,8 +110,8 @@ var eventsModule = createInternalModule('events', function (exports) {
|
|||||||
// process.EventEmitter is defined in src/node_events.cc
|
// process.EventEmitter is defined in src/node_events.cc
|
||||||
// process.EventEmitter.prototype.emit() is also defined there.
|
// process.EventEmitter.prototype.emit() is also defined there.
|
||||||
process.EventEmitter.prototype.addListener = function (type, listener) {
|
process.EventEmitter.prototype.addListener = function (type, listener) {
|
||||||
if (!(listener instanceof Function)) {
|
if (typeof listener != 'function') {
|
||||||
throw new Error('addListener only takes instances of Function');
|
throw new Error('addListener only takes functions');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this._events) this._events = {};
|
if (!this._events) this._events = {};
|
||||||
@ -135,8 +135,8 @@ var eventsModule = createInternalModule('events', function (exports) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
process.EventEmitter.prototype.removeListener = function (type, listener) {
|
process.EventEmitter.prototype.removeListener = function (type, listener) {
|
||||||
if (!(listener instanceof Function)) {
|
if (typeof listener != 'function') {
|
||||||
throw new Error('removeListener only takes instances of Function');
|
throw new Error('removeListener only takes functions');
|
||||||
}
|
}
|
||||||
|
|
||||||
// does not use listeners(), so no side effect of creating _events[type]
|
// does not use listeners(), so no side effect of creating _events[type]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user