Add eslint report to sonar
[poolifier.git] / benchmarks / internal / benchmark-utils.js
index 6c9e23aab93f8b239d2e4505f7e30aa9bf81a16a..7cb4e54f500283d5c5da6e69b743f5b851ba344e 100644 (file)
@@ -40,14 +40,28 @@ function generateRandomInteger (max, min = 0) {
 /**
  * Intentionally inefficient implementation.
  *
- * @param {number} 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'
@@ -58,5 +72,6 @@ module.exports = {
   jsonIntegerSerialization,
   generateRandomInteger,
   fibonacci,
+  factorial,
   LIST_FORMATTER
 }