repeat
优质
小牛编辑
136浏览
2023-12-01
Creates a sequence consisting of the given value repeated a specified number of times.
Signature
Lazy.repeat = function(value, count) { /*...*/ }
Lazy.repeat = function repeat(value, count) { return Lazy.generate(function() { return value; }, count); }
Name | Type(s) | Description |
---|---|---|
value | * | The value to repeat. |
count | number? | The number of times the value should be repeated in the sequence. If this argument is omitted, the value will repeat forever. |
returns | GeneratedSequence | The sequence containing the repeated value. |
Examples
Lazy.repeat("hi", 3) // sequence: ["hi", "hi", "hi"] Lazy.repeat("young") // instanceof Lazy.GeneratedSequence Lazy.repeat("young").length() // => undefined Lazy.repeat("young").take(3) // sequence: ["young", "young", "young"]