Node is working towards a unified data stream interface.
- One argument, a
Buffer
orString
object
- received EOF or FIN
- does not mean any buffered data has been flushed
- emitted with exception object
- does not close stream
- suggestion
stopRead()
- this is advisory, it does not insure that you will not receive data events
- suggestion
startRead()
- close the underlying file descriptor
- suggestion
close()
- boolean
Examples of readable streams (some of these don't exist yet): server-side HTTP request, client-side HTTP response, process.stdin
, childProcess.stdout
, childProcess.stderr
- Returns
true
if it could be flushed to kernel,false
if not. Data is always queued for writing, even if flushing is not possible. If this method returnsfalse
then the event'drain'
will be emitted later, once all data that was buffered has been written to the kernel.
- Writes EOF or a FIN packet on the transport once the existing data buffer is drained. Further calls to
write()
after calling this method will throw an error. - suggestion
end()
- emitted with exception object
- does not close stream
- boolean
Examples of writable streams (some of these don't exist yet): server-side HTTP response, client-side HTTP request, process.stdout
, process.stderr
, childProcess.stdin
Stream.pipe proxies events from a readable stream (readableStream) argument and a a writable stream (readableStream) and interprets a few behaviors from the events.
- The subject of a "data" event on a readableStream is sent to the write() method of the writableStream.
- When writeableStream.write(data) returns false readableStream will be paused until the drain event occurs on the writableStream. If there is not "pause()" method one is added that will emit("pause").
- When a "pause" event is observed on writableStream a "pause" event is emitted on the readableStream.
- When a "resume" event is observed on writableStream a "resume" event is emitted on the readableStream.
Why not move this to the node wiki?