asyncly

A fluent way of asynchronously running functions

asyncly

A fluent way of asynchronously running functions

Installation

$ npm install asyncly --save

Usage

function doSomething() {
    return 'result of doing something';
}
 
asyncly( doSomething ).then(function(result) {
    console.log(result); // => outputs 'result of doing something ' 
});

Arguments can also be passed to the function that will be asyncly executed by passing it as extra arguments of asyncly(func, arg1, arg2...)

function doSomething(val1val2) {
    return 'result of doing something ' + val1 + ' ' + val2;
}
 
asyncly( doSomething, 'very', 'expensive' ).then(function(result) {
    console.log(result); // => outputs 'result of doing something very expensive' 
});

The following sugar methods are also supported and they work exactly as the asyncly(...) variant

asyncly.run(someRoutine);
asyncly.get(something);
asyncly.gotten(resource.at, 'http://some.service.com');