Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zoubin/stream-tap
pause or resume a node stream pipeline
https://github.com/zoubin/stream-tap
Last synced: 8 days ago
JSON representation
pause or resume a node stream pipeline
- Host: GitHub
- URL: https://github.com/zoubin/stream-tap
- Owner: zoubin
- Created: 2015-05-22T03:41:51.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-05-22T07:39:38.000Z (over 9 years ago)
- Last Synced: 2024-10-12T18:49:28.039Z (about 1 month ago)
- Language: JavaScript
- Size: 133 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# stream-tap
To control (pause or resume) a node stream pipeline. It returns a transform which is supposed to be included into a stream pipeline.## Usage
```javascript
var Tap = require('stream-tap');
var tap = Tap();
```### tap = Tap()
Return the tap transform.### tap.turnOn()
`tap` will push no data, until `tap.turnOn()` is called.### tap.turnOff()
Make `tap` collect data, and wait for `tap.turnOn` to flush.## Example
```javascript
var Tap = require('stream-tap');
var thr = require('through2');var s1 = thr();
var s2 = thr();
var tap = Tap();s1.pipe(tap).pipe(s2).pipe(process.stdout);
process.stdout.write('Writing into the pipeline\n');
[1,2,3,4,5].map(String).forEach(s1.write, s1);
s1.end();
process.stdout.write('Writing end\n');
setTimeout(function() {
process.stdout.write('turn tap on\n');
tap.turnOn();
}, 50);
```output:
```
⌘ node example/tap.js
Writing into the pipeline
Writing end
turn tap on
12345
```