index.js
function combineErrors(errPrev, errNew) {
  if (!errPrev) {
    return errNew;
  }

  let errCombined;
  if (errPrev instanceof AggregateError) {
    errCombined = errPrev;
  } else {
    errCombined = new AggregateError();
    errCombined.push(errPrev);
  }

  errCombined.push(errNew);
  return errCombined;
}
function combineErrors(errPrev, errNew) {
  if (!errPrev) {
    return errNew;
  }

  let errCombined;
  if (errPrev instanceof AggregateError) {
    errCombined = errPrev;
  } else {
    errCombined = new AggregateError();
    errCombined.push(errPrev);
  }

  errCombined.push(errNew);
  return errCombined;
}
function combineErrors ( errPrev , errNew ) { if ( ! errPrev ) { return errNew ; } let errCombined ; if ( errPrev instanceof AggregateError ) { errCombined = errPrev ; } else { errCombined = new AggregateError ( ) ; errCombined . push ( errPrev ) ; } errCombined . push ( errNew ) ; return errCombined ; }
Combines one or more errors into a single error.

@param {AggregateError|Error} errPrev Previous errors, if any.
@param {!Error} errNew New error.
@return {!AggregateError|!Error} Error which represents all errors that have
occurred.  If only one error has occurred, it will be returned.  Otherwise
an {@link AggregateError} including all previous errors will be returned.
@private
Combines one or more errors into a single error .