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 14 lines 604 B view raw
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}