【问题标题】:how pipe() will performing read and write operations in node js?pipe() 将如何在节点 js 中执行读写操作?
【发布时间】:2017-07-03 15:12:48
【问题描述】:
var fs = require("fs");

var readStream= fs.createReadStream('input.txt');

var writeStream=fs.createWriteStream('output.txt');

readStream.pipe(writeStream);

console.log("hello...world");

在上面的程序中,readStreamwriteStream的操作是通过管道函数完成的。pipe()中发生的内部代码和内部过程是什么?

【问题讨论】:

    标签: stream pipe chain node.js-stream


    【解决方案1】:

    管道将像 nodejs 中的桥梁一样执行。 在这里评论:https://nodejs.org/api/stream.html#stream_event_pipe

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-11-22
      相关资源
      最近更新 更多