From: Jérôme Benoit Date: Sun, 1 Oct 2023 09:27:17 +0000 (+0200) Subject: refactor: cleanup promise implementation X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=bcd364e02f04150362bd573ff124c1c6426b7718;p=benchmarks-js.git refactor: cleanup promise implementation Signed-off-by: Jérôme Benoit --- diff --git a/busy-wait.mjs b/busy-wait.mjs index 578e90c..5a55ef8 100644 --- a/busy-wait.mjs +++ b/busy-wait.mjs @@ -45,14 +45,14 @@ async function divideAndConquerTimeoutBusyWait ( * @param intervalMs */ async function setIntervalTimeoutBusyWait (timeoutMs, intervalMs = interval) { - return await new Promise(resolve => { + await new Promise(resolve => { const tries = Math.round(timeoutMs / intervalMs) let count = 0 const triesSetInterval = setInterval(() => { count++ if (count === tries) { clearInterval(triesSetInterval) - return resolve() + resolve() } }, intervalMs) }) diff --git a/promise-handling.mjs b/promise-handling.mjs index 97117f1..7f450b3 100644 --- a/promise-handling.mjs +++ b/promise-handling.mjs @@ -3,19 +3,12 @@ import Benchmark from 'benny' /** * */ -async function promise () { - return await new Promise(resolve => { +async function asyncFunction () { + await new Promise(resolve => { resolve() }) } -/** - * - */ -async function asyncFunction () { - return await promise() -} - Benchmark.suite( 'Promise handling', Benchmark.add('await promise', async () => {