https://github.com/commenthol/streamss-cat
Concatenate stream2 streams to one stream
https://github.com/commenthol/streamss-cat
Last synced: 8 months ago
JSON representation
Concatenate stream2 streams to one stream
- Host: GitHub
- URL: https://github.com/commenthol/streamss-cat
- Owner: commenthol
- License: mit
- Created: 2015-01-09T19:02:29.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2021-10-10T05:37:58.000Z (over 4 years ago)
- Last Synced: 2025-01-09T11:38:30.847Z (over 1 year ago)
- Language: JavaScript
- Size: 18.6 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# streamss-cat
> Concatenate stream2 streams to one stream
[](https://www.npmjs.com/package/streamss-cat/)
[](https://travis-ci.org/commenthol/streamss-cat)
Concatenate streams to behave like one [Readable][] Stream. This is a pure Stream2 implementation which respects also a very high number of input streams (>1000).
Works with node v0.8.x and greater.
For node v0.8.x the user-land copy [readable-stream][] is used.
For all other node versions greater v0.8.x the built-in `stream` module is used.
Credits go to [stream-cat][].
### Examples
**Join two streams:**
```js
let Through = require('streamss').Through;
let cat = require('streamss-cat');
let stream1 = new Through();
let stream2 = new Through();
cat(stream1, stream2).pipe(process.stdout);
//cat([stream1, stream2]).pipe(process.stdout); //< alternatively
stream1.end('hello ');
stream2.end('world');
```
**Join thousand fs streams with allocating the resources on runtime:**
```js
let fs = require('fs');
let cat = require('../');
let streams = [];
function fnStream() {
return fs.createReadStream(__filename);
}
for (let i=0; i<1000; i++) {
streams.push(fnStream);
}
cat(streams).pipe(process.stdout);
```
## Methods
### cat(streams)
> Concatenate Streams to a readable stream
**Parameters:**
- `{Readable} streams` - Array of Readable Streams or Array of Functions returning Readable Streams
**Return:**
`{Readable}` A readable stream
## Contribution and License Agreement
If you contribute code to this project, you are implicitly allowing your
code to be distributed under the MIT license. You are also implicitly
verifying that all code is your original work or correctly attributed
with the source of its origin and licence.
### npm scripts
* `npm test` - Run tests
* `npm run cover` - Run istanbul code coverage (shows code coverage; open `./coverage/lcov-report/index.html` after run)
* `npm run lint` - Linting the source
* `npm run doc` - Generate documentation from source (open `./doc/index.html` after run)
## License
Copyright (c) 2015 commenthol (MIT License)
See [LICENSE][] for more info.
[LICENSE]: ./LICENSE
[stream-cat]: https://github.com/micnews/stream-cat
[Readable]: http://nodejs.org/api/stream.html#stream_class_stream_readable
[readable-stream]: https://github.com/isaacs/readable-stream