Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 /* | 1 /* |
2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
3 * Copyright (C) 2006-present eyeo GmbH | 3 * Copyright (C) 2006-present eyeo GmbH |
4 * | 4 * |
5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
8 * | 8 * |
9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
55 { | 55 { |
56 let idx = listeners.indexOf(listener); | 56 let idx = listeners.indexOf(listener); |
57 if (idx != -1) | 57 if (idx != -1) |
58 listeners.splice(idx, 1); | 58 listeners.splice(idx, 1); |
59 } | 59 } |
60 } | 60 } |
61 | 61 |
62 /** | 62 /** |
63 * Adds a one time listener and returns a promise that | 63 * Adds a one time listener and returns a promise that |
64 * is resolved the next time the specified event is emitted. | 64 * is resolved the next time the specified event is emitted. |
65 * | |
65 * @param {string} name | 66 * @param {string} name |
Manish Jethani
2018/08/17 03:07:21
Can we also insert a blank line here before @param
Jon Sonesen
2018/08/17 17:26:24
Acknowledged.
| |
66 * @returns {Promise} | 67 * @returns {Promise} |
67 */ | 68 */ |
68 once(name) | 69 once(name) |
69 { | 70 { |
70 return new Promise(resolve => | 71 return new Promise(resolve => |
71 { | 72 { |
72 let listener = () => | 73 let listener = () => |
73 { | 74 { |
74 this.off(name, listener); | 75 this.off(name, listener); |
75 resolve(); | 76 resolve(); |
(...skipping 12 matching lines...) Expand all Loading... | |
88 listeners(name) | 89 listeners(name) |
89 { | 90 { |
90 let listeners = this._listeners.get(name); | 91 let listeners = this._listeners.get(name); |
91 return listeners ? listeners.slice() : []; | 92 return listeners ? listeners.slice() : []; |
92 } | 93 } |
93 | 94 |
94 /** | 95 /** |
95 * Calls all previously added listeners for the given event name. | 96 * Calls all previously added listeners for the given event name. |
96 * | 97 * |
97 * @param {string} name | 98 * @param {string} name |
98 * @param {args} [arg] | 99 * @param {...*} [args] |
99 */ | 100 */ |
100 emit(name, ...args) | 101 emit(name, ...args) |
101 { | 102 { |
102 let listeners = this.listeners(name); | 103 let listeners = this.listeners(name); |
103 for (let listener of listeners) | 104 for (let listener of listeners) |
104 listener(...args); | 105 listener(...args); |
105 } | 106 } |
106 } | 107 } |
107 | 108 |
108 exports.EventEmitter = EventEmitter; | 109 exports.EventEmitter = EventEmitter; |
LEFT | RIGHT |