Socket
Socket
Sign inDemoInstall

promise2stream

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

promise2stream - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

33

index.js
/*!
* promise2stream <https://github.com/tunnckoCore/promise2stream>
* promise2stream <https://github.com/hybridables/promise2stream>
*

@@ -14,2 +14,33 @@ * Copyright (c) 2016 Charlike Mike Reagent <@tunnckoCore> (http://www.tunnckocore.tk)

/**
* > Transform a Promise `val` to transform stream.
*
* **Example**
*
* ```js
* 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)
* ```
*
* @param {Promise} `val` Some promise.
* @param {Object} `opts` Options passed directly to [through2][].
* @return {Stream}
* @api public
*/
module.exports = function promise2stream (val, opts) {

@@ -16,0 +47,0 @@ if (!isPromise(val)) {

39

package.json
{
"name": "promise2stream",
"version": "0.1.0",
"version": "0.2.0",
"description": "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.",
"repository": "tunnckoCore/promise2stream",
"repository": "hybridables/promise2stream",
"author": "Charlike Mike Reagent <@tunnckoCore> (http://www.tunnckocore.tk)",

@@ -19,2 +19,3 @@ "precommit.silent": true,

"devDependencies": {
"bluebird": "^3.3.5",
"is-buffer": "^1.1.3",

@@ -29,3 +30,21 @@ "is-node-stream": "^1.0.0",

"keywords": [
"promise2stream"
"always",
"array",
"boolean",
"buffer",
"create",
"everything",
"make",
"promise",
"promise-stream",
"promises",
"str",
"stream",
"string",
"through",
"transform",
"util",
"utils",
"val",
"value"
],

@@ -38,10 +57,11 @@ "verb": {

"list": [
"through2",
"limon",
"postcss",
"posthtml",
"postcss",
"stream-from-promise",
"limon",
"postjson",
"promise2thunk",
"thunk2promise"
"stream-from-promise",
"through2",
"thunk2promise",
"stream-to-promise"
]

@@ -55,3 +75,2 @@ },

},
"related.list": true,
"tasks": [

@@ -61,2 +80,2 @@ "readme"

}
}
}

@@ -19,2 +19,33 @@ # [promise2stream][author-www-url] [![npmjs.com][npmjs-img]][npmjs-url] [![The MIT License][license-img]][license-url] [![npm downloads][downloads-img]][downloads-url]

### [promise2stream](index.js#L45)
> Transform a Promise `val` to transform stream.
**Params**
* `val` **{Promise}**: Some promise.
* `opts` **{Object}**: Options passed directly to [through2][].
* `returns` **{Stream}**
**Example**
```js
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)
```
## Related

@@ -27,2 +58,3 @@ * [limon](https://www.npmjs.com/package/limon): The pluggable JavaScript lexer on per character basis. | [homepage](https://github.com/limonjs/limon)

* [stream-from-promise](https://www.npmjs.com/package/stream-from-promise): Create streams from promises | [homepage](https://github.com/schnittstabil/stream-from-promise)
* [stream-to-promise](https://www.npmjs.com/package/stream-to-promise): Convert streams (readable or writable) to promises | [homepage](https://github.com/bendrucker/stream-to-promise)
* [through2](https://www.npmjs.com/package/through2): A tiny wrapper around Node streams2 Transform to avoid explicit subclassing noise | [homepage](https://github.com/rvagg/through2)

@@ -32,3 +64,3 @@ * [thunk2promise](https://www.npmjs.com/package/thunk2promise): Transform or convert thunk to Bluebird Promise. | [homepage](https://github.com/tunnckocore/thunk2promise)

## Contributing
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/tunnckoCore/promise2stream/issues/new).
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/hybridables/promise2stream/issues/new).
But before doing anything, please read the [CONTRIBUTING.md](./CONTRIBUTING.md) guidelines.

@@ -45,3 +77,3 @@

[license-url]: https://github.com/tunnckoCore/promise2stream/blob/master/LICENSE
[license-url]: https://github.com/hybridables/promise2stream/blob/master/LICENSE
[license-img]: https://img.shields.io/npm/l/promise2stream.svg

@@ -52,13 +84,13 @@

[codeclimate-url]: https://codeclimate.com/github/tunnckoCore/promise2stream
[codeclimate-img]: https://img.shields.io/codeclimate/github/tunnckoCore/promise2stream.svg
[codeclimate-url]: https://codeclimate.com/github/hybridables/promise2stream
[codeclimate-img]: https://img.shields.io/codeclimate/github/hybridables/promise2stream.svg
[travis-url]: https://travis-ci.org/tunnckoCore/promise2stream
[travis-img]: https://img.shields.io/travis/tunnckoCore/promise2stream/master.svg
[travis-url]: https://travis-ci.org/hybridables/promise2stream
[travis-img]: https://img.shields.io/travis/hybridables/promise2stream/master.svg
[coveralls-url]: https://coveralls.io/r/tunnckoCore/promise2stream
[coveralls-img]: https://img.shields.io/coveralls/tunnckoCore/promise2stream.svg
[coveralls-url]: https://coveralls.io/r/hybridables/promise2stream
[coveralls-img]: https://img.shields.io/coveralls/hybridables/promise2stream.svg
[david-url]: https://david-dm.org/tunnckoCore/promise2stream
[david-img]: https://img.shields.io/david/tunnckoCore/promise2stream.svg
[david-url]: https://david-dm.org/hybridables/promise2stream
[david-img]: https://img.shields.io/david/hybridables/promise2stream.svg

@@ -65,0 +97,0 @@ [standard-url]: https://github.com/feross/standard

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