mirror of
https://github.com/syumai/workers.git
synced 2025-03-11 01:39:11 +00:00
25 lines
482 B
JavaScript
25 lines
482 B
JavaScript
import "./polyfill_performance.js";
|
|
import "./wasm_exec.js";
|
|
|
|
const go = new Go();
|
|
|
|
let mod;
|
|
|
|
export function init(m) {
|
|
mod = m;
|
|
}
|
|
|
|
async function run() {
|
|
const readyPromise = new Promise((resolve) => {
|
|
globalThis.ready = resolve;
|
|
});
|
|
const instance = new WebAssembly.Instance(mod, go.importObject);
|
|
go.run(instance);
|
|
await readyPromise;
|
|
}
|
|
|
|
export async function fetch(req, env, ctx) {
|
|
await run();
|
|
return handleRequest(req, { env, ctx });
|
|
}
|