@vielzeug/familiar
v2.2.0
Published
Typed ES module Worker pools with queueing, streaming, and AbortSignal cancellation
Readme
@vielzeug/familiar
Typed module-worker pools with cancellation, priority scheduling, streaming, and test utilities.
@vielzeug/familiar runs typed work in ES module workers. Worker modules keep imports, source maps, and normal file boundaries intact.
Installation
pnpm add @vielzeug/familiarQuick Start
// sum.worker.ts
import { exposeTask } from '@vielzeug/familiar/protocol';
exposeTask((values: number[]) => values.reduce((total, value) => total + value, 0));// main.ts
import { createWorker } from '@vielzeug/familiar';
const pool = createWorker<number[], number>(new URL('./sum.worker.ts', import.meta.url), {
concurrency: 2,
timeout: 5_000,
});
try {
console.log(await pool.run([1, 2, 3]));
} finally {
pool.dispose();
}Exports
createWorker()creates a task pool backed by modules registered withexposeTask().createStreamWorker()creates a stream-only pool backed by modules registered withexposeStream().batch()andcreateTaskGroup()compose task-pool work without widening every pool handle.createTestWorker()provides structured-clone, timeout, cancellation, and error-wrapping parity for task-pool tests.dispose()stops work immediately;drain()waits for active work before teardown.
Documentation
License
MIT © Helmuth Saatkamp — part of the Vielzeug monorepo.
