mirror of
https://github.com/electron/electron.git
synced 2026-05-02 03:00:22 -04:00
refactor: use Date.now() instead of +new Date() (#38901)
refactor: use Date.now()
This commit is contained in:
@@ -141,11 +141,11 @@ export async function repeatedly<T> (
|
||||
opts?: { until?: (x: T) => boolean, timeLimit?: number }
|
||||
) {
|
||||
const { until = (x: T) => !!x, timeLimit = 10000 } = opts ?? {};
|
||||
const begin = +new Date();
|
||||
const begin = Date.now();
|
||||
while (true) {
|
||||
const ret = await fn();
|
||||
if (until(ret)) { return ret; }
|
||||
if (+new Date() - begin > timeLimit) { throw new Error(`repeatedly timed out (limit=${timeLimit})`); }
|
||||
if (Date.now() - begin > timeLimit) { throw new Error(`repeatedly timed out (limit=${timeLimit})`); }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user