blob: ab5d23ddf0de901363549f6ab1e7ac0a1141dcf8 [file]
// a simple worker for use in the browser (as Web Worker)
// load workerpool
importScripts('../../dist/workerpool.js');
// a deliberately inefficient implementation of the fibonacci sequence
function fibonacci(n) {
if (n < 2) return n;
return fibonacci(n - 2) + fibonacci(n - 1);
}
// create a worker and register public functions
workerpool.worker({
fibonacci: fibonacci
});