Skip to content

Commit 53640c5

Browse files
committed
Add TaskSeq.where and whereAsync as aliases to filter just like in Seq
1 parent c644f29 commit 53640c5

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

src/FSharp.Control.TaskSeq/TaskSeq.fs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,8 @@ type TaskSeq private () =
285285

286286
static member filter predicate source = Internal.filter (Predicate predicate) source
287287
static member filterAsync predicate source = Internal.filter (PredicateAsync predicate) source
288+
static member where predicate source = Internal.filter (Predicate predicate) source
289+
static member whereAsync predicate source = Internal.filter (PredicateAsync predicate) source
288290

289291
static member skip count source = Internal.skipOrTake Skip count source
290292
static member drop count source = Internal.skipOrTake Drop count source

src/FSharp.Control.TaskSeq/TaskSeq.fsi

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -725,6 +725,34 @@ type TaskSeq =
725725
/// <exception cref="T:ArgumentNullException">Thrown when the input task sequence is null.</exception>
726726
static member filterAsync: predicate: ('T -> #Task<bool>) -> source: TaskSeq<'T> -> TaskSeq<'T>
727727

728+
/// <summary>
729+
/// Returns a new task sequence containing only the elements of the collection
730+
/// for which the given function <paramref name="predicate" /> returns <see cref="true" />.
731+
/// If <paramref name="predicate" /> is asynchronous, consider using <see cref="TaskSeq.whereAsync" />.
732+
///
733+
/// Alias for <see cref="TaskSeq.filter" />.
734+
/// </summary>
735+
///
736+
/// <param name="predicate">A function to test whether an item in the input sequence should be included in the output or not.</param>
737+
/// <param name="source">The input task sequence.</param>
738+
/// <returns>The resulting task sequence.</returns>
739+
/// <exception cref="T:ArgumentNullException">Thrown when the input task sequence is null.</exception>
740+
static member where: predicate: ('T -> bool) -> source: TaskSeq<'T> -> TaskSeq<'T>
741+
742+
/// <summary>
743+
/// Returns a new task sequence containing only the elements of the input sequence
744+
/// for which the given function <paramref name="predicate" /> returns <see cref="true" />.
745+
/// If <paramref name="predicate" /> is synchronous, consider using <see cref="TaskSeq.where" />.
746+
///
747+
/// Alias for <see cref="TaskSeq.filterAsync" />.
748+
/// </summary>
749+
///
750+
/// <param name="predicate">An asynchronous function to test whether an item in the input sequence should be included in the output or not.</param>
751+
/// <param name="source">The input task sequence.</param>
752+
/// <returns>The resulting task sequence.</returns>
753+
/// <exception cref="T:ArgumentNullException">Thrown when the input task sequence is null.</exception>
754+
static member whereAsync: predicate: ('T -> #Task<bool>) -> source: TaskSeq<'T> -> TaskSeq<'T>
755+
728756
/// <summary>
729757
/// Returns a task sequence that, when iterated, skips <paramref name="count" /> elements of the underlying
730758
/// sequence, and then yields the remainder. Raises an exception if there are not <paramref name="count" />
@@ -742,7 +770,6 @@ type TaskSeq =
742770
/// </exception>
743771
static member skip: count: int -> source: TaskSeq<'T> -> TaskSeq<'T>
744772

745-
746773
/// <summary>
747774
/// Returns a task sequence that, when iterated, drops at most <paramref name="count" /> elements of the
748775
/// underlying sequence, and then returns the remainder of the elements, if any.

0 commit comments

Comments
 (0)