Skip to content

Commit ab48f6f

Browse files
committed
better errors
1 parent ad65012 commit ab48f6f

File tree

1 file changed

+3
-22
lines changed

1 file changed

+3
-22
lines changed

index.js

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,46 +3,27 @@ var noop = function () {}
33
module.exports = function (next) {
44
var stream
55
return function (abort, cb) {
6+
if(!cb) throw new Error('callback required!')
67
if(abort) {
78
if(stream) stream(abort, cb)
89
else cb(abort)
910
}
10-
else
11-
more()
12-
13-
function more () {
11+
else (function more () {
1412
if(!stream) {
1513
try { stream = next() }
1614
catch(err) { return cb(err) }
1715
if(!stream) return cb(true)
1816
}
1917
stream(null, function (err, data) {
2018
if(err) {
21-
console.log('end', err, data)
2219
stream = null
2320
if(err === true) setTimeout(more, 100)
2421
else cb(err)
2522
}
2623
else
2724
cb(null, data)
2825
})
29-
}
26+
})()
3027
}
3128
}
3229

33-
34-
35-
36-
37-
38-
39-
40-
41-
42-
43-
44-
45-
46-
47-
48-

0 commit comments

Comments
 (0)