1 2 3 4 5 6
onmessage = function(e) { if(e.data.work === "sleep") { setTimeout(() => postMessage("done"), e.data.time); } };