stream-connect
Similar to .pipe
except .pipe
returns the last stream in a pipeline. stream-connect returns a stream which writes to the first stream in the pipeline and reads from the last.
Synopsis
const connect = const fs = const connected = // data piped into the connected stream is transparently passed through all four internal streams// then output into process.stdout. Errors in any of the internal streams are emitted// by the connected stream.processstdin
More detail
Consider this .pipe
example.
{ ... return streamOne}const stream = stream // catches data from streamOne via streamTwostream // catches errors only from streamTwostream // is written to streamTwo
If you write to the output it will be written to streamTwo
, whereas you probably wanted to write to the start of the pipeline and read from the end. Fixed by stream-connect:
const connect = { ... return }const stream = stream // catches data from streamOne via streamTwostream // catches errors from both streamOne and streamTwostream // is written to streamOne
Any errors emitted in streamOne
or streamTwo
are propagated to the output stream.
stream-connect
Example
const connect =
Duplex
⏏
connect(...streams) ⇒ Connect streams.
Kind: Exported function
Param | Type | Description |
---|---|---|
...streams | Duplex |
One or more streams to connect. |
© 2015 Lloyd Brookes <75pound@gmail.com>. Documented by jsdoc-to-markdown.