Skip to content

Commit 99087ab

Browse files
committed
chore: improve asyncEnumerable.WithBuffer.
1 parent 04c4aec commit 99087ab

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/Stl/Channels/EnumerableExt.cs

+6
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ public static IAsyncEnumerable<T> WithBuffer<T>(
1818
bool allowSynchronousContinuations,
1919
CancellationToken cancellationToken = default)
2020
{
21+
if (bufferSize < 1)
22+
return source;
23+
2124
var buffer = source.ToBoundedChannel(new(bufferSize) {
2225
SingleReader = true,
2326
SingleWriter = true,
@@ -31,6 +34,9 @@ public static IAsyncEnumerable<T> WithBuffer<T>(
3134
BoundedChannelOptions options,
3235
CancellationToken cancellationToken = default)
3336
{
37+
if (options.Capacity < 1)
38+
return source;
39+
3440
var buffer = source.ToBoundedChannel(options, cancellationToken);
3541
return buffer.Reader.ReadAllAsync(cancellationToken);
3642
}

0 commit comments

Comments
 (0)