import { ThreadGenerator } from '../threading'; export interface LoopCallback { /** * A callback called by {@link loop} during each iteration. * * @param i - The current iteration index. */ (i: number): ThreadGenerator | void; } /** * Run the given generator in a loop. * * @remarks * Each iteration waits until the previous one is completed. * Because this loop never finishes it cannot be used in the main thread. * Instead, use `yield` or {@link threading.spawn} to run the loop concurrently. * * @example * Rotate the `rect` indefinitely: * ```ts * yield loop( * () => rect.rotation(0).rotation(360, 2, linear), * ); * ``` * * @param factory - A function creating the generator to run. Because generators * can't be reset, a new generator is created on each * iteration. */ export declare function loop(factory: LoopCallback): ThreadGenerator; /** * Run the given generator N times. * * @remarks * Each iteration waits until the previous one is completed. * * @example * ```ts * const colors = [ * '#ff6470', * '#ffc66d', * '#68abdf', * '#99c47a', * ]; * * yield* loop( * colors.length, * i => rect.fill(colors[i], 2), * ); * ``` * * @param iterations - The number of iterations. * @param factory - A function creating the generator to run. Because generators * can't be reset, a new generator is created on each * iteration. */ export declare function loop(iterations: number, factory: LoopCallback): ThreadGenerator; //# sourceMappingURL=loop.d.ts.map