MCPcopy Index your code
hub / github.com/MultithreadedJSBook/code-samples / fibonacci

Function fibonacci

ch2-patterns/worker.js:15–20  ·  view source on GitHub ↗
(limit)

Source from the content-addressed store, hash-verified

13 return sum;
14 },
15 async fibonacci(limit) {
16 await sleep(Math.random() * 100);
17 let prev = 1n, next = 0n, swap;
18 while (limit) { swap = prev; prev = prev + next; next = swap; limit--; }
19 return String(next); // <4>
20 },
21 async bad() {
22 await sleep(Math.random() * 10);
23 throw new Error('oh no');

Callers

nothing calls this directly

Calls 1

sleepFunction · 0.85

Tested by

no test coverage detected