each
优质
小牛编辑
139浏览
2023-12-01
Iterates over the sequence produced by invoking this sequence's generator function up to its specified length, or, if length is undefined
, indefinitely (in which case the sequence will go on forever--you would need to call, e.g., Sequence#take to limit iteration).
Signature
GeneratedSequence.each = function(fn) { /*...*/ }
GeneratedSequence.each = function each(fn) { var generatorFn = this.get, length = this.fixedLength, i = 0; while (typeof length === "undefined" || i < length) { if (fn(generatorFn(i), i++) === false) { return false; } } return true; }
Name | Type(s) | Description |
---|---|---|
fn | Function | The function to call on each output from the generator function. |