audit.js
function lookupSpecMatch(lookup, spec) {
  // Direct match
  if (lookup[spec]) {
    return lookup[spec];
  }

  // Close match
  var shortSpec = spec.replace(/@\D/g,'@');
  if (lookup[shortSpec]) {
    return lookup[shortSpec];
  }

  // Check for Semver valid match
  var lastIndex = spec.lastIndexOf('@');
  var myName = spec.substring(0, lastIndex);
  var myVersion = spec.substring(lastIndex + 1);
  for(var k in lookup) {
    lastIndex = k.lastIndexOf('@');
    var yourName = k.substring(0, lastIndex);
    var yourVersion = k.substring(lastIndex + 1);
    if (myName == yourName && semver.valid(yourVersion) && semver.satisfies(yourVersion, myVersion)) {
      return lookup[k];
    }
  }
  return undefined;
}
function lookupSpecMatch(lookup, spec) {
  // Direct match
  if (lookup[spec]) {
    return lookup[spec];
  }

  // Close match
  var shortSpec = spec.replace(/@\D/g,'@');
  if (lookup[shortSpec]) {
    return lookup[shortSpec];
  }

  // Check for Semver valid match
  var lastIndex = spec.lastIndexOf('@');
  var myName = spec.substring(0, lastIndex);
  var myVersion = spec.substring(lastIndex + 1);
  for(var k in lookup) {
    lastIndex = k.lastIndexOf('@');
    var yourName = k.substring(0, lastIndex);
    var yourVersion = k.substring(lastIndex + 1);
    if (myName == yourName && semver.valid(yourVersion) && semver.satisfies(yourVersion, myVersion)) {
      return lookup[k];
    }
  }
  return undefined;
}
function lookupSpecMatch ( lookup , spec ) { // Direct match if ( lookup [ spec ] ) { return lookup [ spec ] ; } // Close match var shortSpec = spec . replace ( / @\D / g , '@' ) ; if ( lookup [ shortSpec ] ) { return lookup [ shortSpec ] ; } // Check for Semver valid match var lastIndex = spec . lastIndexOf ( '@' ) ; var myName = spec . substring ( 0 , lastIndex ) ; var myVersion = spec . substring ( lastIndex + 1 ) ; for ( var k in lookup ) { lastIndex = k . lastIndexOf ( '@' ) ; var yourName = k . substring ( 0 , lastIndex ) ; var yourVersion = k . substring ( lastIndex + 1 ) ; if ( myName == yourName && semver . valid ( yourVersion ) && semver . satisfies ( yourVersion , myVersion ) ) { return lookup [ k ] ; } } return undefined ; }
Given a lookup table, try and find the best specification match for the
provided name@version
Given a lookup table try and find the best specification match for the provided name