stream-exhaust
Advanced tools
Comparing version 1.0.0 to 1.0.1
12
index.js
var Writable = require('stream').Writable; | ||
var inherits = require('util').inherits; | ||
module.exports = resumer | ||
module.exports = resumer; | ||
@@ -11,4 +11,12 @@ function resumer(stream) { | ||
stream._read ? stream.pipe(new Sink) : stream.resume(); | ||
if (stream._read) { | ||
stream.pipe(new Sink); | ||
return stream; | ||
} | ||
if (typeof stream.resume === 'function') { | ||
stream.resume(); | ||
return stream; | ||
} | ||
return stream; | ||
@@ -15,0 +23,0 @@ } |
{ | ||
"name": "stream-exhaust", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Ensure that a stream is flowing data without mutating it", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -6,3 +6,3 @@ # stream-exhaust | ||
``javascript | ||
```javascript | ||
var exhaustively = require('stream-exhaust'); | ||
@@ -12,5 +12,4 @@ | ||
.on('close', () => { console.log('all done, despite being streams{1+N}!') }); | ||
``` | ||
`` | ||
## Prior Art | ||
@@ -17,0 +16,0 @@ |
23
test.js
@@ -188,2 +188,23 @@ var test = require('tape'); | ||
assert.end(); | ||
}) | ||
}); | ||
test('does not error on no resume but readable set to true', function(assert) { | ||
var rs = new Stream(); | ||
rs.readable = true; | ||
var ended = false; | ||
var i; | ||
rs.on("end", function() { | ||
assert.ok(ended, 'ended is true'); | ||
assert.end(); | ||
}); | ||
exhaust(rs); | ||
for (i = 0; i < 100; i++) { | ||
rs.emit("data", i); | ||
} | ||
ended = true; | ||
rs.emit("end"); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6462
200
34