|
|
@@ -4,19 +4,15 @@ using System.Threading.Tasks; |
|
|
|
|
|
|
|
namespace Discord |
|
|
|
{ |
|
|
|
/// <summary> An extension class for squashing <see cref="IAsyncEnumerable{T}"/>. </summary> |
|
|
|
public static class AsyncEnumerableExtensions |
|
|
|
{ |
|
|
|
/// <summary> |
|
|
|
/// Flattens the specified pages into one <see cref="IEnumerable{T}"/> asynchronously |
|
|
|
/// </summary> |
|
|
|
/// <typeparam name="T"></typeparam> |
|
|
|
/// <param name="source"></param> |
|
|
|
/// <returns></returns> |
|
|
|
/// <summary> Flattens the specified pages into one <see cref="IEnumerable{T}"/> asynchronously. </summary> |
|
|
|
public static async Task<IEnumerable<T>> FlattenAsync<T>(this IAsyncEnumerable<IEnumerable<T>> source) |
|
|
|
{ |
|
|
|
return await source.Flatten().ToArray().ConfigureAwait(false); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary> Flattens the specified pages into one <see cref="IAsyncEnumerable{T}"/>. </summary> |
|
|
|
public static IAsyncEnumerable<T> Flatten<T>(this IAsyncEnumerable<IEnumerable<T>> source) |
|
|
|
{ |
|
|
|
return source.SelectMany(enumerable => enumerable.ToAsyncEnumerable()); |
|
|
|