all files / src/ remapBranch.js

93.33% Statements 14/15
83.33% Branches 5/6
100% Functions 1/1
93.33% Lines 14/15
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 107× 107×   107× 157× 157× 57×     100× 50×   50×       100×     50×           50×      
function remapBranch(genItem, getMapping) {
  const locations = [];
  let source;
 
  for (let i = 0; i < genItem.locations.length; ++i) {
    const mapping = getMapping(genItem.locations[i]);
    if (!mapping) {
      return null;
    }
 
    if (!source) {
      source = mapping.source;
    } else {
      Iif (source !== mapping.source) {
        return null;
      }
    }
    locations.push(mapping.loc);
  }
 
  const srcItem = {
    line: locations[0].start.line,
    type: genItem.type,
    locations,
  };
 
  return { source, srcItem };
}
 
module.exports = remapBranch;