Offload functions to worker threads with shared memory primitives for Node.js.
8
fork

Configure Feed

Select the types of activity you want to include in your feed.

at main 10 lines 347 B view raw
1import { mo } from '../../src/index.ts'; 2 3export const passthrough = mo(import.meta, async function* (input: AsyncIterable<number>) { 4 for await (const n of input) { 5 // Small CPU cost per item so workers become the bottleneck 6 let x = n; 7 for (let i = 0; i < 10_000; i++) x = (x * 1103515245 + 12345) & 0x7fffffff; 8 yield x; 9 } 10});