当前位置: 首页 > 文档资料 > Lazy.js 英文文档 >

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);
}
NameType(s)Description
value*

The value to repeat.

countnumber?

The number of times the value should be repeated in the sequence. If this argument is omitted, the value will repeat forever.

returnsGeneratedSequence

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"]