index.js
function readIntoBuf(stream) {
  return new Promise((resolve, reject) => {
    const chunks = []

    stream.on('data', chunk => {
      chunks.push(chunk)
    })

    stream.on('error', err => {
      reject(err)
    })

    stream.on('end', () => {
      resolve(Buffer.concat(chunks))
    })
  })
}
function readIntoBuf(stream) {
  return new Promise((resolve, reject) => {
    const chunks = []

    stream.on('data', chunk => {
      chunks.push(chunk)
    })

    stream.on('error', err => {
      reject(err)
    })

    stream.on('end', () => {
      resolve(Buffer.concat(chunks))
    })
  })
}
function readIntoBuf ( stream ) { return new Promise ( ( resolve , reject ) => { const chunks = [ ] stream . on ( 'data' , chunk => { chunks . push ( chunk ) } ) stream . on ( 'error' , err => { reject ( err ) } ) stream . on ( 'end' , ( ) => { resolve ( Buffer . concat ( chunks ) ) } ) } ) }
Produces a Promise that consumes a Readable entirely into a Buffer
Produces a Promise that consumes a Readable entirely into a Buffer