Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: lib/events.js

Issue 29375915: Issue 4878 - Start using ESLint for adblockpluscore (Closed)
Patch Set: Remove the arrow-parens rule Created March 9, 2017, 10:23 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: lib/events.js
diff --git a/lib/events.js b/lib/events.js
index 2f567ce25fd5b05481db7962735bcd2b3fb65767..417d09fdc0747614beccc0a5c4800643fc89a921 100644
--- a/lib/events.js
+++ b/lib/events.js
@@ -34,7 +34,7 @@ exports.EventEmitter.prototype = {
* @param {string} name
* @param {function} listener
*/
- on: function(name, listener)
+ on(name, listener)
{
if (name in this._listeners)
this._listeners[name].push(listener);
@@ -48,7 +48,7 @@ exports.EventEmitter.prototype = {
* @param {string} name
* @param {function} listener
*/
- off: function(name, listener)
+ off(name, listener)
{
let listeners = this._listeners[name];
if (listeners)
@@ -62,10 +62,10 @@ exports.EventEmitter.prototype = {
/**
* Adds a one time listener and returns a promise that
* is resolved the next time the specified event is emitted.
- *
+ * @param {string} name
* @return {Promise}
*/
- once: function(name)
+ once(name)
{
return new Promise(resolve =>
{
@@ -85,7 +85,7 @@ exports.EventEmitter.prototype = {
* @param {string} name
* @return {function[]}
*/
- listeners: function(name)
+ listeners(name)
{
let listeners = this._listeners[name];
return listeners ? listeners.slice() : [];
@@ -97,14 +97,10 @@ exports.EventEmitter.prototype = {
* @param {string} name
* @param {...*} [arg]
*/
- emit: function(name)
+ emit(name, ...args)
{
- let args = [];
- for (let i = 1; i < arguments.length; i++)
- args.push(arguments[i]);
-
let listeners = this.listeners(name);
for (let listener of listeners)
- listener.apply(null, args);
+ listener(...args);
}
};
« no previous file with comments | « lib/elemHideEmulation.js ('k') | lib/filterClasses.js » ('j') | lib/filterNotifier.js » ('J')

Powered by Google App Engine
This is Rietveld