Gathering detailed insights and metrics for combined-stream2
Gathering detailed insights and metrics for combined-stream2
Gathering detailed insights and metrics for combined-stream2
Gathering detailed insights and metrics for combined-stream2
npm install combined-stream2
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
11 Stars
13 Commits
4 Forks
3 Watching
1 Branches
2 Contributors
Updated on 02 Mar 2022
JavaScript (54.37%)
CoffeeScript (45.63%)
Cumulative downloads
Total Downloads
Last day
5.7%
2,640
Compared to previous day
Last week
27.2%
17,105
Compared to previous week
Last month
13.1%
65,575
Compared to previous month
Last year
-16%
718,524
Compared to previous year
A drop-in Streams2-compatible replacement for the combined-stream
module.
Supports most of the combined-stream
API. Automatically wraps Streams1 streams, so that they work as well.
Both Promises and nodebacks are supported.
WTFPL or CC0, whichever you prefer. A donation and/or attribution are appreciated, but not required.
My income consists entirely of donations for my projects. If this module is useful to you, consider making a donation!
You can donate using Bitcoin, PayPal, Gratipay, Flattr, cash-in-mail, SEPA transfers, and pretty much anything else.
Pull requests welcome. Please make sure your modifications are in line with the overall code style, and ensure that you're editing the .coffee
files, not the .js
files.
Build tool of choice is gulp
; simply run gulp
while developing, and it will watch for changes.
Be aware that by making a pull request, you agree to release your modifications under the licenses stated above.
combined-stream
Note that there are a few important differences between combined-stream
and combined-stream2
:
combined-stream2
doesn't know what the encoding of your string would be, and can't guess safely. You will need to manually encode strings to a Buffer before passing them on to combined-stream2
.pauseStreams
option does not exist. All streams are read lazily in non-flowing mode; that is, no data is read until something explicitly tries to read the combined stream.maxDataSize
option does not exist..write()
, .end()
and .destroy()
methods are not (yet) implemented..getCombinedStreamLength()
method that asynchronously returns the total length of all streams (or an error if it cannot be determined). This method will 'resolve' all callback-supplied streams, as if the stream were being read.Most usecases will not be affected by these differences, but your mileage may vary.
combined-stream2
with request
There's an important caveat when trying to append a request
stream to a combined-stream2
.
Because request
does a bunch of strange non-standard hackery with streams, it doesn't play nicely with combined-stream2
(and many other writable/transform streams). For convenience, combined-stream2
contains a built-in workaround using a PassThrough
stream specifically for dealing with request
streams, but this workaround will likely result in the entire response being buffered into memory.
Passing in response objects (that is, the object provided in the response
event handler for a request
call) is completely unsupported - trying to do so will likely break combined-stream2
. You must pass in the request
object, rather than the response
object.
I seriously suggest you consider using bhttp
instead - it has much more predictable behaviour.
1var CombinedStream = require('combined-stream2'); 2var fs = require('fs'); 3 4var combinedStream = CombinedStream.create(); 5combinedStream.append(fs.createReadStream('file1.txt')); 6combinedStream.append(fs.createReadStream('file2.txt')); 7 8combinedStream.pipe(fs.createWriteStream('combined.txt'));
The function will only be called when you try to either read/pipe the combined stream, or retrieve the total stream length.
1combinedStream.append(function(next){ 2 next(fs.createReadStream('file3.txt')); 3});
See the API documentation below for more details.
1Promise = require("bluebird"); 2 3Promise.try(function(){ 4 combinedStream.getCombinedStreamLength() 5}).then(function(length){ 6 console.log("Total stream length is " + length + " bytes."); 7}).catch(function(err){ 8 console.log("Could not determine the total stream length!"); 9});
... or using nodebacks:
1combinedStream.getCombinedStreamLength(function(err, length){ 2 if(err) { 3 console.log("Could not determine the total stream length!"); 4 } else { 5 console.log("Total stream length is " + length + " bytes."); 6 } 7});
Since combined-stream2
is a stream.Readable
, it inherits the regular Readable stream properties. Aside from that, the following methods exist:
Creates and returns a new combinedStream
. Contrary to the .create()
method for the original combined-stream
module, this method does not accept options.
Adds a source to the combined stream. Valid sources are streams, Buffers, and callbacks that return either of the two (asynchronously).
stream-length
, but you know the length of the stream in advance. Also available as knownLength
for backwards compatibility reasons.This method will 'resolve' all callback-supplied streams, as if the stream were being read.
Asynchronously returns the total length of all streams (and Buffers) together. If the total length cannot be determined (ie. at least one of the streams is of an unsupported type), an error is thrown asynchronously.
If you specify a callback
, it will be treated as a nodeback. If you do not specify a callback
, a Promise will be returned.
This functionality uses the stream-length
module.
Like for other Streams2 Readable streams, this will start piping the combined stream contents into the target
stream.
After calling this, you can no longer append new streams.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
Found 1/13 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
license file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More