lib/make-incremental.js
function incrementalProp(state1, state2, propName, compare) {
  const values1 = state1[propName];
  const values2 = state2[propName];

  let result;
  // Note:  Values may be undefined if no data was read.
  if (((values1 && values1.length !== 0) || state1.ended)
      && ((values2 && values2.length !== 0) || state2.ended)) {
    const minLen = Math.min(
      values1 ? values1.length : 0,
      values2 ? values2.length : 0
    );

    if ((values1 && values1.length > minLen) && !state2.ended) {
      result = compare(values1.slice(0, minLen), values2);
    } else if ((values2 && values2.length > minLen) && !state1.ended) {
      result = compare(values1, values2.slice(0, minLen));
    } else {
      result = compare(values1, values2);
    }

    if (minLen > 0 && (result === null || result === undefined)) {
      state1[propName] = values1.slice(minLen);
      state2[propName] = values2.slice(minLen);
    }
  }

  return result;
}
function incrementalProp(state1, state2, propName, compare) {
  const values1 = state1[propName];
  const values2 = state2[propName];

  let result;
  // Note:  Values may be undefined if no data was read.
  if (((values1 && values1.length !== 0) || state1.ended)
      && ((values2 && values2.length !== 0) || state2.ended)) {
    const minLen = Math.min(
      values1 ? values1.length : 0,
      values2 ? values2.length : 0
    );

    if ((values1 && values1.length > minLen) && !state2.ended) {
      result = compare(values1.slice(0, minLen), values2);
    } else if ((values2 && values2.length > minLen) && !state1.ended) {
      result = compare(values1, values2.slice(0, minLen));
    } else {
      result = compare(values1, values2);
    }

    if (minLen > 0 && (result === null || result === undefined)) {
      state1[propName] = values1.slice(minLen);
      state2[propName] = values2.slice(minLen);
    }
  }

  return result;
}
function incrementalProp ( state1 , state2 , propName , compare ) { const values1 = state1 [ propName ] ; const values2 = state2 [ propName ] ; let result ; // Note:  Values may be undefined if no data was read. if ( ( ( values1 && values1 . length !== 0 ) || state1 . ended ) && ( ( values2 && values2 . length !== 0 ) || state2 . ended ) ) { const minLen = Math . min ( values1 ? values1 . length : 0 , values2 ? values2 . length : 0 ) ; if ( ( values1 && values1 . length > minLen ) && ! state2 . ended ) { result = compare ( values1 . slice ( 0 , minLen ) , values2 ) ; } else if ( ( values2 && values2 . length > minLen ) && ! state1 . ended ) { result = compare ( values1 , values2 . slice ( 0 , minLen ) ) ; } else { result = compare ( values1 , values2 ) ; } if ( minLen > 0 && ( result === null || result === undefined ) ) { state1 [ propName ] = values1 . slice ( minLen ) ; state2 [ propName ] = values2 . slice ( minLen ) ; } } return result ; }
Incrementally compares and reduces an Array-like property of the states
using a given comparison function.

@ template CompareResult
@param {!StreamState} state1 First state to compare.
@param {!StreamState} state2 Second state to compare.
@param {string} propName Name of Array-like property to compare.
@param {function(*, *): CompareResult} compare Comparison function to apply
to the <code>propName</code> values from each state.
@return {CompareResult} Result of comparing <code>propName</code> values, up
to the minimum common length.
@private
Incrementally compares and reduces an Array - like property of the states using a given comparison function .