index.js 393 B

12345678910111213141516171819
  1. 'use strict';
  2. var SemverRange = require('sver-compat').SemverRange;
  3. function findRange(version, ranges) {
  4. ranges = ranges || [];
  5. function matches(range) {
  6. return SemverRange.match(range, version, true);
  7. }
  8. var validRanges = ranges.filter(matches);
  9. var sortedRanges = validRanges.sort(SemverRange.compare);
  10. return sortedRanges.pop() || null;
  11. }
  12. module.exports = findRange;