v1.0.4: Fix type checking to also check for stream.Stream - this is needed for it to work with `request` streams.

master
Sven Slootweg 10 years ago
parent 00bef7a381
commit 40f8e6f6d4

@ -13,7 +13,7 @@ ofTypes = (obj, types) ->
return match return match
isStream = (obj) -> isStream = (obj) ->
return ofTypes obj, [stream.Readable, stream.Duplex, stream.Transform] return ofTypes obj, [stream.Readable, stream.Duplex, stream.Transform, stream.Stream]
makeStreams2 = (stream) -> makeStreams2 = (stream) ->
# Adapted from https://github.com/feross/multistream/blob/master/index.js # Adapted from https://github.com/feross/multistream/blob/master/index.js
@ -39,7 +39,7 @@ class CombinedStream extends stream.Readable
append: (source, options = {}) -> append: (source, options = {}) ->
# Only readable binary data sources are allowed. # Only readable binary data sources are allowed.
if not ofTypes source, [stream.Readable, stream.Duplex, stream.Transform, Buffer, Function] if not ofTypes source, [stream.Readable, stream.Duplex, stream.Transform, stream.Stream, Buffer, Function]
throw new Error "The provided source must be either a readable stream or a Buffer, or a callback providing either of those. If it is currently a string, you need to convert it to a Buffer yourself and ensure that the encoding is correct." throw new Error "The provided source must be either a readable stream or a Buffer, or a callback providing either of those. If it is currently a string, you need to convert it to a Buffer yourself and ensure that the encoding is correct."
debug "appending source: %s", source.toString().replace(/\n/g, "\\n").replace(/\r/g, "\\r") debug "appending source: %s", source.toString().replace(/\n/g, "\\n").replace(/\r/g, "\\r")

@ -22,7 +22,7 @@ ofTypes = function(obj, types) {
}; };
isStream = function(obj) { isStream = function(obj) {
return ofTypes(obj, [stream.Readable, stream.Duplex, stream.Transform]); return ofTypes(obj, [stream.Readable, stream.Duplex, stream.Transform, stream.Stream]);
}; };
makeStreams2 = function(stream) { makeStreams2 = function(stream) {
@ -55,7 +55,7 @@ CombinedStream = (function(_super) {
if (options == null) { if (options == null) {
options = {}; options = {};
} }
if (!ofTypes(source, [stream.Readable, stream.Duplex, stream.Transform, Buffer, Function])) { if (!ofTypes(source, [stream.Readable, stream.Duplex, stream.Transform, stream.Stream, Buffer, Function])) {
throw new Error("The provided source must be either a readable stream or a Buffer, or a callback providing either of those. If it is currently a string, you need to convert it to a Buffer yourself and ensure that the encoding is correct."); throw new Error("The provided source must be either a readable stream or a Buffer, or a callback providing either of those. If it is currently a string, you need to convert it to a Buffer yourself and ensure that the encoding is correct.");
} }
debug("appending source: %s", source.toString().replace(/\n/g, "\\n").replace(/\r/g, "\\r")); debug("appending source: %s", source.toString().replace(/\n/g, "\\n").replace(/\r/g, "\\r"));

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

Loading…
Cancel
Save