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 15 lines 382 B view raw
1import { mo } from 'moroutine'; 2 3export const sumStream = mo(import.meta, async (input: AsyncIterable<number>): Promise<number> => { 4 let sum = 0; 5 for await (const n of input) { 6 sum += n; 7 } 8 return sum; 9}); 10 11export const uppercaseStream = mo(import.meta, async function* (input: AsyncIterable<string>) { 12 for await (const s of input) { 13 yield s.toUpperCase(); 14 } 15});