Skip to content

Commit b3b1155

Browse files
committed
Update: Use end-of-stream module to handle all stream completion
1 parent 7732e98 commit b3b1155

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
var domain = require('domain');
44
var EE = require('events').EventEmitter;
55

6+
var eos = require('end-of-stream');
7+
68
function asyncDone(fn, done){
79
function onSuccess(result){
810
return done(undefined, result);
@@ -21,7 +23,7 @@ function asyncDone(fn, done){
2123

2224
if(result && result instanceof EE){
2325
d.add(result);
24-
result.once('end', onSuccess).once('close', onSuccess);
26+
eos(result, { error: false }, onSuccess);
2527
return;
2628
}
2729

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
"url": "https://github.com/phated/async-done/issues"
2020
},
2121
"homepage": "https://github.com/phated/async-done",
22+
"dependencies": {
23+
"end-of-stream": "^0.1.4"
24+
},
2225
"devDependencies": {
2326
"tap": "~0.4.8",
2427
"through2": "~0.4.1",

test/streams.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,8 @@ function failure(){
3030
}
3131

3232
test('handle a successful stream', function(t){
33-
asyncDone(success, function(err, result){
33+
asyncDone(success, function(err){
3434
t.ok(err == null, 'error should be null or undefined');
35-
t.equal(result, 2, 'result should be 2');
3635
t.end();
3736
});
3837
});

0 commit comments

Comments
 (0)