index.js
function (expected, expectedIndex, value) {
   var i = expectedIndex + 1;
   var matchingOptionals = 0;
   var inBetweenOptionals = 0;
   var tmpInBetween = 0;
   while (i < expected.length && isOptionalType(expected[i])) {
      if (isOfType(value, expected[i])) {
         matchingOptionals++;
         inBetweenOptionals += tmpInBetween;
         tmpInBetween = 0;
      } else {
         tmpInBetween++;
      }
      i++;
   }
   return matchingOptionals + inBetweenOptionals;
}
function (expected, expectedIndex, value) {
   var i = expectedIndex + 1;
   var matchingOptionals = 0;
   var inBetweenOptionals = 0;
   var tmpInBetween = 0;
   while (i < expected.length && isOptionalType(expected[i])) {
      if (isOfType(value, expected[i])) {
         matchingOptionals++;
         inBetweenOptionals += tmpInBetween;
         tmpInBetween = 0;
      } else {
         tmpInBetween++;
      }
      i++;
   }
   return matchingOptionals + inBetweenOptionals;
}
Counts the number of trailing, consecutive optional arguments.
@param {Array} expected
@param {number} expectedIndex
@param {?} value
@returns {number}
@private