build: bump volta pnpm version
[benchmarks-js.git] / promise-handling.mjs
index ffb42ff96861de27332160a9748cbecf1e8755da..1624bc2d18224946d95738bb0c2dac41109040bc 100644 (file)
@@ -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 () => {
@@ -27,12 +20,10 @@ Benchmark.suite(
   }),
   Benchmark.add('promise with then().catch()', () => {
     asyncFunction()
-      .then((r) => {
+      .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)