Transform a stream into batched items.