Skip to content

Commit 27ef8f5

Browse files
authored
Merge pull request #2 from guybedford/read-debounce
Handle next call debouncing
2 parents 496a375 + 903d18a commit 27ef8f5

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

index.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,14 @@ function toReadable (iterator, opts) {
1313
readable.destroy(err)
1414
}
1515

16+
let curNext
1617
async function next () {
17-
const { value, done } = await iterator.next()
18+
if (curNext) {
19+
await curNext
20+
return
21+
}
22+
const { value, done } = await (curNext = iterator.next())
23+
curNext = null
1824
if (done) {
1925
readable.push(null)
2026
return

0 commit comments

Comments
 (0)