https://github.com/doowb/iterator-streams
Iterate over a stack of streams.
https://github.com/doowb/iterator-streams
Last synced: about 1 month ago
JSON representation
Iterate over a stack of streams.
- Host: GitHub
- URL: https://github.com/doowb/iterator-streams
- Owner: doowb
- License: mit
- Created: 2015-06-13T18:15:08.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2015-10-16T03:03:56.000Z (over 9 years ago)
- Last Synced: 2025-02-25T23:35:29.491Z (about 2 months ago)
- Language: JavaScript
- Homepage:
- Size: 555 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# iterator-streams [](http://badge.fury.io/js/iterator-streams) [](https://travis-ci.org/doowb/iterator-streams)
> Iterate over a stack of streams.
This module is intended to be used with [loader-cache](https://github.com/jonschlinkert/loader-cache)but may be used by itself or in other modules.
Install with [npm](https://www.npmjs.com/)
```sh
$ npm i iterator-streams --save
```## Usage
```js
var iterator = require('iterator-streams');
```## API
### [iterator](index.js#L20)
Iterate over a stack of streams piping the results of
each steram to the next stream in the stack.**Params**
* `stack` **{Array}**: Array of streams to use.
* `returns` **{Function}**: Returns a function that will iterator over the given stack of streams.```js
var fs = require('fs');
var iterator = require('iterator-streams');
var through = require('through2');var stack = [
through.obj(function (fp, enc, cb) { this.push(fs.readFileSync(fp, 'utf8')); cb(); }),
through.obj(function (contents, enc, cb) { this.push(JSON.parse(contents)); cb(); })
];
var readJSON = iterator(stack);
readJSON('./package.json')
.on('data', console.log);
```## Related projects
* [event-stream](http://github.com/dominictarr/event-stream): construct pipes of streams of events
* [iterator-async](https://github.com/doowb/iterator-async): Iterate over a stack of async functions.
* [iterator-promise](https://github.com/doowb/iterator-promise): Iterator over a stack of functions.
* [iterator-sync](https://github.com/doowb/iterator-sync): Iterator over a stack of functions.
* [loader-cache](https://github.com/jonschlinkert/loader-cache): Register loader functions that dynamically read, parse or otherwise transform file contents when the name… [more](https://github.com/jonschlinkert/loader-cache)
* [through2](https://github.com/rvagg/through2#readme): A tiny wrapper around Node streams2 Transform to avoid explicit subclassing noise## Running tests
Install dev dependencies:
```sh
$ npm i -d && npm test
```## Contributing
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/doowb/iterator-streams/issues/new)
## Author
**Brian Woodward**
+ [github/doowb](https://github.com/doowb)
+ [twitter/doowb](http://twitter.com/doowb)## License
Copyright © 2015 [Brian Woodward](https://github.com/doowb)
Released under the MIT license.***
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on June 17, 2015._