tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 6932a8b1522574fe94295457fb6e505511cded5e
parent 41ac6522ff08f93a2de46495a673d7fa22e24520
Author: Lorenz A <me@lorenzackermann.xyz>
Date:   Mon, 15 Dec 2025 13:02:51 +0000

Bug 2004263 - [devtools] Turn devtools/client/netmonitor/src/middleware/batching.js into an ES class. r=devtools-reviewers,bomsy

Differential Revision: https://phabricator.services.mozilla.com/D276356

Diffstat:
Mdevtools/client/netmonitor/src/middleware/batching.js | 42+++++++++++++++++++++---------------------
1 file changed, 21 insertions(+), 21 deletions(-)

diff --git a/devtools/client/netmonitor/src/middleware/batching.js b/devtools/client/netmonitor/src/middleware/batching.js @@ -98,28 +98,28 @@ function batchingMiddleware() { /** * Create a delayed task that calls the specified task function after a delay. */ -function DelayedTask(taskFn, delay) { - this._promise = new Promise((resolve, reject) => { - this.runTask = cancel => { - if (cancel) { - reject("Task cancelled"); - } else { - taskFn(); - resolve(); - } - this.runTask = null; - }; - this.timeout = setTimeout(this.runTask, delay); - }).catch(console.error); -} - -DelayedTask.prototype = { +class DelayedTask { + #promise; + constructor(taskFn, delay) { + this.#promise = new Promise((resolve, reject) => { + this.runTask = cancel => { + if (cancel) { + reject("Task cancelled"); + } else { + taskFn(); + resolve(); + } + this.runTask = null; + }; + this.timeout = setTimeout(this.runTask, delay); + }).catch(console.error); + } /** * Return a promise that is resolved after the task is performed or canceled. */ get promise() { - return this._promise; - }, + return this.#promise; + } /** * Cancel the execution of the task. @@ -129,7 +129,7 @@ DelayedTask.prototype = { if (this.runTask) { this.runTask(true); } - }, + } /** * Execute the scheduled task immediately, without waiting for the timeout. @@ -140,7 +140,7 @@ DelayedTask.prototype = { if (this.runTask) { this.runTask(); } - }, -}; + } +} module.exports = batchingMiddleware;