Skip to content

jamen/pull-await

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pull-await NPM version Build Status

Await promises in a pull-stream.

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

$ npm install --save pull-await

Usage

Pull promises, thenable objects, or regular through and await those necessary.

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

About

Await promises in a pull-stream.

Resources

License

Stars

Watchers

Forks

Packages

No packages published