Async iterator destructuring?

Bergi a.d.bergi at web.de
Sat Feb 8 02:00:02 UTC 2020


Hi,

> It might be useful on some occasions to [collect] async iterators [into an array].
No need for destructuring or spreading here. The iterator helpers
proposal <https://github.com/tc39/proposal-iterator-helpers> already
covers these:

```js
return Buffer.concat(await someStream.setEncoding('buffer').toArray())
```

```js
// It's different for each database
const [item] = await db.scan({
    filter: {key: value},
    limit: 1,
}).toArray()
```

kind regards,
 Bergi


More information about the es-discuss mailing list