public static IDataflow <Either <TLeft, IList <TRight> > > BufferSafe <TLeft, TRight>( this IDataflow <Either <TLeft, TRight> > source, TimeSpan batchTimeout, int count) { return(source .Buffer(batchTimeout, count) .SelectMany(batch => batch .GroupBy(item => item.IsRight) .SelectMany(group => group.Key ? List( Right <TLeft, IList <TRight> >( group.Rights().ToList())) : group .Lefts() .Select(Left <TLeft, IList <TRight> >)))); }