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

GeneratedSequence

优质
小牛编辑
130浏览
2023-12-01

A GeneratedSequence does not wrap an in-memory collection but rather determines its elements on-the-fly during iteration according to a generator function.

You create a GeneratedSequence by calling Lazy.generate.

Signature

function GeneratedSequence(generatorFn, length) { /*...*/ }
function GeneratedSequence(generatorFn, length) {
  this.get = generatorFn;
  this.fixedLength = length;
}
NameType(s)Description
generatorFnfunction(number):*

A function which accepts an index and returns a value for the element at that position in the sequence.

lengthnumber?

The length of the sequence. If this argument is omitted, the sequence will go on forever.