Commit 508b9bc
committed
feat: support creating iterator async
Allows early errors before the stream is created:
```js
async function * read (fd) {
// read file here
}
const createReadStream = asyncIteratorToStream(async function (file) {
const fd = await fs.open(file, 'r')
return read(fd)
})
try {
const stream = await createReadStream('foo.txt')
stream.pipe(process.stdout)
} catch (error) {
console.error('failed to open the file', error)
}
```1 parent ff9a640 commit 508b9bc
1 file changed
+7
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
71 | 78 | | |
72 | 79 | | |
73 | 80 | | |
| |||
0 commit comments