github.com/outbrain/consul@v1.4.5/ui-v2/app/utils/distance.js (about)

     1  // TODO: Istanbul is ignored for the moment as it's not mine,
     2  // once I come here properly and 100% follow unignore
     3  /* istanbul ignore file */
     4  export default function(a, b) {
     5    a = a.Coord;
     6    b = b.Coord;
     7    let sum = 0;
     8    for (let i = 0; i < a.Vec.length; i++) {
     9      var diff = a.Vec[i] - b.Vec[i];
    10      sum += diff * diff;
    11    }
    12    let rtt = Math.sqrt(sum) + a.Height + b.Height;
    13    const adjusted = rtt + a.Adjustment + b.Adjustment;
    14    if (adjusted > 0.0) {
    15      rtt = adjusted;
    16    }
    17    return Math.round(rtt * 100000.0) / 100.0;
    18  }