1/* eslint-env worker */ 2/* eslint-disable no-restricted-globals */ 3 4let intervalId = null; 5let awaitingTock = false; 6let isRunning = false; 7 8function reset() { 9 if (intervalId) { 10 clearInterval(intervalId); 11 intervalId = null; 12 } 13 awaitingTock = false; 14 isRunning = false; 15} 16 17function startProcessing(fps) { 18 if (isRunning) { 19 return; 20 } 21 isRunning = true; 22 intervalId = setInterval(() => { 23 if (awaitingTock) { 24 return; 25 } 26 awaitingTock = true; 27 self.postMessage({ command: "tick" }); 28 }, Math.floor(1000 / (fps || 30))); 29} 30 31self.onmessage = (e) => { 32 if (!e.data?.command) { 33 return; 34 } 35 const { command, fps } = e.data; 36 switch (command) { 37 case "start": 38 startProcessing(fps); 39 break; 40 case "tock": 41 awaitingTock = false; 42 break; 43 case "stop": 44 reset(); 45 break; 46 default: 47 break; 48 } 49}; 50 51self.onmessageerror = () => { 52 awaitingTock = false; 53}; 54 55self.onerror = reset;
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.