Index: lib/events.js |
diff --git a/lib/events.js b/lib/events.js |
index 3e9067a2b1bfe88ccace767b19ded6fdc42c5be1..cf6baf0dfd4e37b226bcdd6ed1c8925b4390accd 100644 |
--- a/lib/events.js |
+++ b/lib/events.js |
@@ -24,7 +24,7 @@ |
*/ |
exports.EventEmitter = function() |
{ |
- this._listeners = Object.create(null); |
+ this._listeners = new Map(); |
}; |
exports.EventEmitter.prototype = { |
@@ -36,10 +36,11 @@ exports.EventEmitter.prototype = { |
*/ |
on(name, listener) |
{ |
- if (name in this._listeners) |
- this._listeners[name].push(listener); |
+ let listeners = this._listeners.get(name); |
+ if (listeners) |
+ listeners.push(listener); |
else |
- this._listeners[name] = [listener]; |
+ this._listeners.set(name, [listener]); |
}, |
/** |
@@ -50,7 +51,7 @@ exports.EventEmitter.prototype = { |
*/ |
off(name, listener) |
{ |
- let listeners = this._listeners[name]; |
+ let listeners = this._listeners.get(name); |
if (listeners) |
{ |
let idx = listeners.indexOf(listener); |
@@ -87,7 +88,7 @@ exports.EventEmitter.prototype = { |
*/ |
listeners(name) |
{ |
- let listeners = this._listeners[name]; |
+ let listeners = this._listeners.get(name); |
return listeners ? listeners.slice() : []; |
}, |