public async Task <Terminator <TReduction> > CompleteAsync(TReduction reduction) { var terminator = await Next.CompleteAsync(reduction).ConfigureAwait(false); var terminated = CheckTermination(terminator); return(Reduction(terminator.Value, terminated: terminated)); }
public static async Task <Terminator <TReduction> > ReduceAsync <TInput, TReduction>( this IEnumerable <TInput> input, TReduction reduction, IAsyncReducer <TReduction, TInput> reducer) { var terminator = Terminator.Reduction(reduction); foreach (var value in input) { terminator = await reducer.InvokeAsync(terminator.Value, value).ConfigureAwait(false); if (terminator.IsTerminated) { return(terminator); } } return(await reducer.CompleteAsync(terminator.Value).ConfigureAwait(false)); }
public Task <Terminator <TReduction> > CompleteAsync(TReduction reduction) => Next.CompleteAsync(reduction);