Socket
Socket
Sign inDemoInstall

stream-collector

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stream-collector

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


Version published
Weekly downloads
32K
decreased by-3.88%
Maintainers
1
Weekly downloads
 
Created
Source

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

FAQs

Package last updated on 15 Nov 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc