Merge pull request #123 from jerome-benoit/dependabot/npm_and_yarn/commitlint/config...
[benchmarks-js.git] / max.mjs
diff --git a/max.mjs b/max.mjs
index de7602ea57f669bb7f8c00539074fe92712cb62d..0b1ec9f93528bed64c39bf82435a689223d2f3f7 100644 (file)
--- a/max.mjs
+++ b/max.mjs
@@ -1,5 +1,5 @@
 import Benchmark from 'benny'
-import { generateRandomNumberArray } from './benchmark-utils.js'
+import { generateRandomNumberArray } from './benchmark-utils.mjs'
 
 const size = 10000
 const testArray = generateRandomNumberArray(size)
@@ -10,11 +10,11 @@ const testArray = generateRandomNumberArray(size)
  * @returns
  */
 function loopMax (values) {
-  let max = -Infinity
+  let maximum = -Infinity
   for (const value of values) {
-    if (value > max) max = value
+    if (value > maximum) maximum = value
   }
-  return max
+  return maximum
 }
 
 /**
@@ -23,7 +23,10 @@ function loopMax (values) {
  * @returns
  */
 function reduceTernaryMax (values) {
-  return values.reduce((a, b) => (a > b ? a : b), -Infinity)
+  return values.reduce(
+    (maximum, num) => (maximum > num ? maximum : num),
+    -Infinity
+  )
 }
 
 /**
@@ -32,7 +35,7 @@ function reduceTernaryMax (values) {
  * @returns
  */
 function reduceMathMax (values) {
-  return values.reduce((a, b) => Math.max(a, b), -Infinity)
+  return values.reduce((maximum, num) => Math.max(maximum, num), -Infinity)
 }
 
 /**
@@ -66,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)