-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathindex.js
25 lines (20 loc) · 761 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import * as smd from "./smd.js"
async function main() {
const source_res = await fetch("readme.md")
const source_txt = await source_res.text()
const container = /** @type {HTMLElement} */(document.getElementById("markdown"))
const renderer = smd.default_renderer(container)
// const renderer = mds.logger_renderer()
const parser = smd.parser(renderer)
let i = 0
while (i < source_txt.length) {
const length = Math.floor(Math.random() * 20) + 1
const delay = Math.floor(Math.random() * 80) + 10
const chunk = source_txt.slice(i, i += length)
await new Promise(resolve => setTimeout(resolve, delay))
smd.parser_write(parser, chunk)
}
smd.parser_end(parser)
}
main()
export {}