Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

1.3K
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda