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

128
Views
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
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!