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

Function square_sum

ch2-patterns/worker.js:10–14  ·  view source on GitHub ↗
(max)

Source from the content-addressed store, hash-verified

8
9const commands = {
10 async square_sum(max) {
11 await sleep(Math.random() * 100); // <3>
12 let sum = 0; for (let i = 0; i < max; i++) sum += Math.sqrt(i);
13 return sum;
14 },
15 async fibonacci(limit) {
16 await sleep(Math.random() * 100);
17 let prev = 1n, next = 0n, swap;

Callers

nothing calls this directly

Calls 1

sleepFunction · 0.85

Tested by

no test coverage detected