Buffer data from a stream into an array if a callback is provided