Something went wrong. Try again.
Offload functions to worker threads with shared memory primitives for Node.js.
Something went wrong. Try again.
123456789101112131415161718192021import { describe, it } from 'node:test';import assert from 'node:assert/strict';import { workers } from 'moroutine';import { makeMultiplier, streamMultiplied } from './fixtures/stream-context.ts';
describe('streaming with task-args', () => { it('resolves task-args before streaming', async () => { const factor = makeMultiplier(3); const run = workers(1); try { const results: number[] = []; for await (const value of run(streamMultiplied(factor, 4))) { results.push(value); } assert.deepEqual(results, [0, 3, 6, 9]); } finally { run[Symbol.dispose](); } });});