Add eslint report to sonar
[poolifier.git] / benchmarks / internal / benchmark-utils.js
index 5f0c643b0c189a9d6d232deae5e8c0effe9cbae8..7cb4e54f500283d5c5da6e69b743f5b851ba344e 100644 (file)
@@ -11,7 +11,10 @@ async function runPoolifierTest (pool, { tasks, workerData }) {
           }
           return null
         })
-        .catch(err => console.error(err))
+        .catch(err => {
+          console.error(err)
+          return reject(err)
+        })
     }
   })
 }
@@ -37,14 +40,28 @@ function generateRandomInteger (max, min = 0) {
 /**
  * Intentionally inefficient implementation.
  *
- * @param {*} n
- * @returns {number}
+ * @param {number} n - The number of fibonacci numbers to generate.
+ * @returns {number} - The nth fibonacci number.
  */
 function fibonacci (n) {
   if (n <= 1) return 1
   return fibonacci(n - 1) + fibonacci(n - 2)
 }
 
+/**
+ * Intentionally inefficient implementation.
+ *
+ * @param {number} n - The number to calculate the factorial of.
+ * @returns {number} - The factorial of n.
+ */
+function factorial (n) {
+  if (n === 0) {
+    return 1
+  } else {
+    return factorial(n - 1) * n
+  }
+}
+
 const LIST_FORMATTER = new Intl.ListFormat('en-US', {
   style: 'long',
   type: 'conjunction'
@@ -55,5 +72,6 @@ module.exports = {
   jsonIntegerSerialization,
   generateRandomInteger,
   fibonacci,
+  factorial,
   LIST_FORMATTER
 }