• Returns a generator that yields first argument (what) the number of times specified by the second argument (times). If times is not given, what is repeated indefinitely.

    Type Parameters

    • T

    Parameters

    • it: Iterable<T> | (() => Iterable<T>)
    • Optional times: number = -1
    • Rest ...extras: any[]

    Returns Generator<any, void, unknown>

    Example

    import { repeat } from 'deleight/generators';
    const repeated = [...repeat([1, 2, 3], 4)];
    // [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]