lib/mocha.js
function coverage(filename, data) {
  var ret = {
    filename: filename,
    coverage: 0,
    hits: 0,
    misses: 0,
    sloc: 0,
    source: {}
  };

  data.source.forEach(function(line, num){
    num++;

    if (data[num] === 0) {
      ret.misses++;
      ret.sloc++;
    } else if (data[num] !== undefined) {
      ret.hits++;
      ret.sloc++;
    }

    ret.source[num] = {
        source: line
      , coverage: data[num] === undefined
        ? ''
        : data[num]
    };
  });

  ret.coverage = ret.hits / ret.sloc * 100;

  return ret;
}
function coverage(filename, data) {
  var ret = {
    filename: filename,
    coverage: 0,
    hits: 0,
    misses: 0,
    sloc: 0,
    source: {}
  };

  data.source.forEach(function(line, num){
    num++;

    if (data[num] === 0) {
      ret.misses++;
      ret.sloc++;
    } else if (data[num] !== undefined) {
      ret.hits++;
      ret.sloc++;
    }

    ret.source[num] = {
        source: line
      , coverage: data[num] === undefined
        ? ''
        : data[num]
    };
  });

  ret.coverage = ret.hits / ret.sloc * 100;

  return ret;
}
function coverage ( filename , data ) { var ret = { filename : filename , coverage : 0 , hits : 0 , misses : 0 , sloc : 0 , source : { } } ; data . source . forEach ( function ( line , num ) { num ++ ; if ( data [ num ] === 0 ) { ret . misses ++ ; ret . sloc ++ ; } else if ( data [ num ] !== undefined ) { ret . hits ++ ; ret . sloc ++ ; } ret . source [ num ] = { source : line , coverage : data [ num ] === undefined ? '' : data [ num ] } ; } ) ; ret . coverage = ret . hits / ret . sloc * 100 ; return ret ; }
Map jscoverage data for a single source file
to a JSON structure suitable for reporting.

@param {String} filename name of the source file
@param {Object} data jscoverage coverage data
@return {Object}
@api private
Map jscoverage data for a single source file to a JSON structure suitable for reporting .