[Pkg-mozext-commits] [adblock-plus] 55/87: Issue 3862 - Added EventEmitter.listeners()

David Prévot taffit at moszumanska.debian.org
Sat Apr 30 17:59:08 UTC 2016


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository adblock-plus.

commit b41e40c1e1638888755df19d1c62e446e0e5427a
Author: Sebastian Noack <sebastian at adblockplus.org>
Date:   Thu Mar 24 12:02:44 2016 +0100

    Issue 3862 - Added EventEmitter.listeners()
---
 lib/events.js | 28 ++++++++++++++++++----------
 1 file changed, 18 insertions(+), 10 deletions(-)

diff --git a/lib/events.js b/lib/events.js
index a72575a..2f567ce 100644
--- a/lib/events.js
+++ b/lib/events.js
@@ -80,6 +80,18 @@ exports.EventEmitter.prototype = {
   },
 
   /**
+   * Returns a copy of the array of listeners for the specified event.
+   *
+   * @param {string} name
+   * @return {function[]}
+   */
+  listeners: function(name)
+  {
+    let listeners = this._listeners[name];
+    return listeners ? listeners.slice() : [];
+  },
+
+  /**
    * Calls all previously added listeners for the given event name.
    *
    * @param {string} name
@@ -87,16 +99,12 @@ exports.EventEmitter.prototype = {
    */
   emit: function(name)
   {
-    let listeners = this._listeners[name];
-    if (listeners)
-    {
-      let args = [];
-      for (let i = 1; i < arguments.length; i++)
-        args.push(arguments[i]);
+    let args = [];
+    for (let i = 1; i < arguments.length; i++)
+      args.push(arguments[i]);
 
-      let currentListeners = listeners.slice();
-      for (let listener of currentListeners)
-        listener.apply(null, args);
-    }
+    let listeners = this.listeners(name);
+    for (let listener of listeners)
+      listener.apply(null, args);
   }
 };

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/adblock-plus.git



More information about the Pkg-mozext-commits mailing list