import type { Task } from './runner.ts'; type TaskOf = M extends { (...args: any[]): infer R } ? R extends Task ? Task : never : never; /** * Narrows a task to the descriptor type produced by a specific moroutine. * * ```ts * if (isTask(isPrime, task)) { * // task: Task * } * ``` * * @param moroutine - A function returned by {@link mo}. * @param task - A task to test. * @returns `true` if `task` was created by `moroutine`. */ export function isTask }>( moroutine: M, task: Task, ): task is TaskOf { return task.id === moroutine.id; }