1 importScripts('primes.js'); 2 3 var primes = new Primes(); 4 5 onmessage = function(event) { 6 var p = event.data; 7 if (p != parseInt(p)) 8 throw 'invalid argument'; 9 postMessage([p, primes.test(p)]); 10 } 11