Skip to content

Latest commit

 

History

History
36 lines (21 loc) · 839 Bytes

transducers.repeat.md

File metadata and controls

36 lines (21 loc) · 839 Bytes

Home > @thi.ng/transducers > repeat

repeat() function

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>;

Parameters

Parameter Type Description
x T value to repeat
n number num values (default: ∞)

Returns:

Generator<T, void, unknown>

Example

[...repeat(42, 5)]
// [42, 42, 42, 42, 42]