Node.js . , , .
5 : Readable, Writable, Duplex, Transform PassThrough.
, :
- , .push(). , (null).
- , "".
- , "" , "read()" , null.
- , , () ' , , push() false. , , . "HighWaterMark" ( ) .
- _read(), , . . push, . , , read(), , _read(), .
Writable
- , .write(). , .end().
- .end(), . process.nextTick(), ! .
- . (highWaterMark), false, .write(). , . , , - "", , .
- _write() - . false, Writable , _write() , "".
Readable Writable Streams
- ONE . , streamA.pipe(streamB).pipe(streamC) "... .. , streamA. streamC. streamB ( ) - , Transform.
- 1: . .
- 2: , , . . _write().
, , - . ? : ,
Duplex
- . ( ), . , Writable.
- 1: "streamA.pipe(duplexB).pipe(streamC)" , Readable streamA _read() duplexB _write(). streamC. , , duplexB_read(), streamC. , , streamA streamC.
- 2: .push(null) .end() . , "" "". . end() .push(null)?
. , , , , , "link-stream", _read _write. streamA streamC , "finish" "end", . .
Transform
- -
- write() _write , _read()
- this.push(...) _read , _transform()
- _transform(). _transform. , , , , , _transform()
- _transform, , .
, . , Joyent Duplex , , PassThrough, link-stream, .
!