/** * A Coroutine is the intersection of: * 1. An Iterator that yields void, returns a T, and is not passed values with calls to next. * 2. An IterableIterator of void (since it only yields void). */ type CoroutineBase = Iterator & IterableIterator; /** @internal */ export type Coroutine = CoroutineBase; /** @internal */ export type AsyncCoroutine = CoroutineBase, T>; /** @internal */ export type CoroutineStep = IteratorResult; /** @internal */ export type CoroutineScheduler = (coroutine: AsyncCoroutine, onStep: (stepResult: CoroutineStep) => void, onError: (stepError: any) => void) => void; /** * @internal */ export declare function inlineScheduler(coroutine: AsyncCoroutine, onStep: (stepResult: CoroutineStep) => void, onError: (stepError: any) => void): void; /** * @internal */ export declare function createYieldingScheduler(yieldAfterMS?: number): (coroutine: AsyncCoroutine, onStep: (stepResult: CoroutineStep) => void, onError: (stepError: any) => void) => void; /** * @internal */ export declare function runCoroutine(coroutine: AsyncCoroutine, scheduler: CoroutineScheduler, onSuccess: (result: T) => void, onError: (error: any) => void, abortSignal?: AbortSignal): void; /** * @internal */ export declare function runCoroutineSync(coroutine: Coroutine, abortSignal?: AbortSignal): T; /** * @internal */ export declare function runCoroutineAsync(coroutine: AsyncCoroutine, scheduler: CoroutineScheduler, abortSignal?: AbortSignal): Promise; /** * Given a function that returns a Coroutine, produce a function with the same parameters that returns a T. * The returned function runs the coroutine synchronously. * @param coroutineFactory A function that returns a Coroutine. * @param abortSignal * @returns A function that runs the coroutine synchronously. * @internal */ export declare function makeSyncFunction(coroutineFactory: (...params: TParams) => Coroutine, abortSignal?: AbortSignal): (...params: TParams) => TReturn; /** * Given a function that returns a Coroutine, product a function with the same parameters that returns a Promise. * The returned function runs the coroutine asynchronously, yield control of the execution context occasionally to enable a more responsive experience. * @param coroutineFactory A function that returns a Coroutine. * @param scheduler * @param abortSignal * @returns A function that runs the coroutine asynchronously. * @internal */ export declare function makeAsyncFunction(coroutineFactory: (...params: TParams) => AsyncCoroutine, scheduler: CoroutineScheduler, abortSignal?: AbortSignal): (...params: TParams) => Promise; export {};