Skip to content
Execute thunks in parallel and return after any of them return
JavaScript Makefile
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
test
.gitignore
.travis.yml
History.md
LICENSE
Makefile
README.md
example.js
index.js
package.json

README.md

co-any

Build Status

Execute thunks in parallel and return after any of them return

Install

npm install co-any

Usage

var wait = require('co-wait');
var generators = [wait(200), wait(100), wait(300)];

yield any(generators);
// or
yield any(wait(50), wait(100));
// or
yield any({
  first: wait(200),
  second: wait(100)
});

also you can pass thunk, generatorFunction and promise into any.

=>

{
  _key: 'key',
  value: 'value'
}

Example

var wait = require('co-wait');
var co = require('co');
var any = require('co-any');

co(function *() {
  console.time('any');
  yield any(wait(200), wait(100), wait(300));
  console.timeEnd('any'); // should arond 100ms
})();

License

MIT

You can’t perform that action at this time.