Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/thlorenz/floodgate
Throttles a stream to pass one value per given interval.
https://github.com/thlorenz/floodgate
Last synced: 2 months ago
JSON representation
Throttles a stream to pass one value per given interval.
- Host: GitHub
- URL: https://github.com/thlorenz/floodgate
- Owner: thlorenz
- License: mit
- Created: 2013-09-15T22:08:14.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2013-12-03T20:20:48.000Z (about 11 years ago)
- Last Synced: 2024-10-18T01:49:17.520Z (2 months ago)
- Language: JavaScript
- Homepage:
- Size: 159 KB
- Stars: 16
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# floodgate [![build status](https://secure.travis-ci.org/thlorenz/floodgate.png)](http://travis-ci.org/thlorenz/floodgate)
Throttles a stream to pass one value per given interval.
```js
var floodgate = require('floodgate');var gate = floodgate({ interval: 200 });
gate.pipe(process.stdout);'hello world'.split('').forEach(gate.write.bind(gate));
```![demo](https://github.com/thlorenz/floodgate/raw/master/assets/floodgate.gif)
## Installation
npm install floodgate
## API
### *floodgate(opts)*
```
/**
* Creates a transform stream that will delay passing values through according to the given interval.
*
* Note:
* Passing and interval of 0 is useful in order to keep any streams in your pipe chain from blocking the
* event loop.
*
* @name Floodgate
* @function
* @param opts {Object} typical TransformStream options (like highWaterMark) and one additional:
* - interval: the interval at which to time out passing through values
* @return {TransformStream} stream that can be added to a pipe in order to delay values coming through
*/
```## Similar modules
- [throttle](https://github.com/TooTallNate/node-throttle) passes data through at `n` bytes per second
## License
MIT