corunner

0.0.1 • Public • Published

CoRunner

corunner is a lightweight (<50 LOC) coroutine library, for use with javascript generators

Installation

npm install --save corunner

Usage

    let run = require('corunner');
    
    let func = run(function *(firstname, secondname) {
   
        // yield Promises for synchronous looking, async code
        let email = yield Promise.resolve('name@email.com');
 
        // the returned value will be resolve in the returned promise
        return `${firstname} ${secondname} ${email}`;
    });
    
    // func is now a function that returns a Promise
    func('Allan', 'Ross').then(description => {
        console.log(description === 'Allan Ross name@email.com')
    }).catch(console.error);

Dependents (0)

Package Sidebar

Install

npm i corunner

Weekly Downloads

0

Version

0.0.1

License

MIT

Last publish

Collaborators

  • mofax