src/generators.js
/** Iterates over the given sequence `seq` once, storing the values in an
 * array. Any subsequent iteration will go over the array and not the
 * original sequence. It is useful to avoid recalculating the sequence's
 * values if it is to be iterated more than once.
 *
 * @param {iterable<T>} seq - The original sequence.
 * @param {T[]} [array=null] - The buffer array. If not given a new one
 *   will be created.
 * @returns {iterable<T>}
 */
Iterates over the given sequence `seq` once, storing the values in an
array. Any subsequent iteration will go over the array and not the
original sequence. It is useful to avoid recalculating the sequence's
values if it is to be iterated more than once.

@param {iterable} seq - The original sequence.
@param {T[]} [array=null] - The buffer array. If not given a new one
will be created.
@returns {iterable}
Iterates over the given sequence ` seq ` once storing the values in an array . Any subsequent iteration will go over the array and not the original sequence . It is useful to avoid recalculating the sequence ' s values if it is to be iterated more than once . @param { iterable } seq - The original sequence . @param { T [] } [ array = null ] - The buffer array . If not given a new one will be created . @returns { iterable }
function buffered(seq, array = null) {
  array = array || [];
  const iter = seq[Symbol.iterator]();
  return function* bufferedGenerator() {
    for (const value of array) {
      yield value;
    }
    for (let entry = iter.next(); !entry.done; entry = iter.next()) {
      array.push(entry.value);
      yield entry.value;
    }
  };
}
function buffered ( seq , array = null ) { array = array || [ ] ; const iter = seq [ Symbol . iterator ] ( ) ; return function * bufferedGenerator ( ) { for ( const value of array ) { yield value ; } for ( let entry = iter . next ( ) ; ! entry . done ; entry = iter . next ( ) ) { array . push ( entry . value ) ; yield entry . value ; } } ; }
Iterates over the given sequence `seq` once, storing the values in an
 array.
Iterates over the given sequence ` seq ` once storing the values in an array .