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

feat: Add an addOne argument to takeWhile #156

Merged
merged 1 commit into from
Mar 27, 2023
Merged

Conversation

kitten
Copy link
Member

@kitten kitten commented Mar 26, 2023

Summary

I realised this is impossible to express without a takeUntil and share operator, but is sometimes pretty handy, e.g. to say "take values until predicate returns false, but include the ending value".

This adds an addOne?: boolean argument to takeWhile which allows the first value that fails the predicate to also be issued on the output Source rather than being omitted.

This comes in handy for GraphQL’s incremental results, e.g. to express takeWhile(result => !!result.hasNext). This is important, since the first result in GraphQL may pass !hasNext but will still contain new data. It's also, while implied in the spec, not guaranteed that the last result with hasNext: false won't carry a new result.

Set of changes

  • Add an addOne argument to takeWhile

@kitten kitten merged commit acbba9a into main Mar 27, 2023
@kitten kitten deleted the feat/takewhile-addone-arg branch March 27, 2023 14:10
@github-actions github-actions bot mentioned this pull request Mar 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant