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 e46aca05dbf9a2204886d23f7ae3b34883f4e5c6 21 lines 527 B view raw
1// Pipeline of streaming moroutines, each step on its own dedicated worker. 2// Data flows: generate → double → square → toString, all via MessageChannel. 3// Requires Node v24+. 4// 5// Run: node examples/pipeline/main.ts 6 7import { generate, double, square, toString } from './steps.ts'; 8 9const numbers = generate(5); 10const doubled = double(numbers); 11const squared = square(doubled); 12const labels = toString(squared); 13 14for await (const label of labels) { 15 console.log(label); 16} 17// => 4 18// => 16 19// => 36 20// => 64 21// => 100