Skip to content

Support Async Iterable Protocol #20

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
kuchta opened this issue May 21, 2019 · 4 comments · Fixed by #46
Closed

Support Async Iterable Protocol #20

kuchta opened this issue May 21, 2019 · 4 comments · Fixed by #46

Comments

@kuchta
Copy link

kuchta commented May 21, 2019

No description provided.

@sindresorhus
Copy link
Owner

Please include some body text in the issue. For example, what it would look like to support this?

@kuchta
Copy link
Author

kuchta commented May 22, 2019

I meant it would be cool to have support for Async Iterables in place of input argument.

@sindresorhus
Copy link
Owner

sindresorhus commented Jul 1, 2019

Yeah, we could do this, but not worth doing it until we can use it natively internally, which means targeting Node.js 10, which we cannot do until next year.

@sindresorhus
Copy link
Owner

This can now be done. PR welcome :)

huntharo added a commit to pwrdrvr/p-map that referenced this issue Aug 25, 2021
- Expand capabilities to handle both async and sync iterables
- There is a problem in the original functionality around the `stop-on-error` test that needs to be resolved
  - The test has a bug in that neither p-map nor the test mapper function, which is provided for that specific test and is not the common version, await the calling of the delay() function for item 2
  - This means that item 2 will only ever return a Promise, never a value
  - When this is fixed to await the function call, it causes the returned results to change from `[1, 3]` to `[1, 3, 2]`
  - Fixing this test makes it clear that the `concurrency setup` loop does not wait for mappers, so the only way to make this test fail would be to have enough items that eventually the initial iteration could not reach the last items in the test array before the 100 ms delay on the exception expires
  - With `concurrency = 1` this test behaves as expected since there are not unlimited unawaited promises created
  - Let me know your thoughts on how to resolve this as it becomes more apparent with the behavior changes needed for asyncIterable (where the concurrency setup iteration of asyncIterable has to be awaited to prevent inifinte runners from being created)
  - The test, in the state it's in in this PR, does not actually demonstrate that stop on error works as intended
huntharo added a commit to pwrdrvr/p-map that referenced this issue Sep 12, 2021
- Expand capabilities to handle both async and sync iterables
- There is a problem in the original functionality around the `stop-on-error` test that needs to be resolved
  - The test has a bug in that neither p-map nor the test mapper function, which is provided for that specific test and is not the common version, await the calling of the delay() function for item 2
  - This means that item 2 will only ever return a Promise, never a value
  - When this is fixed to await the function call, it causes the returned results to change from `[1, 3]` to `[1, 3, 2]`
  - Fixing this test makes it clear that the `concurrency setup` loop does not wait for mappers, so the only way to make this test fail would be to have enough items that eventually the initial iteration could not reach the last items in the test array before the 100 ms delay on the exception expires
  - With `concurrency = 1` this test behaves as expected since there are not unlimited unawaited promises created
  - Let me know your thoughts on how to resolve this as it becomes more apparent with the behavior changes needed for asyncIterable (where the concurrency setup iteration of asyncIterable has to be awaited to prevent inifinte runners from being created)
  - The test, in the state it's in in this PR, does not actually demonstrate that stop on error works as intended
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants