Skip to content

Commit 2a74b46

Browse files
committed
fix async iterators
1 parent 197f4b7 commit 2a74b46

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

index.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ var end = function(ws, fn) {
3131
fn()
3232
}
3333

34+
var noop = function() {}
35+
3436
var toStreams2 = function(rs) {
3537
return new (stream.Readable)({objectMode:true, highWaterMark:16}).wrap(rs)
3638
}
@@ -173,13 +175,15 @@ Duplexify.prototype._forward = function() {
173175
this._forwarding = false
174176
}
175177

176-
Duplexify.prototype.destroy = function(err) {
177-
if (this.destroyed) return
178+
Duplexify.prototype.destroy = function(err, cb) {
179+
if (!cb) cb = noop
180+
if (this.destroyed) return cb(null)
178181
this.destroyed = true
179182

180183
var self = this
181184
process.nextTick(function() {
182185
self._destroy(err)
186+
cb(null)
183187
})
184188
}
185189

0 commit comments

Comments
 (0)