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 e2cebd539403475e2f4e79d55ca1a84a0ce3510d 13 lines 405 B view raw
1import { mo } from 'moroutine'; 2 3export const checkPrime = mo(import.meta, (n: number): boolean => { 4 if (n < 2) return false; 5 for (let i = 2; i * i <= n; i++) if (n % i === 0) return false; 6 return true; 7}); 8 9export const upper = mo(import.meta, (s: string): string => s.toUpperCase()); 10 11export const countUp = mo(import.meta, async function* (n: number) { 12 for (let i = 0; i < n; i++) yield i; 13});