pyield

0.4.5 • Public • Published

'pyield'

pyield is a node.js package for parallel execution of yield.

Follow me on github!

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);
});

Package Sidebar

Install

npm i pyield

Weekly Downloads

1

Version

0.4.5

License

MIT

Last publish

Collaborators

  • youjia