Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes15kdownloads
max-satisfying.js28 linesDownload Raw Back to ranges
1'use strict'
2
3const SemVer = require('../classes/semver')
4const Range = require('../classes/range')
5
6const maxSatisfying = (versions, range, options) => {
7  let max = null
8  let maxSV = null
9  let rangeObj = null
10  try {
11    rangeObj = new Range(range, options)
12  } catch (er) {
13    return null
14  }
15  versions.forEach((v) => {
16    if (rangeObj.test(v)) {
17      // satisfies(v, range, options)
18      if (!max || maxSV.compare(v) === -1) {
19        // compare(max, v, true)
20        max = v
21        maxSV = new SemVer(max, options)
22      }
23    }
24  })
25  return max
26}
27module.exports = maxSatisfying
28 
codekingpro/portable-devtools · Team Ai