2 static async
waitExits (pool
, numberOfExitEventsToWait
) {
4 return new Promise(resolve
=> {
5 pool
.workers
.forEach(w
=> {
8 if (exitEvents
=== numberOfExitEventsToWait
) {
16 static async
sleep (ms
) {
17 return new Promise(resolve
=> setTimeout(resolve
, ms
))
20 static async
workerSleepFunction (
26 return new Promise((resolve
, reject
) => {
30 ? reject(new Error(rejectionMessage
))
37 static jsonIntegerSerialization (n
) {
38 for (let i
= 0; i
< n
; i
++) {
47 * Intentionally inefficient implementation.
49 * @param {number} n - The number of fibonacci numbers to generate.
50 * @returns {number} - The nth fibonacci number.
52 static fibonacci (n
) {
54 return TestUtils
.fibonacci(n
- 1) + TestUtils
.fibonacci(n
- 2)
58 * Intentionally inefficient implementation.
60 * @param {number} n - The number to calculate the factorial of.
61 * @returns {number} - The factorial of n.
63 static factorial (n
) {
67 return TestUtils
.factorial(n
- 1) * n
72 module
.exports
= TestUtils