import { Rhodium } from "./Rhodium.mts"; import type { Errored, Merged } from "./terminology.mts"; /** * Resolves each Rhodium yielded by {@linkcode generator} one by one. * Allows writing asynchronous code imperatively: `for`, `if`, `while`, `switch`, `const`, `using` statements, etc. * Works similarly to `async` functions, except that `async` is written as `function*`, and `await` - as `yield*`. * * `try {} finally {}` will always execute its `finally` block, even in an event of cancellation. * * @returns a Rhodium that is fullfilled with the awaited return value of {@linkcode generator}, or * rejected when generator rejects. * @example * ``` * Rhodium.tryGen(function* () { * // yield* awaits a Rhodium * const connection = yield* openConnection() * try { * yield* connection.send("ping") * // Control of flow is easy * if (yield* connection.read() !== "pong") { * // This is how `throw` is written 😅 * return yield* Rhodium.reject(new ExpectedPongError()) * } * } finally { * // This will always execute, even in cancellation * yield* connection.close() * } * }) * ``` */ export declare function tryGen, const R, const U extends unknown[] = []>(generator: (...args: [...U, signal: AbortSignal]) => Generator, ...args: U): Merged, Errored

| Errored>>;