feat(stream-helpers): add take, takeWhile, and takeUntil helpers#136
Open
feat(stream-helpers): add take, takeWhile, and takeUntil helpers#136
Conversation
commit: |
28ca45f to
63fde31
Compare
Adds three new stream transformer helpers for limiting/filtering streams: - take(n): Yields first n values, closes with nth value. Curried for pipe compatibility. - takeWhile(predicate): Yields while predicate is true, closes with source close value. - takeUntil(predicate): Yields until predicate is true, closes with matching value. These helpers enable composable stream limiting patterns, particularly useful for validation flows where you iterate until a terminal status. Also adds build directories to biome ignore list.
63fde31 to
5f9f17d
Compare
Member
Author
|
@claude can you review this PR for policy compliance |
Policy Compliance AssessmentSummary
✅ All items compliant - no violations foundItems ReviewedTest Files
Implementation Files
Documentation & Configuration
Policy Compliance DetailsNo-Sleep Test Synchronization Policy (Recommended)All three test files properly use Examples of compliant patterns found:
Stateless Stream Operations Policy (Recommended)All three implementation files correctly use the Examples of compliant patterns found:
ConclusionThis PR demonstrates excellent adherence to both applicable policies:
No violations found. ✅ Policy review completed by Policy Compliance Agent |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds three new stream transformer helpers for limiting/filtering streams:
take(n): Yields the firstnvalues, then closes with the nth value as the close value.takeWhile(predicate): Yields values while the predicate returns true. Closes immediately when the predicate fails (does not include the failing value).takeUntil(predicate): Yields values until the predicate returns true. Closes with the matching value (includes it as the close value).All helpers use curried style for pipe compatibility.
Use Cases
take- Limit stream to first N valuestakeWhile- Take values while condition holdstakeUntil- Iterate until terminal condition (wizard validation pattern)Key Difference:
takeWhilevstakeUntiltakeWhileundefinedtakeUntilThe
takeUntilpattern is particularly useful for validation flows where the matching value (e.g.,{status: "valid", data: ...}) carries meaningful data you want to use.Notes
take(n)(stream)streamOf()for simpler, synchronous test casestakeWhileno longer drains the stream when predicate fails