Consume a stream of data into a binary Buffer as efficiently as possible
npm install fast-stream-to-bufferConsume a stream of data into a binary Buffer as efficiently as
possible.


```
npm install fast-stream-to-buffer --save
Process an abitrary readable stream:
`js
const streamToBuffer = require('fast-stream-to-buffer')
streamToBuffer(stream, function (err, buf) {
if (err) throw err
console.log(buf.toString())
})
`
Or use the onStream() helper function:
`js
const http = require('http')
const streamToBuffer = require('fast-stream-to-buffer')
// http.get expects a callback as the 2nd argument that will be called`
// with a readable stream of the response
http.get('http://example.com', streamToBuffer.onStream(function (err, buf) {
if (err) throw err
console.log(buf.toString('utf8'))
})
Arguments:
- stream - Any readable streamcallback
- - A callback function which will be called with an optionalstream
error object as the first argument and a buffer containing the content
of the as the 2nd
Returns a function fn which expects a readable stream as its onlystreamToBuffer()
argument. When called, it will automatically call callback` as the second.
with the stream as the first argument and the
MIT