Skip to content

Commit 1b7c546

Browse files
Added useful simplified overloads.
1 parent 4a586e7 commit 1b7c546

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

Open.ChannelExtensions/Extensions.Pipe.cs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,14 @@ public static ChannelReader<T> PipeFilter<T>(this ChannelReader<T> source,
381381
return matchedChannel.Reader;
382382
}
383383

384+
/// <inheritdoc cref="PipeFilter{T}(ChannelReader{T}, out ChannelReader{T}, ChannelOptions, int, Func{T, bool}, CancellationToken)"/>
385+
public static ChannelReader<T> PipeFilter<T>(this ChannelReader<T> source,
386+
out ChannelReader<T> unmatched,
387+
ChannelOptions options,
388+
Func<T, bool> predicate,
389+
CancellationToken cancellationToken = default)
390+
=> PipeFilter(source, out unmatched, options, 1, predicate, cancellationToken);
391+
384392
/// <inheritdoc cref="PipeFilter{T}(ChannelReader{T}, out ChannelReader{T}, ChannelOptions, int, Func{T, bool}, CancellationToken)"/>
385393
public static ChannelReader<T> PipeFilterAsync<T>(this ChannelReader<T> source,
386394
out ChannelReader<T> unmatched,
@@ -416,6 +424,14 @@ public static ChannelReader<T> PipeFilterAsync<T>(this ChannelReader<T> source,
416424
return matchedChannel.Reader;
417425
}
418426

427+
/// <inheritdoc cref="PipeFilterAsync{T}(ChannelReader{T}, out ChannelReader{T}, ChannelOptions, int, Func{T, ValueTask{bool}}, CancellationToken)"/>
428+
public static ChannelReader<T> PipeFilterAsync<T>(this ChannelReader<T> source,
429+
out ChannelReader<T> unmatched,
430+
ChannelOptions options,
431+
Func<T, ValueTask<bool>> predicate,
432+
CancellationToken cancellationToken = default)
433+
=> PipeFilterAsync(source, out unmatched, options, 1, predicate, cancellationToken);
434+
419435
/// <param name="source">The asynchronous source data to use.</param>
420436
/// <param name="unmatched">Channel containing the unmatched items</param>
421437
/// <param name="capacity">
@@ -438,6 +454,14 @@ public static ChannelReader<T> PipeFilter<T>(this ChannelReader<T> source,
438454
return PipeFilter(source, out unmatched, options, maxConcurrency, predicate, cancellationToken);
439455
}
440456

457+
/// <inheritdoc cref="PipeFilter{T}(ChannelReader{T}, out ChannelReader{T}, int, int, Func{T, bool}, CancellationToken)"/>
458+
public static ChannelReader<T> PipeFilter<T>(this ChannelReader<T> source,
459+
out ChannelReader<T> unmatched,
460+
int capacity,
461+
Func<T, bool> predicate,
462+
CancellationToken cancellationToken = default)
463+
=> PipeFilter(source, out unmatched, capacity, 1, predicate, cancellationToken);
464+
441465
/// <inheritdoc cref="PipeFilter{T}(ChannelReader{T}, out ChannelReader{T}, int, int, Func{T, bool}, CancellationToken)"/>
442466
public static ChannelReader<T> PipeFilterAsync<T>(this ChannelReader<T> source,
443467
out ChannelReader<T> unmatched,
@@ -449,4 +473,12 @@ public static ChannelReader<T> PipeFilterAsync<T>(this ChannelReader<T> source,
449473
var options = CreateOptions(capacity, false, false, maxConcurrency == 1);
450474
return PipeFilterAsync(source, out unmatched, options, maxConcurrency, predicate, cancellationToken);
451475
}
476+
477+
/// <inheritdoc cref="PipeFilter{T}(ChannelReader{T}, out ChannelReader{T}, int, int, Func{T, bool}, CancellationToken)"/>
478+
public static ChannelReader<T> PipeFilterAsync<T>(this ChannelReader<T> source,
479+
out ChannelReader<T> unmatched,
480+
int capacity,
481+
Func<T, ValueTask<bool>> predicate,
482+
CancellationToken cancellationToken = default)
483+
=> PipeFilterAsync(source, out unmatched, capacity, 1, predicate, cancellationToken);
452484
}

0 commit comments

Comments
 (0)