-
Notifications
You must be signed in to change notification settings - Fork 30
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: implement takeWhile
function
#22
Conversation
@@ -141,6 +141,25 @@ trait SourceOps[+T] { this: Source[T] => | |||
|
|||
def take(n: Int)(using Ox, StageCapacity): Source[T] = transform(_.take(n)) | |||
|
|||
/** Takes elements from the source as long as predicate `f` is satisfied (returns `true`). Note that once the predicate `f` is not |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as in the others - I would change the wording a bit to indicate that the returned source is a separate one. E.g. Forwards the elements from this source to the return one, as along ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're using "sends to the returned channel" in other operators, so let's use a similar wording here for consistency from the user's perspective.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Sends elements to the returned channel until predicate is satisfied. Note that if the predicate fails then subsequent elements are not longer taken even if they could still satisfy it. Example: Source.empty[Int].takeWhile(_ > 3).toList // List() Source.fromValues(1, 2, 3).takeWhile(_ < 3).toList // List(1, 2) Source.fromValues(3, 2, 1).takeWhile(_ < 3).toList // List()
379cd29
to
0b4455e
Compare
Sorry, needs merge |
Fixed 👍 |
Takes elements from the source as long as the predicate is satisfied. Note that if the predicate fails then subsequent elements are not longer taken even if they could still satisfy it.
Example: