https://github.com/jamen/pull-await
Await promises in a pull-stream.
https://github.com/jamen/pull-await
Last synced: about 1 year ago
JSON representation
Await promises in a pull-stream.
- Host: GitHub
- URL: https://github.com/jamen/pull-await
- Owner: jamen
- License: mit
- Created: 2016-08-31T08:47:19.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2016-08-31T16:04:14.000Z (almost 10 years ago)
- Last Synced: 2025-04-09T17:58:04.746Z (about 1 year ago)
- Language: JavaScript
- Size: 4.88 KB
- Stars: 4
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# pull-await [](https://npmjs.org/package/pull-await) [](https://travis-ci.org/jamen/pull-await)
> Await promises in a pull-stream.
```javascript
pull(
pull.values([ 'hello', Promise.resolve('world') ]),
await, // use pull-await on promises or anything thenable.
pull.collect(function(err, res) {
t.same(res, ['hello', 'world']);
})
);
```
## Installation
```sh
$ npm install --save pull-await
```
## Usage
Pull promises, thenable objects, or regular through and await those necessary.
```js
await(function(err, cb) {
// Push promises to read for `await`
cb(null, new Promise(r => setTimeout(() => r('hello'), 1000)));
cb(null, Promise.resolve('cool'));
cb(null, 'yay!');
cb(true);
})(null, function(err, data) {
if (err === true) return;
if (err) throw err;
// Log awaited data.
console.log(data);
});
```
## License
MIT © [Jamen Marz](https://github.com/jamen)