duplex-combination
Advanced tools
Comparing version
16
dc.js
@@ -17,4 +17,4 @@ "use strict"; | ||
this._reader = reader; | ||
this._writer = writer; | ||
this.reader = reader; | ||
this.writer = writer; | ||
Duplex.call(this, options); | ||
@@ -25,7 +25,7 @@ | ||
var duplex = this; | ||
this._reader.on('error', function (error) { | ||
duplex.emit('error', error); | ||
this.reader.on('error', function (error) { | ||
duplex.emit('error', error, duplex.reader); | ||
}); | ||
this._writer.on('error', function (error) { | ||
duplex.emit('error', error); | ||
this.writer.on('error', function (error) { | ||
duplex.emit('error', error, duplex.writer); | ||
}); | ||
@@ -41,4 +41,4 @@ | ||
assert(writer instanceof stream.Writable || writer instanceof stream.Duplex, 'writer must be a Writable stream'); | ||
this._reader.read(0); | ||
this._writer.read(0); | ||
this.reader.read(0); | ||
this.writer.read(0); | ||
}; | ||
@@ -45,0 +45,0 @@ |
{ | ||
"name": "duplex-combination", | ||
"description": "Combine a readable and writable stream into a duplex stream", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"license": "BSD", | ||
@@ -6,0 +6,0 @@ "scripts": { |
@@ -16,4 +16,23 @@ # duplex-combination | ||
## Additional public properties | ||
The read and write streams are exposed with the properties `dp.reader` and `dp.writer` | ||
## ERRORS | ||
Error events include the stream that triggered the error, so you can: | ||
```javascript | ||
dp.on('error',function(err,stream) { | ||
if (stream === dp.reader) { | ||
// error while reading | ||
} | ||
else { | ||
// error while writing | ||
} | ||
}); | ||
``` | ||
## Acknowledgements | ||
Stolen shamelessly from Isaac Schuleter's `duplex-passthrough` module. |
3984
11.28%38
100%