admin管理员组文章数量:1389812
I got a quick question. I want to save the value (string) of this statement:
process.stdout.write(d);
in a variable. But all my attempts failed so how is it done?
res.on('data', (d) => {
process.stdout.write(d);
});
I got a quick question. I want to save the value (string) of this statement:
process.stdout.write(d);
in a variable. But all my attempts failed so how is it done?
res.on('data', (d) => {
process.stdout.write(d);
});
Share
Improve this question
edited Jan 27, 2020 at 13:42
Ygg
3,8801 gold badge18 silver badges23 bronze badges
asked Jan 27, 2020 at 12:38
OberDulli94OberDulli94
1872 silver badges11 bronze badges
1 Answer
Reset to default 7You can do it like this
var str = "";
res.on('data', (d) => {
str+=d;
}).on('end',()=>{
console.log(str);
});
Here we append the data d
we get from stream, we append it to str
variable & the print the str
once the stream pletes reading
本文标签: javascriptNodejs processstdoutwrite() to variableStack Overflow
版权声明:本文标题:javascript - Nodejs process.stdout.write() to variable - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744668763a2618695.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论