Skip to content
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

Deprecate generator transforms? #32

Open
mbostock opened this issue Apr 19, 2018 · 0 comments
Open

Deprecate generator transforms? #32

mbostock opened this issue Apr 19, 2018 · 0 comments
Labels
question Further information is requested

Comments

@mbostock
Copy link
Member

mbostock commented Apr 19, 2018

We currently provide two utility methods for creating a new Generator from an iterator: Generators.filter and Generators.map. There are a few problems with these methods:

  1. If the input iterator is a Generator, the returned Generator does not wrap generator.return and generator.throw. Possibly, these methods should return an Iterator rather than a Generator, and be moved to Iterators.filter and Iterators.map. Or, these methods could “upgrade” an iterator to a generator, and wrap the return and throw methods as expected.

  2. If the input iterator iterates over promises, the generator doesn’t wait for the promise to resolve. Coming from Observable, we somewhat expect the test or transform functions to be passed resolved values rather than Promise objects. However, in the case of Generators.filter, it’s not clear how that should work, since the test function might return false for the last promise, but it’s too late because the generator has already yielded a promise!

  3. If the input iterator is an async iterator (i.e., iterator.next returns a Promise), these methods don’t work at all.

It’s possible that the simplest thing to do would be to deprecate these methods along with the deprecated DOM methods #31. I haven’t found them especially useful, and given the desire to keep the standard library small, it might be good to prune them.

@mbostock mbostock changed the title Generalize generator transforms? Deprecate generator transforms? Apr 19, 2018
@mbostock mbostock added the question Further information is requested label Jun 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant