From 40f8e6f6d4dc26682fd5966ccadc6f41ec98ea60 Mon Sep 17 00:00:00 2001 From: Sven Slootweg Date: Thu, 26 Feb 2015 06:47:49 +0100 Subject: [PATCH] v1.0.4: Fix type checking to also check for stream.Stream - this is needed for it to work with `request` streams. --- lib/combined-stream2.coffee | 4 ++-- lib/combined-stream2.js | 4 ++-- package.json | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/combined-stream2.coffee b/lib/combined-stream2.coffee index 93a6f47..6ea3dcc 100644 --- a/lib/combined-stream2.coffee +++ b/lib/combined-stream2.coffee @@ -13,7 +13,7 @@ ofTypes = (obj, types) -> return match isStream = (obj) -> - return ofTypes obj, [stream.Readable, stream.Duplex, stream.Transform] + return ofTypes obj, [stream.Readable, stream.Duplex, stream.Transform, stream.Stream] makeStreams2 = (stream) -> # Adapted from https://github.com/feross/multistream/blob/master/index.js @@ -39,7 +39,7 @@ class CombinedStream extends stream.Readable append: (source, options = {}) -> # 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." debug "appending source: %s", source.toString().replace(/\n/g, "\\n").replace(/\r/g, "\\r") diff --git a/lib/combined-stream2.js b/lib/combined-stream2.js index 96288fe..7d71dc7 100644 --- a/lib/combined-stream2.js +++ b/lib/combined-stream2.js @@ -22,7 +22,7 @@ ofTypes = function(obj, types) { }; 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) { @@ -55,7 +55,7 @@ CombinedStream = (function(_super) { if (options == null) { 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."); } debug("appending source: %s", source.toString().replace(/\n/g, "\\n").replace(/\r/g, "\\r")); diff --git a/package.json b/package.json index 2a173e9..3fafe17 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "combined-stream2", - "version": "1.0.3", + "version": "1.0.4", "description": "A drop-in Streams2-compatible replacement for combined-stream.", "main": "index.js", "scripts": {