Skip to content

Commit

Permalink
Add simple wasm vm demos
Browse files Browse the repository at this point in the history
  • Loading branch information
vshymanskyy committed Jul 25, 2024
1 parent efde2f7 commit a0c6012
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions src/emulator.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,23 @@ for i, char in enumerate(text):
print(reset)
print("=" * 32)
`);
fs.writeFile('/demo_01.py', `
# TODO: Demo 1
`);
fs.writeFile('/demo_02.py', `
# TODO: Demo 2
fs.writeFile('/01_fetch.py', `
import js
import asyncio
async def task():
url = "https://api.github.com/users/micropython"
print(f"Fetching {url}...")
res = await js.fetch(url)
data = await res.json()
for i in dir(data):
print(f"{i}: {data[i]}")
asyncio.create_task(task())
`);
fs.writeFile('/demo_03.py', `
# TODO: Demo 3
fs.writeFile('/02_js_eval.py', `
import js
js.eval("alert('Hello from JavaScript')")
`);
}

Expand Down

0 comments on commit a0c6012

Please sign in to comment.