Skip to content
This repository has been archived by the owner on Oct 8, 2024. It is now read-only.

Which methods should be async? #165

Closed
ronag opened this issue Nov 18, 2021 · 5 comments
Closed

Which methods should be async? #165

ronag opened this issue Nov 18, 2021 · 5 comments

Comments

@ronag
Copy link

ronag commented Nov 18, 2021

We're working on this proposal for node streams at nodejs/node#40815

Question. What methods do we think make sense to allow async for?

List of candidates:

  • map (Promise)
  • filter (Promise)
  • flatMap (AsyncGenerator)
  • reduce (Promise)
  • forEach (Promise)
  • some (Promise)
  • every (Promise)
@benjamingr
Copy link
Contributor

All of them according to the spec text if I am reading it correctly - though I think for flatMap it would make sense to also take another stream (though really, that is transparent given streams are async iterable).

@Jack-Works
Copy link
Member

what about .toAsync() to convert a sync iterator to async?

@benjamingr
Copy link
Contributor

@Jack-Works as sugar for (async function*() { yield* gen; })().?

@Jamesernator
Copy link

@Jack-Works as sugar for (async function*() { yield* gen; })().?

The spec does have AsyncIterator.from for this purpose, although would it be more desirable to have it as a method as well/in place of?

@michaelficarra
Copy link
Member

All of these methods are currently on %AsyncIterator.prototype%, and should be. As for the AsyncIterator.from shorthand question, see #160.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants