mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-22 16:18:08 +02:00
Change the LoopbackPort
class to use a Set internally
This is a tiny bit more compact, thanks to the `Set.prototype.delete` method.
This commit is contained in:
parent
ff3b9ccf6e
commit
9d29abdfa0
1 changed files with 4 additions and 5 deletions
|
@ -1909,7 +1909,7 @@ class PDFPageProxy {
|
|||
}
|
||||
|
||||
class LoopbackPort {
|
||||
#listeners = [];
|
||||
#listeners = new Set();
|
||||
|
||||
#deferred = Promise.resolve();
|
||||
|
||||
|
@ -1926,16 +1926,15 @@ class LoopbackPort {
|
|||
}
|
||||
|
||||
addEventListener(name, listener) {
|
||||
this.#listeners.push(listener);
|
||||
this.#listeners.add(listener);
|
||||
}
|
||||
|
||||
removeEventListener(name, listener) {
|
||||
const i = this.#listeners.indexOf(listener);
|
||||
this.#listeners.splice(i, 1);
|
||||
this.#listeners.delete(listener);
|
||||
}
|
||||
|
||||
terminate() {
|
||||
this.#listeners.length = 0;
|
||||
this.#listeners.clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue