I am trying to receive data via stdin which I have working:
const fs = require('fs');
const readStream = process.stdin;
readStream.pause();
readStream.setEncoding('utf8');
readStream.on('data', (data) => {
console.log(data);
});
readStream.resume();
Now what I need to do is store it as a variable so I can do some calculations before I return it via stdout.
Every time I try to so anything with it, like push certain data to an array it repeats the data until the stdin has finished, and I cant access it after it has finished. I cant find any resources online to help me.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…