X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=promise-handling.mjs;h=1624bc2d18224946d95738bb0c2dac41109040bc;hb=a02cd9a6491a825e13c1ac19f41d09f8f5981f5e;hp=b3b02107c9cfc793a7c3149db013236df206b8bb;hpb=f913c68ce1ad111704f1f319706cb99e9659e236;p=benchmarks-js.git diff --git a/promise-handling.mjs b/promise-handling.mjs index b3b0210..1624bc2 100644 --- a/promise-handling.mjs +++ b/promise-handling.mjs @@ -3,19 +3,12 @@ import Benchmark from 'benny' /** * */ -function promise () { - return 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 () => { @@ -30,9 +23,7 @@ Benchmark.suite( .then(r => { return r }) - .catch(e => { - console.error(e) - }) + .catch(console.error) }), Benchmark.add('voided promise', () => { // eslint-disable-next-line no-void @@ -58,6 +49,4 @@ Benchmark.suite( format: 'table.html', details: true }) -).catch(err => { - console.error(err) -}) +).catch(console.error)