INNER CODE UNIT · TypeScript

test3

andywer/threads.js · test-tooling/webpack/app.ts:35

async function test3() {
  if (!(process as any).browser) {
    // Running workers from remote URLs is disabled in node.js
    return
  }

  const hello = await spawn<HelloWorker>(new Worker("https://infallible-turing-115958.netlify.com/hello-worker.js"))
  const result = await hello("World")

  if (result !== "Hello, World") {
    throw Error("Unexpected result returned by hello worker: " + result)
  }
}

function test4() {
  if (isWorkerRuntime() !== false) {
    throw Error("Expected isWorkerRuntime() to return false. Got: " + isWorkerRuntime())
  }

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…