流的类型
Node.js 中有四种基本的流类型:
Writable
: 可以写入数据的流(例如,fs.createWriteStream()
)。Readable
: 可以从中读取数据的流(例如,fs.createReadStream()
)。Duplex
:Readable
和Writable
的流(例如,net.Socket
)。Transform
: 可以在写入和读取数据时修改或转换数据的Duplex
流(例如,zlib.createDeflate()
)。
此外,此模块还包括实用函数 stream.pipeline()
、stream.finished()
、和 stream.Readable.from()
。
There are four fundamental stream types within Node.js:
Writable
: streams to which data can be written (for example,fs.createWriteStream()
).Readable
: streams from which data can be read (for example,fs.createReadStream()
).Duplex
: streams that are bothReadable
andWritable
(for example,net.Socket
).Transform
:Duplex
streams that can modify or transform the data as it is written and read (for example,zlib.createDeflate()
).
Additionally, this module includes the utility functions
stream.pipeline()
, stream.finished()
and
stream.Readable.from()
.