| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 9c29ac6 commit f11291a
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -65,7 +65,32 @@ Resumes the incoming `'data'` events after a `pause()`. | |||
| 65 | 65 | ||
| 66 | 66 | Closes the underlying file descriptor. Stream will not emit any more events. | |
| 67 | 67 | ||
| 68 | + ### stream.pipe(destination, [options]) | ||
| 68 | 69 | ||
| 70 | + This is a `Stream.prototype` method available on all `Stream`s. | ||
| 71 | + | ||
| 72 | + Connects this read stream to `destination` WriteStream. Incoming | ||
| 73 | + data on this stream gets written to `destination`. The destination and source | ||
| 74 | + streams are kept in sync by pausing and resuming as necessary. | ||
| 75 | + | ||
| 76 | + Emulating the Unix `cat` command: | ||
| 77 | + | ||
| 78 | + process.openStdin().pipe(process.stdout); | ||
| 79 | + | ||
| 80 | + | ||
| 81 | + By default `end()` is called on the destination when the source stream emits | ||
| 82 | + `end`, so that `destination` is no longer writable. Pass `{ end: false }` as | ||
| 83 | + `options` to keep the destination stream open. | ||
| 84 | + | ||
| 85 | + This keeps `process.stdout` open so that "Goodbye" can be written at the end. | ||
| 86 | + | ||
| 87 | + var stdin = process.openStdin(); | ||
| 88 | + stdin.pipe(process.stdout, { end: false }); | ||
| 89 | + stdin.on("end", function() { process.stdout.write("Goodbye\n"); }); | ||
| 90 | + | ||
| 91 | + NOTE: If the source stream does not support `pause()` and `resume()`, this function | ||
| 92 | + adds simple definitions which simply emit `'pause'` and `'resume'` events on | ||
| 93 | + the source stream. | ||
| 69 | 94 | ||
| 70 | 95 | ## Writable Stream | |
| 71 | 96 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments