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

don't preserve the generator protocol for helper-produced iterators #194

Merged
merged 4 commits into from Jul 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 11 additions & 0 deletions README.md
Expand Up @@ -335,6 +335,17 @@ const wrapper = Iterator.from(iter);
wrapper.next() // { value: 1, done: false }
```

## Iterator helpers and the generator protocol

The generator protocol facilitates coordination between a producer and a
consumer, which is necessarily broken by iteration-based transforms. There is
no way to properly preserve or re-establish this coordination. We've taken the
philosophy that any iterators produced by the helpers this proposal adds only
implement the iterator protocol and make no attempt to support generators which
use the remainder of the generator protocol. Specifically, such iterators do
not implement `.throw` and do not forward the parameter of `.next` or `.return`
to an underlying or "source" iterator.

## More Example Usage

### Lazy Iteration over sets
Expand Down