https://github.com/jamen/pull-collect-promise
Pull-stream sink that collects values into an array then returns a promise.
https://github.com/jamen/pull-collect-promise
Last synced: about 1 year ago
JSON representation
Pull-stream sink that collects values into an array then returns a promise.
- Host: GitHub
- URL: https://github.com/jamen/pull-collect-promise
- Owner: jamen
- License: mit
- Created: 2018-04-21T19:32:57.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-04-21T19:33:13.000Z (about 8 years ago)
- Last Synced: 2025-02-08T02:24:25.068Z (over 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 4.88 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# pull-collect-promise
[Pull-stream sink][1] that collects values into an array then returns a promise. allowing you to interop between pull-streams and promises.
## Install
```sh
npm i pull-collect-promise
```
## Usage
### `collectPromise()`
Returns a sink stream that returns a promise.
```js
const { pull, map, values } = require('pull-stream')
const collectPromise = require('pull-collect-promise')
const foo = pull(
values([ 1, 2, 3, 4 ]),
map(x => x * 3),
collectPromise()
)
foo.then(results => {
t.same(results, [ 3, 6, 9, 12 ])
})
```
[1]: https://github.com/pull-stream/pull-stream/blob/master/docs/spec.md#sink-streams