Why isn't concat-stream working with process.stdin.pipe()?

本秂侑毒 提交于 2021-02-20 10:22:46

问题


Here's my code:

var concat = require('concat-stream');
process.stdin.pipe(concat(function(){console.log("output")}));

What I'm expecting this to do is output "output" every time I enter input into the console, but this doesn't work. Does anyone have an idea why this isn't working? If I do a fs.createReadStream() buffer, it works fine, just not with process.stdin.pipe(). I've used process.stdin.pipe() for other things though, and they worked fine.

Thanks in advance!


回答1:


The reason you get no output is because you're not actually closing stdin, which is what concat-stream is looking for so that it knows no more data is coming.



来源:https://stackoverflow.com/questions/25225158/why-isnt-concat-stream-working-with-process-stdin-pipe

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!