// Moroutines from different modules running on a single worker. // The worker lazily imports each module the first time a task from it is dispatched. // Requires Node v24+. // // Run: node examples/multi-module/main.ts import { workers } from '../../src/index.ts'; import { square, add } from './math.ts'; import { uppercase, repeat } from './text.ts'; { using run = workers(1); // All four moroutines from two modules run on the same single worker const results = await run([square(7), add(3, 4), uppercase('hello'), repeat('ab', 3)]); console.log('square(7) =', results[0]); // 49 console.log('add(3, 4) =', results[1]); // 7 console.log("uppercase('hello') =", results[2]); // HELLO console.log("repeat('ab', 3) =", results[3]); // ababab }