Skip to content

Commit

Permalink
Add compatibility for 0.9 / 0.10 Streams
Browse files Browse the repository at this point in the history
Fall back to readable-stream 0.2.0 for older
versions of Node. Also update tests now that
callling end() after end() does not throw.
  • Loading branch information
Evan Oxfeld committed Jan 25, 2013
1 parent bd85f81 commit fb636cb
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -25,7 +25,7 @@
},
"dependencies": {
"over": "~0.0.5",
"readable-stream": "0.0.3",
"readable-stream": "~0.2.0",
"setimmediate": "~1.0.1"
}
}
6 changes: 5 additions & 1 deletion pullstream.js
Expand Up @@ -4,9 +4,13 @@ module.exports = PullStream;

require("setimmediate");
var inherits = require("util").inherits;
var PassThrough = require('readable-stream/passthrough');
var PassThrough = require('stream').PassThrough;
var over = require('over');

if (!PassThrough) {
PassThrough = require('readable-stream/passthrough');
}

function PullStream(opts) {
var self = this;
this.opts = opts || {};
Expand Down
11 changes: 2 additions & 9 deletions test/pullStreamTest.js
Expand Up @@ -260,8 +260,8 @@ module.exports = {
});
},

"throw on calling data or end after end": function (t) {
t.expect(2);
"throw on calling write() after end": function (t) {
t.expect(1);
var ps = new PullStream({ lowWaterMark : 0 });
ps.end();

Expand All @@ -272,13 +272,6 @@ module.exports = {
t.ok(ex);
}

try {
ps.end(new Buffer('hello', 'utf8'));
t.fail("should throw error");
} catch (ex) {
t.ok(ex);
}

t.done();
},

Expand Down

0 comments on commit fb636cb

Please sign in to comment.