Updated AsyncFunction (markdown)

Namhyeon Go 2022-06-05 19:53:54 +09:00
parent a855b90acd
commit 47f720899d

@ -4,6 +4,7 @@ JScript does not support the `async` keyword. So, WelsonJS uses the `AsyncFuncti
### Examples
#### In the webbrowser
```js
var STD = require("lib/std");
@ -18,3 +19,23 @@ function main(args) {
exports.main = main;
```
#### In the console
```
function main(args) {
[5, 4, 3, 2, 1].forEach(function(x) {
new AsyncFunction('sub_01', 'mymodule').run(x);
});
}
function _async_sub_01(args) {
var x = args[0];
sleep(x * 1000);
console.log(x);
}
exports.main = main;
exports._async_sub_01 = _async_sub_01;
```