mirror of https://github.com/nodejs/node.git
EventEmitter#once only takes instanceof function
parent
52b9ede6db
commit
a4dad95be3
|
@ -137,6 +137,10 @@ EventEmitter.prototype.addListener = function(type, listener) {
|
|||
EventEmitter.prototype.on = EventEmitter.prototype.addListener;
|
||||
|
||||
EventEmitter.prototype.once = function(type, listener) {
|
||||
if ('function' !== typeof listener) {
|
||||
throw new Error('.once only takes instances of Function');
|
||||
}
|
||||
|
||||
var self = this;
|
||||
self.on(type, function g() {
|
||||
self.removeListener(type, g);
|
||||
|
|
Loading…
Reference in New Issue