Socket
Socket
Sign inDemoInstall

stream-to-promise

Package Overview
Dependencies
5
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    stream-to-promise

Convert streams (readable or writable) to promises


Version published
Weekly downloads
719K
increased by1.56%
Maintainers
1
Install size
49.2 kB
Created
Weekly downloads
 

Readme

Source

stream-to-promise Build Status

Convert streams (readable or writable) to promises

Installing

npm install --save stream-to-promise

Examples

Readable Streams

streamToPromise(readableStream).then(function (buffer) {
  // buffer.length === 3
})
readableStream.emit('data', new Buffer())
readableStream.emit('data', new Buffer())
readableStream.emit('data', new Buffer())
readableStream.emit('end') // promise is resolved here

Writable Streams

streamToPromise(writableStream).then(function () {
  // resolves undefined
})
writableStream.write('data')
writableStream.end() // promise is resolved here

Error Handling

const err = new Error()
streamToPromise(stream).catch(function (error) {
  // error === err
})
stream.emit('error', err) // promise is rejected here

Keywords

FAQs

Last updated on 25 May 2020

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc