Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/thlorenz/nest-stream
Stream that allows nesting another stream for each value of the outer stream and streams the flattened result.
https://github.com/thlorenz/nest-stream
Last synced: 26 days ago
JSON representation
Stream that allows nesting another stream for each value of the outer stream and streams the flattened result.
- Host: GitHub
- URL: https://github.com/thlorenz/nest-stream
- Owner: thlorenz
- License: mit
- Created: 2013-08-17T21:09:13.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2013-08-18T01:30:49.000Z (over 11 years ago)
- Last Synced: 2024-11-15T04:44:08.797Z (about 2 months ago)
- Language: JavaScript
- Homepage:
- Size: 129 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# nest-stream [![build status](https://secure.travis-ci.org/thlorenz/nest-stream.png)](http://travis-ci.org/thlorenz/nest-stream)
[![testling badge](https://ci.testling.com/thlorenz/nest-stream.png)](https://ci.testling.com/thlorenz/nest-stream)
Stream that allows nesting another stream for each value of the outer stream and streams the flattened result.
```js
'use strict';var nestStream = require('nest-stream')
, through = require('through')
, from = require('from');var stream = nestStream(getInnerStream);
function getInnerStream (outerVal) {
return from([1 + outerVal, 3 + outerVal, 4 + outerVal, 5 + outerVal])
}function stringify (data) {
this.queue(data + ' ');
}from([10, 20, 30, 40])
.pipe(stream)
.pipe(through(stringify))
.on('end', function () { console.error('ended') })
.pipe(process.stdout);// => 11 13 14 15 21 23 24 25 31 33 34 35 41 43 44 45 ended
```[more examples](https://github.com/thlorenz/nest-stream/tree/master/examples)
## Installation
npm install nest-stream
## API
### *nestStream(getInnerStream[, sep])*
```
/**
* Streams values resulting from all the inner streams generated from the values of the outer stream.
*
* @name exports
* @function
* @param getInnerStream {Function} function (outerValue) { .. } that returns a stream generated from the provided value
* @param sep {Object} (optional)
* any non-null object to serve as a separator between values queued for one value piped by the outer stream
* default: ''
* @return {Stream} that queues a value for each value provided by either of the inner streams
*/
```## License
MIT