Offload functions to worker threads with shared memory primitives for Node.js.
1import type { Task } from './runner.ts';
2
3/**
4 * Returns an inert copy of a task — same `uid`, `id`, `args`, and `worker`
5 * but without `PromiseLike` or `AsyncIterable` protocols.
6 * Safe to `yield` from an async generator without triggering auto-await.
7 *
8 * @param task - A task created by a {@link mo}-wrapped function.
9 * @returns A plain object with the same task identity, stripped of any thenable or iterable protocols.
10 */
11export function inert<T, A extends unknown[] = unknown[]>(task: Task<T, A>): Task<T, A> {
12 const { uid, id, args, worker } = task;
13 return { uid, id, args, worker };
14}