Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function* fib(x) {
let x1 = 0;
let x2 = 1;
let i = 0;
while (i < x) {
yield `(calculating...) ${x1}`;
// eslint-disable-next-line no-await-in-loop
await new Promise((r) => setTimeout(r, 100));
[x1, x2] = [x2, x1 + x2];
i += 1;
}
yield x1;
}
exposeWorker(fib);
import { exposeWorker } from 'react-hooks-worker';
const fib = (i) => (i <= 1 ? i : fib(i - 1) + fib(i - 2));
exposeWorker(fib);
import { exposeWorker } from 'react-hooks-worker';
const fib = (i) => (i <= 1 ? i : fib(i - 1) + fib(i - 2));
exposeWorker(fib);
import { exposeWorker } from 'react-hooks-worker';
const fib = (i) => (i <= 1 ? i : fib(i - 1) + fib(i - 2));
exposeWorker(fib);