Skip to content

mafintosh/stream-collector

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

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

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published