You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

17 lines
372 B

  1. var i = 0;
  2. console.log("Starting worker")
  3. onmessage = (ev) => {
  4. console.log(`Worker received data ${ev.data}`)
  5. const data = JSON.parse(ev.data)
  6. postMessage(JSON.stringify({ data: data.data * 2 }))
  7. }
  8. // function timedCount() {
  9. // i = i + 1;
  10. // postMessage(JSON.stringify({ data: i }));
  11. // setTimeout("timedCount()", 2000);
  12. // }
  13. // timedCount();