Skip to content

Commit

Permalink
Add TaskSeq.where and whereAsync as aliases to filter just like…
Browse files Browse the repository at this point in the history
… in `Seq`
  • Loading branch information
abelbraaksma committed Dec 20, 2023
1 parent 7d6e367 commit 1692d6e
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/FSharp.Control.TaskSeq/TaskSeq.fs
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,8 @@ type TaskSeq private () =

static member filter predicate source = Internal.filter (Predicate predicate) source
static member filterAsync predicate source = Internal.filter (PredicateAsync predicate) source
static member where predicate source = Internal.filter (Predicate predicate) source
static member whereAsync predicate source = Internal.filter (PredicateAsync predicate) source

static member skip count source = Internal.skipOrTake Skip count source
static member drop count source = Internal.skipOrTake Drop count source
Expand Down
31 changes: 29 additions & 2 deletions src/FSharp.Control.TaskSeq/TaskSeq.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -725,10 +725,38 @@ type TaskSeq =
/// <exception cref="T:ArgumentNullException">Thrown when the input task sequence is null.</exception>
static member filterAsync: predicate: ('T -> #Task<bool>) -> source: TaskSeq<'T> -> TaskSeq<'T>

/// <summary>
/// Returns a new task sequence containing only the elements of the collection
/// for which the given function <paramref name="predicate" /> returns <see cref="true" />.
/// If <paramref name="predicate" /> is asynchronous, consider using <see cref="TaskSeq.whereAsync" />.
///
/// Alias for <see cref="TaskSeq.filter" />.
/// </summary>
///
/// <param name="predicate">A function to test whether an item in the input sequence should be included in the output or not.</param>
/// <param name="source">The input task sequence.</param>
/// <returns>The resulting task sequence.</returns>
/// <exception cref="T:ArgumentNullException">Thrown when the input task sequence is null.</exception>
static member where: predicate: ('T -> bool) -> source: TaskSeq<'T> -> TaskSeq<'T>

/// <summary>
/// Returns a new task sequence containing only the elements of the input sequence
/// for which the given function <paramref name="predicate" /> returns <see cref="true" />.
/// If <paramref name="predicate" /> is synchronous, consider using <see cref="TaskSeq.where" />.
///
/// Alias for <see cref="TaskSeq.filterAsync" />.
/// </summary>
///
/// <param name="predicate">An asynchronous function to test whether an item in the input sequence should be included in the output or not.</param>
/// <param name="source">The input task sequence.</param>
/// <returns>The resulting task sequence.</returns>
/// <exception cref="T:ArgumentNullException">Thrown when the input task sequence is null.</exception>
static member whereAsync: predicate: ('T -> #Task<bool>) -> source: TaskSeq<'T> -> TaskSeq<'T>

/// <summary>
/// Returns a task sequence that, when iterated, skips <paramref name="count" /> elements of the underlying
/// sequence, and then yields the remainder. Raises an exception if there are not <paramref name="count" />
/// items. See <see cref="drop" /> for a version that does not raise an exception.
/// items. See <see cref="TaskSeq.drop" /> for a version that does not raise an exception.
/// See also <see cref="take" /> for the inverse of this operation.
/// </summary>
///
Expand All @@ -742,7 +770,6 @@ type TaskSeq =
/// </exception>
static member skip: count: int -> source: TaskSeq<'T> -> TaskSeq<'T>


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

0 comments on commit 1692d6e

Please sign in to comment.