stream-with-known-length-to-buffer
![javascript style guide](https://camo.githubusercontent.com/bde227e3207c7143032c0feb73889ffbda8eb1ef234b820b915ccaf74f9c66d7/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f636f64655f7374796c652d7374616e646172642d627269676874677265656e2e737667)
Convert a Readable Stream with a known length into a Buffer
This package converts a Readable Stream into a Buffer, with just one Buffer allocation (excluding allocations done internally by the streams implementation).
This is lighter-weight choice than stream-to-array
when the total stream length is known in advance. This whole package is 15 lines.
This module is used by WebTorrent.
install
npm install stream-with-known-length-to-buffer
usage
var toBuffer = require('stream-with-known-length-to-buffer')
toBuffer(fs.createReadStream('file.txt'), 1000, function (err, buf) {
if (err) return console.error(err.message)
console.log(buf)
})
license
MIT. Copyright (c) Feross Aboukhadijeh.