Home > @thi.ng/transducers > repeat
Iterator yielding an infinite (by default) repetition of given value x
. If n
is given, only produces that many values.
See also: repeatedly()
Signature:
export declare function repeat<T>(x: T, n?: number): Generator<T, void, unknown>;
Parameter | Type | Description |
---|---|---|
x | T |
value to repeat |
n | number |
num values (default: ∞) |
Returns:
Generator<T, void, unknown>
[...repeat(42, 5)]
// [42, 42, 42, 42, 42]