pyield
v0.4.5
Published
Parallel execution of yield
Downloads
8
Readme
#'pyield'
pyield is a node.js package for parallel execution of yield.
Usage
npm install pyield
example:
require("babel/polyfill"); // ES6 generator support in Babel
let Promise = require("bluebird")
var co = Promise.coroutine;
var Redis = require('ioredis');
let pyield = require('pyield');
console.log('test runs')
let redis = new Redis({
port: 6379, // Redis port
host: '127.0.0.1' // Redis host
});
let parallelAsync = Promise.promisify(pyield.parallel, pyield);
let hco = co(function* () {
redis.set('a', 'hello a');
redis.set('b', 'hello b');
redis.set('c', 'hello c');
//console.log(yield redis.get('c'));
let allrel = yield parallelAsync([
{obj: redis, func: redis.get, param:['a']}
,{obj: redis, func: redis.get, param:['b']}
,{obj: redis, func: redis.get, param:['c']}]);
console.log(allrel);
});
hco().then( function() {
}).catch(function(e){
console.error(e);
});