From 4247cbbd3c312d34802d06ca303be866cbc987ad Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Sun, 17 Sep 2023 14:09:55 +0200 Subject: [PATCH] refactor: code cleanup MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- busy-wait.mjs | 2 +- promise-handling.mjs | 4 ++-- quick-select.mjs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/busy-wait.mjs b/busy-wait.mjs index dd8a74f..578e90c 100644 --- a/busy-wait.mjs +++ b/busy-wait.mjs @@ -45,7 +45,7 @@ async function divideAndConquerTimeoutBusyWait ( * @param intervalMs */ async function setIntervalTimeoutBusyWait (timeoutMs, intervalMs = interval) { - return new Promise(resolve => { + return await new Promise(resolve => { const tries = Math.round(timeoutMs / intervalMs) let count = 0 const triesSetInterval = setInterval(() => { diff --git a/promise-handling.mjs b/promise-handling.mjs index b3b0210..97117f1 100644 --- a/promise-handling.mjs +++ b/promise-handling.mjs @@ -3,8 +3,8 @@ import Benchmark from 'benny' /** * */ -function promise () { - return new Promise(resolve => { +async function promise () { + return await new Promise(resolve => { resolve() }) } diff --git a/quick-select.mjs b/quick-select.mjs index 3823448..6e5706d 100644 --- a/quick-select.mjs +++ b/quick-select.mjs @@ -25,8 +25,8 @@ const tasksMap = generateRandomTasksMap(60, 20) * @returns */ function loopSelect (tasksMap) { - let minValue = Infinity let minKey + let minValue = Infinity for (const [key, value] of tasksMap) { if (value === 0) { return key -- 2.34.1