Package Exports
- than
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (than) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Than
Make your functions asynchronous by using the than
function !!!
I know, it's than
, not then
... but you still can use it to make your function async xD
Installation
Use the npm command
npm install than
Usage
This package adds a prototype function to the Function
object, to use it, you need to require it like this :
require('than');
Example
Here is an example showing you how this than
function can be used
Let's say you have a function with blocking code
function calculate(a, b) {
/*
Your code that might take too long to execute !
*/
return a + b;
}
So, instead of calling the function directly by passing two arguments, you can pass these arguments to the than
function and a callBack that receives the result of the main function.
console.log("Do something");
calculate.than(1, 2, function(result) {
console.log("Then display the result : ", result);
});
console.log("Do other thing");
If the calculate
function takes too long to finish its execution, the output of the code above would be :
Do something
Do other thing
Then display the result : 3