+/**
+ * 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
+ }
+}
+
+function executeWorkerFunction (data) {
+ switch (data.function) {
+ case WorkerFunctions.jsonIntegerSerialization:
+ return jsonIntegerSerialization(data.n || 1000)
+ case WorkerFunctions.fibonacci:
+ return fibonacci(data.n || 50)
+ case WorkerFunctions.factorial:
+ return factorial(data.n || 1000)
+ default:
+ throw new Error('Unknown worker function')
+ }
+}
+
+const LIST_FORMATTER = new Intl.ListFormat('en-US', {
+ style: 'long',
+ type: 'conjunction'
+})
+
+module.exports = {
+ LIST_FORMATTER,
+ WorkerFunctions,
+ executeWorkerFunction,
+ generateRandomInteger,
+ runPoolifierTest
+}