lib/coverage.js
function coverage(data, type) {
  var comparisionFunc;
  var n = 0;

  function isCovered(val) {
    return (val > 0);
  }

  function isMissed(val) {
    return !isCovered(val);
  }

  if (type === 'covered') {
    comparisionFunc = isCovered;
  }
  else if (type === 'missed') {
    comparisionFunc = isMissed;
  }
  else {
    throw new Error('Invalid type: ' + type);
  }

  var len = Object.keys(data.lines).length;

  for (var i = 0; i < len; ++i) {
    if (data.lines[i] !== null && comparisionFunc(data.lines[i])) {
      ++n;
    }
  }

  return n;
}
function coverage(data, type) {
  var comparisionFunc;
  var n = 0;

  function isCovered(val) {
    return (val > 0);
  }

  function isMissed(val) {
    return !isCovered(val);
  }

  if (type === 'covered') {
    comparisionFunc = isCovered;
  }
  else if (type === 'missed') {
    comparisionFunc = isMissed;
  }
  else {
    throw new Error('Invalid type: ' + type);
  }

  var len = Object.keys(data.lines).length;

  for (var i = 0; i < len; ++i) {
    if (data.lines[i] !== null && comparisionFunc(data.lines[i])) {
      ++n;
    }
  }

  return n;
}
function coverage ( data , type ) { var comparisionFunc ; var n = 0 ; function isCovered ( val ) { return ( val > 0 ) ; } function isMissed ( val ) { return ! isCovered ( val ) ; } if ( type === 'covered' ) { comparisionFunc = isCovered ; } else if ( type === 'missed' ) { comparisionFunc = isMissed ; } else { throw new Error ( 'Invalid type: ' + type ) ; } var len = Object . keys ( data . lines ) . length ; for ( var i = 0 ; i < len ; ++ i ) { if ( data . lines [ i ] !== null && comparisionFunc ( data . lines [ i ] ) ) { ++ n ; } } return n ; }
Total coverage for the given file data.

@param  {Array} data
@return {Type}
Total coverage for the given file data .