From 47f720899d265042afb0a01574fdcff9554a5970 Mon Sep 17 00:00:00 2001 From: "Namhyeon, Go" Date: Sun, 5 Jun 2022 19:53:54 +0900 Subject: [PATCH] Updated AsyncFunction (markdown) --- AsyncFunction.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/AsyncFunction.md b/AsyncFunction.md index 293eaaa..04ecc7b 100644 --- a/AsyncFunction.md +++ b/AsyncFunction.md @@ -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; +``` \ No newline at end of file