markdown + mermaid is becoming a de-facto documentation + visualization for open source and other code solutions, both in IDEs and on the web
Markdown Preview Mermaid Support - Visual Studio Marketplace
Markdown Preview Mermaid SupportMatt Bierner | 3,811,890 installs
TypeScript
async function sleep(ms: number): Promise<void> {
return new Promise(resolve => setTimeout(resolve, ms));
}
async function countdown(): Promise<void> {
for (let i: number = 3; i > 0; i--) {
console.log(i + "... ");
await sleep(1000);
}
console.log("liftoff");
}
countdown();
Countdown Program Structure
flowchart TD
main([main]) --> countdown[[countdown]]
countdown --> loop[/"for i = 3 to 1"\]
loop --> body["print i
sleep(1000)"]
body --> loop
loop --> liftoff["print 'liftoff'"]
liftoff --> done([end])
Countdown Program Flow
flowchart TD
main([main]) --> countdown[[countdown]]
countdown --> init
subgraph loop ["for (i=3; i>0; i--)"]
init[i = 3] --> check{i > 0?}
check -->|yes| print["print i + '...'"]
print --> sleep[[sleep 1000ms]]
sleep --> dec[i--]
dec --> check
end
check -->|no| liftoff["print 'liftoff'"]
liftoff --> done([end])
