stream-collector
Buffer data from a stream into an array if a callback is provided
Last updated 10 years ago by mafintosh .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install stream-collector 
SYNC missed versions from official npm registry.

stream-collector

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

npm install stream-collector

build status

Usage

var collect = require('stream-collector')

collect(stream, function(err, list) {
  // list contains all data chunks from stream  
})

The stream is always returned from the function. If a callback isn't provided no buffering will occur. This allows you to do the following pattern where if you provide a callback the stream will be buffered (similar to how request works)

var read = function(cb) {
  var stream = db.createReadStream()
  return collect(stream, cb)
}

var stream = read() // does not buffer

read(function(err, list) {
  // buffers the data
})

License

MIT

Current Tags

  • 1.0.1                                ...           latest (10 years ago)

2 Versions

  • 1.0.1                                ...           10 years ago
  • 1.0.0                                ...           10 years ago
Maintainers (1)
Downloads
Total 0
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (1)
Dev Dependencies (2)

© 2010 - cnpmjs.org x YWFE | Home | YWFE