Nationwide Polamorous Matrimony

    coify

    0.1.2 • Public • Published

    coify

    Build Status

    Transform generator methods into co-wrapped functions.

    Installing

    npm install --save coify
    

    Examples

    Plain JavaScript objects
    const coify = require('coify');
     
    function delay( n ) {
      return new Promise(function( resolve, reject ) {
        setTimeout( resolve, n );
      });
    }
     
    let obj = {
      *asyncStuff() {
        yield delay( 500 );
        return true;
      }
    };
     
    module.exports = coify( obj );
     
    // ...
     
    obj.asyncStuff().then( console.log ); // `true`
    Classes/Constructors
    const coify = require('coify');
     
    function delay( n ) {
      return new Promise(function( resolve, reject ) {
        setTimeout( resolve, n );
      });
    }
     
    class Thing {
      *asyncStuff() {
        yield delay( 500 );
        return true;
      }
    }
     
    module.exports = coify( Thing );
     
    // ...
     
    const thing = new Thing();
    thing.asyncStuff().then( console.log ); // `true`

    Keywords

    Install

    npm i coify

    DownloadsWeekly Downloads

    5

    Version

    0.1.2

    License

    MIT

    Last publish

    Collaborators

    • kevincennis
    • spmurrayzzz