~nasser/browser-repl

Initial commit

refs

main
browse  log 

clone

read-only
https://git.sr.ht/~nasser/browser-repl
read/write
git@git.sr.ht:~nasser/browser-repl

You can also use your local clone with git send-email.

#Browser REPL

Experiment at getting a REPL into a browser

#Usage

Start REPL server in your terminal

$ cargo run
Listening on: 127.0.0.1:8080

Open html/index.html in a browser. In your terminal you should see

connected 127.0.0.1:56528
hello from the browser!
> 

You should be able to type JavaScript code into the REPL prompt and hit enter, which evaluates the code in the browser and returns the result.

> 98 * 7
686
> [1, 2, 3, 4].map(i => i * 8)
8,16,24,32
> Array(16).join("wat" - 1) + " Batman!"
NaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaN Batman!
> alert("hello from rust!")
undefined
> h1 = document.createElement("h1")
[object HTMLHeadingElement]
> h1.textContent = "Hello from rust!"
Hello from rust!
> document.body.appendChild(h1)
[object HTMLHeadingElement]

Copyright © 2024 Ramsey Nasser. Released under the terms of the ACSL 1.4.