Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

1.3K
Views
cluster module to interact with child processes (workers)

Please help In this exercise, you will use the cluster module to interact with child processes (workers).

A worker has been implemented at workerPath. It uses CPU-heavy computing logic. The worker is waiting for the input message from the primary cluster process. It then calculates the result, returns it, and exits.

Your goal is to implement the asynchronous function doCalculations(inputs, workerPath) that sends inputs to the worker and returns the calculation results.

  • inputs is a list containing the string input(s) to be sent.
  • workerPath is a string representing the path to the worker file.
  • Your function should return a Promise object that resolves to an array of results.
  • The calculations should run in parallel.
  • The order between the inputs and outputs should be preserved.
// JavaScript code below
const cluster = require("cluster");
/** 
* 
* @param {string[]} inputs 
* @param {string} workerPath 
* @returns {Promise<Array<string | number>} calculation results returned from workers 
*/
async function doCalculations(inputs, workerPath = "/tmp/deps/worker") {    
  // Your code goes here    
  const result = []; // = calculate(inputs)    
  return result;
}
doCalculations(['hello', 'world']).then(console.log).catch(console.error)
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!