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 25 lines 618 B view raw
1import { mo } from '../../src/index.ts'; 2 3export const generate = mo(import.meta, async function* (count: number) { 4 for (let i = 1; i <= count; i++) { 5 yield i; 6 } 7}); 8 9export const double = mo(import.meta, async function* (input: AsyncIterable<number>) { 10 for await (const n of input) { 11 yield n * 2; 12 } 13}); 14 15export const square = mo(import.meta, async function* (input: AsyncIterable<number>) { 16 for await (const n of input) { 17 yield n * n; 18 } 19}); 20 21export const toString = mo(import.meta, async function* (input: AsyncIterable<number>) { 22 for await (const n of input) { 23 yield `=> ${n}`; 24 } 25});