Bret Comnes 80459935e1
0.0.1
2020-02-12 16:58:30 -07:00

22 lines
408 B
JavaScript

const tape = require('tape')
const { Readable } = require('../')
tape('streams are async iterators', async function (t) {
const data = ['a', 'b', 'c', null]
const expected = data.slice(0)
const r = new Readable({
read (cb) {
this.push(data.shift())
cb(null)
}
})
for await (const chunk of r) {
t.same(chunk, expected.shift())
}
t.same(expected, [null])
t.end()
})