v1.0.3: Actually offer the API that the documentation promises.

master
Sven Slootweg 9 years ago
parent 717003615e
commit 00bef7a381

@ -100,14 +100,16 @@ Adds a source to the combined stream. Valid sources are streams, Buffers, and ca
* __source__: The source to add.
* __options__: *Optional.* Additional stream options.
* __contentLength__: The length of the stream. Useful if your stream type is not supported by `stream-length`, but you know the length of the stream in advance. Also available as `knownLength` for backwards compatibility reasons.
* __contentLength__: The length of the stream. Useful if your stream type is not supported by [`stream-length`](https://www.npmjs.com/package/stream-length), but you know the length of the stream in advance. Also available as `knownLength` for backwards compatibility reasons.
### combinedStream.getCombinedStreamLength()
### combinedStream.getCombinedStreamLength([callback])
__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`](https://www.npmjs.com/package/stream-length) module.
### combinedStream.pipe(target)

@ -61,11 +61,12 @@ class CombinedStream extends stream.Readable
else
streamLength source[0]
getCombinedStreamLength: ->
getCombinedStreamLength: (callback) ->
debug "getting combined stream length"
Promise.try =>
@getStreamLengths()
.reduce ((total, current) -> total + current), 0
.nodeify(callback)
_resolveAllSources: ->
debug "resolving all sources"

@ -87,7 +87,7 @@ CombinedStream = (function(_super) {
}
};
CombinedStream.prototype.getCombinedStreamLength = function() {
CombinedStream.prototype.getCombinedStreamLength = function(callback) {
debug("getting combined stream length");
return Promise["try"]((function(_this) {
return function() {
@ -95,7 +95,7 @@ CombinedStream = (function(_super) {
};
})(this)).reduce((function(total, current) {
return total + current;
}), 0);
}), 0).nodeify(callback);
};
CombinedStream.prototype._resolveAllSources = function() {

@ -1,6 +1,6 @@
{
"name": "combined-stream2",
"version": "1.0.2",
"version": "1.0.3",
"description": "A drop-in Streams2-compatible replacement for combined-stream.",
"main": "index.js",
"scripts": {

Loading…
Cancel
Save