Socket
Socket
Sign inDemoInstall

promise2stream

Package Overview
Dependencies
12
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    promise2stream

Transform ES2015 Promise to Stream - specifically, Transform Stream using [through2][]. Works in object mode by default, but you can pass options directly to the [through2][] package.


Version published
Maintainers
1
Install size
222 kB
Created

Changelog

Source

1.0.1 - 2016-05-08

  • Release v1.0.1 / npm@v1.0.1
  • add few ensurance tests
  • switch again to assertit, because mukla does some strange things/bugs
  • update related libs and usage example

Readme

Source

promise2stream npmjs.com The MIT License npm downloads

Transform ES2015 Promise to Stream - specifically, Transform Stream using through2. Works in object mode by default, but you can pass options directly to the through2 package.

code climate standard code style travis build status coverage status dependency status

Install

npm i promise2stream --save

Usage

For more use-cases see the tests

const promise2stream = require('promise2stream')

promise2stream

Transform a Promise val to transform stream.

Params

  • val {Promise}: Some promise.
  • opts {Object}: Options passed directly to through2.
  • returns {Stream}

Example

var promise2stream = require('promise2stream')
var promise = Promise.resolve(123)

var stream = promise2stream(promise)
stream
  .on('data', function (val) {
    console.log(val) // => 123
  })
  .once('error', console.error)
  .once('end', function () {
    console.log('end')
  })

// or access the promise
stream.promise.then(function (val) {
  console.log(val) // => 123
}, console.error)

// rejected promise fires `error` event
var rejectedPromise = Promise.reject(new Error('foo err'))
var stream = promise2stream(rejectedPromise)

stream.once('error', function (err) {
  console.log(err) // => [Error: foo err]
})

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
But before doing anything, please read the CONTRIBUTING.md guidelines.

Charlike Make Reagent new message to charlike freenode #charlike

tunnckoCore.tk keybase tunnckoCore tunnckoCore npm tunnckoCore twitter tunnckoCore github

Keywords

FAQs

Last updated on 08 May 2016

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