Async Auto Context

Running async.auto() steps functions in a custom context.

by andypotanin

HTML

<script src="http://ud-cdn.com/js/async/latest/async.js"></script>

JavaScript

function Context() {
    console.clear();
    this.data = "My Data";
    return this;
}

var Context = new Context;

var tasks = {
    'One': [ function( next, report ) { 
        next( null, this );                                   
    }.bind( Context ) ],
    'Two': [ function( next, report ) { 
        next( null, 'TwoWorks' ); 
    }.bind( Context )],    
    'Three': [ 'Two', function( next, report ) { 
        next( null, 'ThreeWorks' ); 
    }.bind( Context )]
}

function Callback( error, report ) {
    console.dir( report );
}
                
async.auto( tasks, Callback )