流的类型
【Types of streams】
Node.js 中有四种基本的流类型:
【There are four fundamental stream types within Node.js:】
Writable:可以写入数据的流(例如,fs.createWriteStream())。Readable:可以从中读取数据的流(例如,fs.createReadStream())。Duplex:既是Readable又是Writable的流(例如,net.Socket)。Transform:可以在写入和读取数据时修改或转换数据的“Duplex”流(例如,zlib.createDeflate())。
此外,该模块还包括实用函数 stream.duplexPair()、stream.pipeline()、stream.finished()、stream.Readable.from() 和 stream.addAbortSignal()。
【Additionally, this module includes the utility functions
stream.duplexPair(),
stream.pipeline(),
stream.finished()
stream.Readable.from(), and
stream.addAbortSignal().】