ordered-read-streams
Advanced tools
Comparing version 0.3.0 to 1.0.0
66
index.js
@@ -5,5 +5,6 @@ var Readable = require('readable-stream/readable'); | ||
function addStream(streams, stream) | ||
{ | ||
if(!isReadable(stream)) throw new Error('All input streams must be readable'); | ||
function addStream (streams, stream) { | ||
if (!isReadable(stream)) { | ||
throw new Error('All input streams must be readable'); | ||
} | ||
@@ -14,23 +15,22 @@ var self = this; | ||
stream.on('readable', function() | ||
{ | ||
stream.on('readable', function () { | ||
var chunk = stream.read(); | ||
if (chunk === null) | ||
if (chunk === null) { | ||
return; | ||
} | ||
if(this === streams[0]) | ||
if (this === streams[0]) { | ||
self.push(chunk); | ||
else | ||
} else { | ||
this._buffer.push(chunk); | ||
} | ||
}); | ||
stream.on('end', function() | ||
{ | ||
for(var stream = streams[0]; | ||
stream && stream._readableState.ended; | ||
stream = streams[0]) | ||
{ | ||
while(stream._buffer.length) | ||
stream.on('end', function () { | ||
for (var stream = streams[0]; | ||
stream && stream._readableState.ended; | ||
stream = streams[0]) { | ||
while (stream._buffer.length) { | ||
self.push(stream._buffer.shift()); | ||
} | ||
@@ -40,3 +40,5 @@ streams.shift(); | ||
if(!streams.length) self.push(null); | ||
if (!streams.length) { | ||
self.push(null); | ||
} | ||
}); | ||
@@ -49,4 +51,3 @@ | ||
function OrderedStreams(streams, options) { | ||
function OrderedStreams (streams, options) { | ||
if (!(this instanceof(OrderedStreams))) { | ||
@@ -63,17 +64,17 @@ return new OrderedStreams(streams, options); | ||
if (!Array.isArray(streams)) { | ||
streams = [streams]; | ||
} | ||
if (!streams.length) { | ||
return this.push(null); // no streams, close | ||
} | ||
if(!Array.isArray(streams)) streams = [streams]; | ||
if(!streams.length) return this.push(null); // no streams, close | ||
var addStreamBinded = addStream.bind(this, []); | ||
var addStream_bind = addStream.bind(this, []); | ||
streams.forEach(function(item) | ||
{ | ||
if(Array.isArray(item)) | ||
item.forEach(addStream_bind); | ||
else | ||
addStream_bind(item); | ||
streams.forEach(function (item) { | ||
if (Array.isArray(item)) { | ||
item.forEach(addStreamBinded); | ||
} else { | ||
addStreamBinded(item); | ||
} | ||
}); | ||
@@ -85,3 +86,2 @@ } | ||
module.exports = OrderedStreams; |
{ | ||
"name": "ordered-read-streams", | ||
"version": "0.3.0", | ||
"version": "1.0.0", | ||
"description": "Combines array of streams into one read stream in strict order", | ||
@@ -9,3 +9,3 @@ "files": [ | ||
"scripts": { | ||
"test": "jshint *.js test/*.js && mocha" | ||
"test": "jscs *.js test/*js && jshint *.js test/*.js && mocha" | ||
}, | ||
@@ -20,8 +20,9 @@ "repository": "armed/ordered-read-streams", | ||
"devDependencies": { | ||
"jscs": "^1.13.1", | ||
"jshint": "^2.8.0", | ||
"mocha": "^2.2.5", | ||
"pre-commit": "^1.0.10", | ||
"should": "^7.0.1", | ||
"mocha": "^2.2.5", | ||
"through2": "^2.0.0", | ||
"jshint": "^2.8.0", | ||
"pre-commit": "^1.0.10" | ||
"through2": "^2.0.0" | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
# ordered-read-streams [![NPM version](https://badge.fury.io/js/ordered-read-streams.png)](http://badge.fury.io/js/ordered-read-streams) [![Build Status](https://travis-ci.org/armed/ordered-read-streams.png?branch=master)](https://travis-ci.org/armed/ordered-read-streams) | ||
# ordered-read-streams [![NPM version](https://img.shields.io/npm/v/ordered-read-streams.svg)](http://badge.fury.io/js/ordered-read-streams) [![Build Status](https://travis-ci.org/armed/ordered-read-streams.svg?branch=master)](https://travis-ci.org/armed/ordered-read-streams) | ||
@@ -3,0 +3,0 @@ Combines array of streams into one read stream in strict order. |
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
4823
62
1
6