From 4aa2893a787119ef9b3957e82539fee4fad4f98f Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Mon, 4 Dec 2023 13:40:48 +0100 Subject: [PATCH] refactor: cleanup promises handling code MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- busy-wait.mjs | 4 +--- deep-clone-object.mjs | 4 +--- deep-merge-object.mjs | 4 +--- empty-array.mjs | 4 +--- fibonacci.mjs | 4 +--- is-empty-object.mjs | 4 +--- is-undefined.mjs | 4 +--- max.mjs | 4 +--- min.mjs | 4 +--- promise-handling.mjs | 8 ++------ quick-select.mjs | 4 +--- random.mjs | 4 +--- shallow-clone-object.mjs | 4 +--- uuid-generator.mjs | 4 +--- 14 files changed, 15 insertions(+), 45 deletions(-) diff --git a/busy-wait.mjs b/busy-wait.mjs index 5a55ef8..eeef8fe 100644 --- a/busy-wait.mjs +++ b/busy-wait.mjs @@ -77,6 +77,4 @@ Benchmark.suite( Benchmark.save({ file: 'busy-wait', format: 'json', details: true }), Benchmark.save({ file: 'busy-wait', format: 'chart.html', details: true }), Benchmark.save({ file: 'busy-wait', format: 'table.html', details: true }) -).catch(err => { - console.error(err) -}) +).catch(console.error) diff --git a/deep-clone-object.mjs b/deep-clone-object.mjs index 8206cd9..bd8b3e6 100644 --- a/deep-clone-object.mjs +++ b/deep-clone-object.mjs @@ -41,6 +41,4 @@ Benchmark.suite( format: 'table.html', details: true }) -).catch(err => { - console.error(err) -}) +).catch(console.error) diff --git a/deep-merge-object.mjs b/deep-merge-object.mjs index cce9345..fe1440f 100644 --- a/deep-merge-object.mjs +++ b/deep-merge-object.mjs @@ -38,6 +38,4 @@ Benchmark.suite( format: 'table.html', details: true }) -).catch(err => { - console.error(err) -}) +).catch(console.error) diff --git a/empty-array.mjs b/empty-array.mjs index 12abb24..3c46e35 100644 --- a/empty-array.mjs +++ b/empty-array.mjs @@ -30,6 +30,4 @@ Benchmark.suite( Benchmark.save({ file: 'empty-array', format: 'json', details: true }), Benchmark.save({ file: 'empty-array', format: 'chart.html', details: true }), Benchmark.save({ file: 'empty-array', format: 'table.html', details: true }) -).catch(err => { - console.error(err) -}) +).catch(console.error) diff --git a/fibonacci.mjs b/fibonacci.mjs index 00130ce..3929b4d 100644 --- a/fibonacci.mjs +++ b/fibonacci.mjs @@ -76,6 +76,4 @@ Benchmark.suite( Benchmark.save({ file: 'fibonacci', format: 'json', details: true }), Benchmark.save({ file: 'fibonacci', format: 'chart.html', details: true }), Benchmark.save({ file: 'fibonacci', format: 'table.html', details: true }) -).catch(err => { - console.error(err) -}) +).catch(console.error) diff --git a/is-empty-object.mjs b/is-empty-object.mjs index b4ba3cb..e9b42f7 100644 --- a/is-empty-object.mjs +++ b/is-empty-object.mjs @@ -36,6 +36,4 @@ Benchmark.suite( format: 'table.html', details: true }) -).catch(err => { - console.error(err) -}) +).catch(console.error) diff --git a/is-undefined.mjs b/is-undefined.mjs index a04113b..b720507 100644 --- a/is-undefined.mjs +++ b/is-undefined.mjs @@ -25,6 +25,4 @@ Benchmark.suite( format: 'table.html', details: true }) -).catch(err => { - console.error(err) -}) +).catch(console.error) diff --git a/max.mjs b/max.mjs index 60fcdea..0b1ec9f 100644 --- a/max.mjs +++ b/max.mjs @@ -69,6 +69,4 @@ Benchmark.suite( Benchmark.save({ file: 'max', format: 'json', details: true }), Benchmark.save({ file: 'max', format: 'chart.html', details: true }), Benchmark.save({ file: 'max', format: 'table.html', details: true }) -).catch(err => { - console.error(err) -}) +).catch(console.error) diff --git a/min.mjs b/min.mjs index 2561820..834076c 100644 --- a/min.mjs +++ b/min.mjs @@ -69,6 +69,4 @@ Benchmark.suite( Benchmark.save({ file: 'min', format: 'json', details: true }), Benchmark.save({ file: 'min', format: 'chart.html', details: true }), Benchmark.save({ file: 'min', format: 'table.html', details: true }) -).catch(err => { - console.error(err) -}) +).catch(console.error) diff --git a/promise-handling.mjs b/promise-handling.mjs index 7f450b3..1624bc2 100644 --- a/promise-handling.mjs +++ b/promise-handling.mjs @@ -23,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 @@ -51,6 +49,4 @@ Benchmark.suite( format: 'table.html', details: true }) -).catch(err => { - console.error(err) -}) +).catch(console.error) diff --git a/quick-select.mjs b/quick-select.mjs index 6e5706d..efbb9b7 100644 --- a/quick-select.mjs +++ b/quick-select.mjs @@ -264,6 +264,4 @@ Benchmark.suite( format: 'table.html', details: true }) -).catch(err => { - console.error(err) -}) +).catch(console.error) diff --git a/random.mjs b/random.mjs index 70d48c0..16037df 100644 --- a/random.mjs +++ b/random.mjs @@ -100,6 +100,4 @@ Benchmark.suite( format: 'table.html', details: true }) -).catch(err => { - console.error(err) -}) +).catch(console.error) diff --git a/shallow-clone-object.mjs b/shallow-clone-object.mjs index 830a386..51ee172 100644 --- a/shallow-clone-object.mjs +++ b/shallow-clone-object.mjs @@ -33,6 +33,4 @@ Benchmark.suite( format: 'table.html', details: true }) -).catch(err => { - console.error(err) -}) +).catch(console.error) diff --git a/uuid-generator.mjs b/uuid-generator.mjs index 6ed8015..325abcb 100644 --- a/uuid-generator.mjs +++ b/uuid-generator.mjs @@ -27,6 +27,4 @@ Benchmark.suite( format: 'table.html', details: true }) -).catch(err => { - console.error(err) -}) +).catch(console.error) -- 2.34.1