wip: 47 tiles
This commit is contained in:
parent
1013c53975
commit
ca94c06c5f
11 changed files with 1098 additions and 51 deletions
40
static/js/components/literate-programming/worker.js
Normal file
40
static/js/components/literate-programming/worker.js
Normal file
|
@ -0,0 +1,40 @@
|
|||
console = {
|
||||
log(...message) {
|
||||
postMessage({
|
||||
kind: "output",
|
||||
output: {
|
||||
kind: "log",
|
||||
message: [...message],
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
addEventListener("message", event => {
|
||||
let message = event.data;
|
||||
if (message.action == "eval") {
|
||||
try {
|
||||
let func = new Function(message.input);
|
||||
let result = func.apply({});
|
||||
postMessage({
|
||||
kind: "output",
|
||||
output: {
|
||||
kind: "result",
|
||||
message: [result],
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
postMessage({
|
||||
kind: "output",
|
||||
output: {
|
||||
kind: "error",
|
||||
message: [error.toString()],
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
postMessage({
|
||||
kind: "evalComplete",
|
||||
});
|
||||
}
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue