aboutsummaryrefslogtreecommitdiff
path: root/node_modules/ordered-read-streams
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2016-11-03 01:33:53 +0100
committerFlorian Dold <florian.dold@gmail.com>2016-11-03 01:33:53 +0100
commitd1291f67551c58168af43698a359cb5ddfd266b0 (patch)
tree55a13ed29fe1915e3f42f1b1b7038dafa2e975a7 /node_modules/ordered-read-streams
parentd0a0695fb5d34996850723f7d4b1b59c3df909c2 (diff)
downloadwallet-core-d1291f67551c58168af43698a359cb5ddfd266b0.tar.xz
node_modules
Diffstat (limited to 'node_modules/ordered-read-streams')
-rw-r--r--node_modules/ordered-read-streams/.npmignore16
-rw-r--r--node_modules/ordered-read-streams/.travis.yml4
-rw-r--r--node_modules/ordered-read-streams/index.js34
-rw-r--r--node_modules/ordered-read-streams/package.json98
-rw-r--r--node_modules/ordered-read-streams/test/main.js160
5 files changed, 33 insertions, 279 deletions
diff --git a/node_modules/ordered-read-streams/.npmignore b/node_modules/ordered-read-streams/.npmignore
deleted file mode 100644
index a74dcace8..000000000
--- a/node_modules/ordered-read-streams/.npmignore
+++ /dev/null
@@ -1,16 +0,0 @@
-lib-cov
-*.seed
-*.log
-*.csv
-*.dat
-*.out
-*.pid
-*.gz
-
-coverage
-pids
-logs
-results
-node_modules
-
-npm-debug.log
diff --git a/node_modules/ordered-read-streams/.travis.yml b/node_modules/ordered-read-streams/.travis.yml
deleted file mode 100644
index 18ae2d89c..000000000
--- a/node_modules/ordered-read-streams/.travis.yml
+++ /dev/null
@@ -1,4 +0,0 @@
-language: node_js
-node_js:
- - "0.11"
- - "0.10"
diff --git a/node_modules/ordered-read-streams/index.js b/node_modules/ordered-read-streams/index.js
index f58ccf1dd..03e936b65 100644
--- a/node_modules/ordered-read-streams/index.js
+++ b/node_modules/ordered-read-streams/index.js
@@ -1,20 +1,21 @@
-var Readable = require('stream').Readable;
+var Readable = require('readable-stream/readable');
+var isReadable = require('is-stream').readable;
var util = require('util');
-
function addStream(streams, stream)
{
- if(!stream.readable) throw new Error('All input streams must be readable');
-
- if(this._readableState.ended) throw new Error('Adding streams after ended');
-
+ if(!isReadable(stream)) throw new Error('All input streams must be readable');
var self = this;
stream._buffer = [];
- stream.on('data', function(chunk)
+ stream.on('readable', function()
{
+ var chunk = stream.read();
+ if (chunk === null)
+ return;
+
if(this === streams[0])
self.push(chunk);
@@ -39,7 +40,6 @@ function addStream(streams, stream)
stream.on('error', this.emit.bind(this, 'error'));
-
streams.push(stream);
}
@@ -64,20 +64,14 @@ function OrderedStreams(streams, options) {
var addStream_bind = addStream.bind(this, []);
- this.concat = function()
+ streams.forEach(function(item)
{
- Array.prototype.forEach.call(arguments, function(item)
- {
- if(Array.isArray(item))
- item.forEach(addStream_bind);
-
- else
- addStream_bind(item);
- });
- };
-
+ if(Array.isArray(item))
+ item.forEach(addStream_bind);
- this.concat(streams);
+ else
+ addStream_bind(item);
+ });
}
util.inherits(OrderedStreams, Readable);
diff --git a/node_modules/ordered-read-streams/package.json b/node_modules/ordered-read-streams/package.json
index 6b406d781..48982f604 100644
--- a/node_modules/ordered-read-streams/package.json
+++ b/node_modules/ordered-read-streams/package.json
@@ -1,85 +1,25 @@
{
- "_args": [
- [
- {
- "raw": "ordered-read-streams@^0.1.0",
- "scope": null,
- "escapedName": "ordered-read-streams",
- "name": "ordered-read-streams",
- "rawSpec": "^0.1.0",
- "spec": ">=0.1.0 <0.2.0",
- "type": "range"
- },
- "/home/dold/repos/taler/wallet-webex/node_modules/glob-stream"
- ]
- ],
- "_from": "ordered-read-streams@>=0.1.0 <0.2.0",
- "_id": "ordered-read-streams@0.1.0",
- "_inCache": true,
- "_location": "/ordered-read-streams",
- "_npmUser": {
- "name": "armed",
- "email": "artem.medeusheyev@gmail.com"
- },
- "_npmVersion": "1.4.14",
- "_phantomChildren": {},
- "_requested": {
- "raw": "ordered-read-streams@^0.1.0",
- "scope": null,
- "escapedName": "ordered-read-streams",
- "name": "ordered-read-streams",
- "rawSpec": "^0.1.0",
- "spec": ">=0.1.0 <0.2.0",
- "type": "range"
- },
- "_requiredBy": [
- "/glob-stream"
- ],
- "_resolved": "https://registry.npmjs.org/ordered-read-streams/-/ordered-read-streams-0.1.0.tgz",
- "_shasum": "fd565a9af8eb4473ba69b6ed8a34352cb552f126",
- "_shrinkwrap": null,
- "_spec": "ordered-read-streams@^0.1.0",
- "_where": "/home/dold/repos/taler/wallet-webex/node_modules/glob-stream",
- "author": {
- "name": "Artem Medeusheyev",
- "email": "artem.medeusheyev@gmail.com"
- },
- "bugs": {
- "url": "https://github.com/armed/ordered-read-streams/issues"
- },
- "dependencies": {},
+ "name": "ordered-read-streams",
+ "version": "0.3.0",
"description": "Combines array of streams into one read stream in strict order",
- "devDependencies": {
- "jshint": "~2.4.1",
- "mocha": "~1.17.0",
- "pre-commit": "0.0.4",
- "should": "~3.0.1",
- "through2": "~0.4.0"
- },
- "directories": {},
- "dist": {
- "shasum": "fd565a9af8eb4473ba69b6ed8a34352cb552f126",
- "tarball": "https://registry.npmjs.org/ordered-read-streams/-/ordered-read-streams-0.1.0.tgz"
- },
- "gitHead": "0a7e487d8734978c0cc29d4dc3bfbdb8e82f865b",
- "homepage": "https://github.com/armed/ordered-read-streams",
- "license": "MIT",
- "main": "index.js",
- "maintainers": [
- {
- "name": "armed",
- "email": "artem.medeusheyev@gmail.com"
- }
+ "files": [
+ "index.js"
],
- "name": "ordered-read-streams",
- "optionalDependencies": {},
- "readme": "ERROR: No README data found!",
- "repository": {
- "type": "git",
- "url": "git://github.com/armed/ordered-read-streams.git"
- },
"scripts": {
- "test": "jshint *.js test/*.js && mocha -R spec"
+ "test": "jshint *.js test/*.js && mocha"
+ },
+ "repository": "armed/ordered-read-streams",
+ "author": "Artem Medeusheyev <artem.medeusheyev@gmail.com>",
+ "license": "MIT",
+ "dependencies": {
+ "is-stream": "^1.0.1",
+ "readable-stream": "^2.0.1"
},
- "version": "0.1.0"
+ "devDependencies": {
+ "should": "^7.0.1",
+ "mocha": "^2.2.5",
+ "through2": "^2.0.0",
+ "jshint": "^2.8.0",
+ "pre-commit": "^1.0.10"
+ }
}
diff --git a/node_modules/ordered-read-streams/test/main.js b/node_modules/ordered-read-streams/test/main.js
deleted file mode 100644
index 81f80403d..000000000
--- a/node_modules/ordered-read-streams/test/main.js
+++ /dev/null
@@ -1,160 +0,0 @@
-var should = require('should');
-var through = require('through2');
-var OrderedStreams = require('../');
-
-describe('ordered-read-streams', function () {
- it('should end if no streams are given', function (done) {
- var streams = 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) {
- var writable = { readable: false };
-
- try {
- new OrderedStreams(writable);
- } catch (e) {
- e.message.should.equal('All input streams must be readable');
- done();
- }
- });
-
- it('should emit data from all streams', function(done) {
- var s1 = through.obj(function (data, enc, next) {
- this.push(data);
- next();
- });
- var s2 = through.obj(function (data, enc, next) {
- this.push(data);
- next();
- });
- var s3 = through.obj(function (data, enc, next) {
- this.push(data);
- next();
- });
-
- var streams = new OrderedStreams([s1, s2, s3]);
- var results = [];
- streams.on('data', function (data) {
- results.push(data);
- });
- streams.on('end', function () {
- results.length.should.be.exactly(3);
- results[0].should.equal('stream 1');
- results[1].should.equal('stream 2');
- results[2].should.equal('stream 3');
- done();
- });
-
- s1.write('stream 1');
- s1.end();
-
- s2.write('stream 2');
- s2.end();
-
- s3.write('stream 3');
- s3.end();
- });
-
- it('should emit all data event from each stream', function (done) {
- var s = through.obj(function (data, enc, next) {
- this.push(data);
- next();
- });
-
- var streams = new OrderedStreams(s);
- var results = [];
- streams.on('data', function (data) {
- results.push(data);
- });
- streams.on('end', function () {
- results.length.should.be.exactly(3);
- done();
- });
-
- s.write('data1');
- s.write('data2');
- s.write('data3');
- s.end();
- });
-
- it('should preserve streams order', function(done) {
- var s1 = through.obj(function (data, enc, next) {
- var self = this;
- setTimeout(function () {
- self.push(data);
- next();
- }, 200);
- });
- var s2 = through.obj(function (data, enc, next) {
- var self = this;
- setTimeout(function () {
- self.push(data);
- next();
- }, 30);
- });
- var s3 = through.obj(function (data, enc, next) {
- var self = this;
- setTimeout(function () {
- self.push(data);
- next();
- }, 100);
- });
-
- var streams = new OrderedStreams([s1, s2, s3]);
- var results = [];
- streams.on('data', function (data) {
- results.push(data);
- });
- streams.on('end', function () {
- results.length.should.be.exactly(3);
- results[0].should.equal('stream 1');
- results[1].should.equal('stream 2');
- results[2].should.equal('stream 3');
- done();
- });
-
- s1.write('stream 1');
- s1.end();
-
- s2.write('stream 2');
- s2.end();
-
- s3.write('stream 3');
- s3.end();
- });
-
- it('should emit stream errors downstream', function (done) {
- var s = through.obj(function (data, enc, next) {
- this.emit('error', new Error('stahp!'));
- next();
- });
- var s2 = through.obj(function (data, enc, next) {
- this.push(data);
- next();
- });
-
- var errMsg;
- var streamData;
- var streams = new OrderedStreams([s, s2]);
- streams.on('data', function (data) {
- streamData = data;
- });
- streams.on('error', function (err) {
- errMsg = err.message;
- });
- streams.on('end', function () {
- errMsg.should.equal('stahp!');
- streamData.should.equal('Im ok!');
- done();
- });
-
- s.write('go');
- s.end();
- s2.write('Im ok!');
- s2.end();
- });
-});