Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2923182
test_async_coroutines.cjs
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
744 B
Referenced Files
None
Subscribers
None
test_async_coroutines.cjs
View Options
// Test async/await with coroutines
console.log("Starting async test");
async function delay(ms) {
return new Promise((resolve) => {
setTimeout(() => {
console.log(`Delayed ${ms}ms`);
resolve(`Result after ${ms}ms`);
}, ms);
});
}
async function main() {
console.log("Before await 1");
const result1 = await delay(100);
console.log("After await 1:", result1);
console.log("Before await 2");
const result2 = await delay(50);
console.log("After await 2:", result2);
return "All done!";
}
// Call the async function
main().then(result => {
console.log("Final result:", result);
}).catch(err => {
console.error("Error:", err);
});
console.log("After main() call (should execute before awaits)");
File Metadata
Details
Attached
Mime Type
text/x-c
Expires
Fri, Mar 27, 4:11 PM (2 d)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
512281
Default Alt Text
test_async_coroutines.cjs (744 B)
Attached To
Mode
rANT Ant
Attached
Detach File
Event Timeline
Log In to Comment