multistream
Advanced tools
Comparing version 1.4.1 to 1.4.2
@@ -60,3 +60,3 @@ module.exports = MultiStream | ||
if (typeof stream === 'function') stream = stream() | ||
if (typeof stream === 'function') stream = toStreams2(stream()) | ||
@@ -68,3 +68,2 @@ if (!stream) { | ||
stream = toStreams2(stream) | ||
this._current = stream | ||
@@ -102,4 +101,3 @@ | ||
function toStreams2 (s) { | ||
if (typeof s === 'function') return s | ||
if (s._readableState) return s | ||
if (!s || typeof s === 'function' || s._readableState) return s | ||
@@ -106,0 +104,0 @@ var wrap = new stream.Readable().wrap(s) |
{ | ||
"name": "multistream", | ||
"description": "A stream that emits multiple other streams one after another (streams2)", | ||
"version": "1.4.1", | ||
"version": "1.4.2", | ||
"author": "Feross Aboukhadijeh <feross@feross.org> (http://feross.org/)", | ||
@@ -14,2 +14,3 @@ "bugs": { | ||
"concat-stream": "^1.4.6", | ||
"string-to-stream": "^1.0.0", | ||
"tape": "^2.5.0", | ||
@@ -16,0 +17,0 @@ "through": "^2.3.4" |
var concat = require('concat-stream') | ||
var through = require('through') | ||
var inherits = require('inherits') | ||
var MultiStream = require('../') | ||
var stream = require('stream') | ||
var str = require('string-to-stream') | ||
var test = require('tape') | ||
var through = require('through') | ||
inherits(StringStream, stream.Readable) | ||
function StringStream (str) { | ||
stream.Readable.call(this) | ||
this._str = str | ||
} | ||
StringStream.prototype._read = function(n) { | ||
if (!this.ended) { | ||
var self = this | ||
process.nextTick(function () { | ||
self.push(new Buffer(self._str)) | ||
self.push(null) | ||
}) | ||
this.ended = true | ||
} | ||
} | ||
test('combine streams', function (t) { | ||
var streams = [ | ||
new StringStream('1'), | ||
new StringStream('2'), | ||
new StringStream('3') | ||
new str('1'), | ||
new str('2'), | ||
new str('3') | ||
] | ||
MultiStream(streams) | ||
new MultiStream(streams) | ||
.on('error', function (err) { | ||
@@ -50,3 +31,3 @@ t.fail(err) | ||
MultiStream(streams) | ||
new MultiStream(streams) | ||
.on('error', function (err) { | ||
@@ -67,12 +48,12 @@ t.fail(err) | ||
var streams = [ | ||
new StringStream('1'), | ||
new str('1'), | ||
function() { | ||
return new StringStream('2') | ||
return new str('2') | ||
}, | ||
function() { | ||
return new StringStream('3') | ||
return new str('3') | ||
} | ||
] | ||
MultiStream(streams) | ||
new MultiStream(streams) | ||
.on('error', function (err) { | ||
@@ -79,0 +60,0 @@ t.fail(err) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
30843
4
138