X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=promise-handling.mjs;h=1624bc2d18224946d95738bb0c2dac41109040bc;hb=bfca901b58dc85e442e433ff3ba67c4850ff4af5;hp=97117f19d9a086733a9bad0b0d32d9097e850be9;hpb=4247cbbd3c312d34802d06ca303be866cbc987ad;p=benchmarks-js.git diff --git a/promise-handling.mjs b/promise-handling.mjs index 97117f1..1624bc2 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 () => { @@ -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)