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

131
Vistas
node.js send data in async from function to function

I'm going to create a node repl that works within a node.

The run function is a function that returns the output value when the code to be put in the repl is passed over to the factor.

Is there a way to transfer data from a write function to a run function while the run function is running?

const repl = require('repl');
const { Readable, Writable } = require('stream');

const readable = new Readable({
    read(size) {
        return true;
    }
});
const writable = new Writable({
    write(chunk, encoding, callback) {
        const value = chunk.toString();
        if (value === "") {
            // todo : send data to function run
        } else {
            // todo : stack data for function run
        }
        console.log(chunk);
        callback();
    }
});

repl.start({
    prompt: "",
    input: readable,
    output: writable
});

async function run(code) {
    readable.push(code);
    // todo 
}

run("setTimeout(() => {console.log('test')}, 1000);\n");

exports.run = run;
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