D
D
dailysse2017-09-18 14:50:14
Node.js
dailysse, 2017-09-18 14:50:14

How to organize such a stream?

Hello. There is a code:

let spawn = require('child_process').spawn,
  fs    = require('fs'),
  stream = require('stream').Writable;

let a = new stream();
a._write = (chunk, encoding, done) => {

}

function test () {
  this.ls = spawn('Некая команда');
  return this.ls.stdin;
}

fs.createReadStream('test.file')
  .pipe(test())
  .pipe(a);

A certain process spawns, which receives data on stdin and should give it on stdout. So here's how to get data from the stdout of the process in this case and transfer it to the writable stream (variable a)

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question