node package manager
Stop wasting time. Easily manage code sharing in your team. Create a free org »

pond

pond

Collect a stream into a buffer.

Please aware that, because buffers came out from a stream are buffered into the memory, DO NOT try to collect a stream that is large or with unknowable length!

Requirements

Node >= 0.12, also tested on Node 4 ~ Node 8.

Installation

npm install pond

Usage

Piping:

fs.createReadStream('somefile')
  .pipe(pond())
  .spoon(function (buffer) {
    // ...
  })

Or:

pond(fs.createReadStream('anotherfile'), function (err, buffer) {
  // ...
})

Promise, await

let buffer = await stream.pipe(pond()).spoon()
let buffer = await pond(stream).spoon()

Test

npm test

License

This project is released under the terms of MIT License.