/**
*
*/
-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 () => {
}),
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
format: 'table.html',
details: true
})
-).catch((err) => {
- console.error(err)
-})
+).catch(console.error)