Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ordered-read-streams

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ordered-read-streams - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

21

index.js

@@ -5,3 +5,3 @@ var Readable = require('stream').Readable;

function OrderedStreams(options) {
options = options || {};
options = options || [];
if (Array.isArray(options)) {

@@ -22,3 +22,3 @@ options = {streams: options};

} else {
// initial index in list of glob-streams
// initial index in list of streams
this._currentIndex = 0;

@@ -47,13 +47,10 @@ this._buff = {};

if (!--self._openedStreams) {
self.push(null); // close OrderedStreams
self.push(null); // close
}
})
});
s.on('error', function (e) {
self.emit('error', e); // error event downstream
})
});
this.on('finish', function() {
streams.forEach(function (s) {
s.end();
if (i === self._currentIndex) {
self._currentIndex++;
}
self.emit('error', e);
});

@@ -73,4 +70,4 @@ });

}
}
};
module.exports = OrderedStreams;
{
"name": "ordered-read-streams",
"version": "0.0.2",
"version": "0.0.3",
"description": "Combines array of streams into one read stream in strict order",
"main": "index.js",
"scripts": {
"test": "mocha -R spec && jshint"
"test": "mocha -R spec && jshint *.js test/*.js"
},

@@ -9,0 +9,0 @@ "repository": {

@@ -1,2 +0,2 @@

# 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://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)

@@ -3,0 +3,0 @@ Combines array of streams into one read stream in strict order.

@@ -6,2 +6,10 @@ var should = require('should');

describe('ordered-read-streams', function () {
it('should end if no streams are given', function (done) {
var streams = new OrderedStreams();
streams.on('data', function () {
done('error');
});
streams.on('end', done);
});
it('should throw error if one or more streams are not readable', function (done) {

@@ -36,3 +44,3 @@ var writable = { readable: false };

results.push(data);
})
});
streams.on('end', function () {

@@ -44,3 +52,3 @@ results.length.should.equal(3);

done();
})
});

@@ -63,3 +71,3 @@ s1.write('stream 1');

next();
}, 200)
}, 200);
});

@@ -71,3 +79,3 @@ var s2 = through.obj(function (data, enc, next) {

next();
}, 30)
}, 30);
});

@@ -79,3 +87,3 @@ var s3 = through.obj(function (data, enc, next) {

next();
}, 100)
}, 100);
});

@@ -87,3 +95,3 @@

results.push(data);
})
});
streams.on('end', function () {

@@ -95,3 +103,3 @@ results.length.should.equal(3);

done();
})
});

@@ -112,16 +120,22 @@ s1.write('stream 1');

next();
})
});
var s2 = through.obj(function (data, enc, next) {
this.push(data);
next();
})
});
var streams = new OrderedStreams(s);
var errMsg;
var streamData;
var streams = new OrderedStreams([s, s2]);
streams.on('data', function (data) {
streamData = data;
});
streams.on('error', function (err) {
err.message.should.equal('stahp!');
errMsg = err.message;
});
streams.on('data', function (data) {
data.should.equal('Im ok!');
streams.on('end', function () {
errMsg.should.equal('stahp!');
streamData.should.equal('Im ok!');
done();
});
streams.on('end', done);

@@ -128,0 +142,0 @@ s.write('go');

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc