achingbrain / achingbrain/it-all
Cannot pass async iterator
- Dominant language
- JavaScript
- Stars
- 5
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
Hello, it seems you cannot pass this function an `iterator`, it only accepts `iterable`
Your example shows
```js
async function * iterator (values) {
for (let i = 0; i < values.length; i++) {
yield values[i]
}
}
```
Which is a generator, which is async iterable, and is also a iterator, but your function throws an error
```
TypeError: iterator is not async iterable
```
I looked into your code, it seems it is simply `async for...of` which doesn't accept iterators.
Your code would need to be able to pass this test
```js
(async function () {
let i = 65;
const the_iterator = {
next() {
if ( i < 70 ) return Promise.resolve({ done: false, value: String.fromCharCode(i++) });
return { done: true };
}
};
const a = await toArray(the_iterator);
deepEqual(a, ['A', 'B', 'C', 'D', 'E']);
})();
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.