Skip to content

Commit

Permalink
Fixed up example to work again... Also fixed and updated lib to use s…
Browse files Browse the repository at this point in the history
…tartNext instead of just next.

Signed-off-by: Nick Campbell <nicholas.j.campbell@gmail.com>
  • Loading branch information
ncb000gt committed Sep 28, 2011
1 parent d666ecb commit 7f4a3d4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
20 changes: 13 additions & 7 deletions examples/test.js
@@ -1,21 +1,27 @@
var Queue = require('../lib/queuestream').QueueStream(),
fs = require('fs');

stream.on('error', function(err) {
Queue.on('error', function(err) {
console.log('err: ' + err);
});

stream.on('data', function(data) {
console.log(data.toString());
Queue.on('data', function(data) {
console.log('listener 1: ' + data.toString());
});
Queue.on('data', function(data) {
console.log('listener 2: ' + data.toString());
});
Queue.on('data', function(data) {
console.log('listener 3: ' + data.toString());
});

stream.on('end', function() {
Queue.on('end', function() {
console.log('done');
});

var test1 = fs.createReadStream(__dirname + '/files/test1.txt');
stream.queue(test1);
Queue.queue(test1);
var test2 = fs.createReadStream(__dirname + '/files/test2.txt');
stream.queue(test2);
Queue.queue(test2);

stream.start();
Queue.startNext();
4 changes: 2 additions & 2 deletions lib/queuestream.js
Expand Up @@ -73,7 +73,7 @@ QueueStream.prototype.start = function() {

if (this.current.paused) this.current.resume();
} else if (this.streams.length > 0) {
this.next();
this.startNext();
}
}

Expand Down Expand Up @@ -117,7 +117,7 @@ QueueStream.prototype.end = function() {
// Handle currentStream Events
QueueStream.prototype.currentEnd = function() {
this.current = null;
this.next();
this.startNext();
}

QueueStream.prototype.currentData = function(data) {
Expand Down

0 comments on commit 7f4a3d4

Please sign in to comment.