openmct/example/worker/src/FibonacciWorker.js
Victor Woeltjen eb2cddc063 [Workers] Satisfy JSLint
Modify example worker script to satisfy JSLint. #12.
2015-06-18 11:30:47 -07:00

16 lines
369 B
JavaScript

/*global self*/
(function () {
"use strict";
// Calculate fibonacci numbers inefficiently.
// We can do this because we're on a background thread, and
// won't halt the UI.
function fib(n) {
return n < 2 ? n : (fib(n - 1) + fib(n - 2));
}
self.onmessage = function (event) {
self.postMessage(fib(event.data));
};
}());