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 20 lines 630 B view raw
1import { describe, it } from 'node:test'; 2import assert from 'node:assert/strict'; 3import { workers } from 'moroutine'; 4import { makeMultiplier, streamMultiplied } from './fixtures/stream-context.ts'; 5 6describe('streaming with task-args', () => { 7 it('resolves task-args before streaming', async () => { 8 const factor = makeMultiplier(3); 9 const run = workers(1); 10 try { 11 const results: number[] = []; 12 for await (const value of run(streamMultiplied(factor, 4))) { 13 results.push(value); 14 } 15 assert.deepEqual(results, [0, 3, 6, 9]); 16 } finally { 17 run[Symbol.dispose](); 18 } 19 }); 20});