New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

yield-yield

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

yield-yield

Sequential writing of asynchronous code

latest
Source
npmnpm
Version
1.3.1
Version published
Weekly downloads
314
67.91%
Maintainers
1
Weekly downloads
 
Created
Source

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

Keywords

async

FAQs

Package last updated on 06 Sep 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts