src/modules/iteration.js
function functionIterator(fn) {
  return function* () {
    let current;
    let index = 0;

    for (;;) {
      current = fn(index++, current);
      if (current === undefined) {
        break;
      }
      yield current;
    }
  }();
}
function functionIterator(fn) {
  return function* () {
    let current;
    let index = 0;

    for (;;) {
      current = fn(index++, current);
      if (current === undefined) {
        break;
      }
      yield current;
    }
  }();
}
function functionIterator ( fn ) { return function * ( ) { let current ; let index = 0 ; for ( ; ; ) { current = fn ( index ++ , current ) ; if ( current === undefined ) { break ; } yield current ; } } ( ) ; }
Creates an iterator that runs a function for each `next` value.

The function in question is provided two arguments: the current 0-based index (which starts at `0` and increases by
one for each run) and the return value for the prior calling of the function (which is `undefined` if the function
has not yet been run). The return value of the function is used as the value that comes from `next` the next time
it's called.

If the function returns `undefined` at any point, the iteration terminates there and the `done` property of the
object returned with the next call to `next` becomes `true`.

@private

@param {function} fn A function that is run once for each step of the iteration. It is provided two arguments: the
`0`-based index of that run (starts at `0` and increments each run) and the return value of the last call to the
function (`undefined` if it hasn't been called yet). If the function returns `undefined` at any point, the
iteration terminates.
@return {function} A generator wrapping `fn`, which is suitable for use as an iterator.
Creates an iterator that runs a function for each next value .