Unleash awesomeness. Private packages, team management tools, and powerful integrations. Get started with npm Orgs »

yield-yield

1.3.1 • Public • Published

var o_o = yield (yield)(); Build Status

NPM

Double yield ( yield-yield ) helps you to organize asynchronously written code by structuring it sequentially without need to wrap or change your existing code.

var superagent = require('superagent');
var o_o = require('yield-yield');
var fs = require('fs');
 
module.exports = o_o(function *() {
 
    //
    // Read file from fs
    //
    try {
      var content = yield fs.readFile('/etc/hosts', { encoding: 'utf8'}, yield);
    } catch (e) {
      console.log('Unable to read file', e);
    }
 
    //
    // Pause for a second
    //
    yield setTimeout(yield, 1000);
 
    //
    // Make the request to the server
    //
    var response = yield superagent
      .get('/api/pet')
      .end(yield);
 
    //
    // Do some more  async stuff
    //
 
});

Read full Documentation

install

npm i yield-yield

Downloadsweekly downloads

38

version

1.3.1

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability