Skip to content

Commit

Permalink
Always use readable-stream/lazystream (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
jpommerening committed Dec 29, 2015
1 parent dbf871e commit eb1e656
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions lib/lazystream.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@

var util = require('util');
var PassThrough = require('stream').PassThrough || require('readable-stream/passthrough');
var PassThrough = require('readable-stream/passthrough');

module.exports = {
Readable: Readable,
Expand Down Expand Up @@ -29,10 +28,8 @@ function Readable(fn, options) {

beforeFirstCall(this, '_read', function() {
var source = fn.call(this, options);
var that = this
source.on('error', function(err) {
that.emit('error', err)
})
var emit = this.emit.bind(this, 'error');
source.on('error', emit);
source.pipe(this);
});

Expand All @@ -47,10 +44,8 @@ function Writable(fn, options) {

beforeFirstCall(this, '_write', function() {
var destination = fn.call(this, options);
var that = this
destination.on('error', function(err) {
that.emit('error', err)
})
var emit = this.emit.bind(this, 'error');
destination.on('error', emit);
this.pipe(destination);
});

Expand Down

0 comments on commit eb1e656

Please sign in to comment.