Last change
on this file since 84d0fbb was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
579 bytes
|
Rev | Line | |
---|
[6a3a178] | 1 | const SemVer = require('../classes/semver')
|
---|
| 2 | const Range = require('../classes/range')
|
---|
| 3 |
|
---|
| 4 | const maxSatisfying = (versions, range, options) => {
|
---|
| 5 | let max = null
|
---|
| 6 | let maxSV = null
|
---|
| 7 | let rangeObj = null
|
---|
| 8 | try {
|
---|
| 9 | rangeObj = new Range(range, options)
|
---|
| 10 | } catch (er) {
|
---|
| 11 | return null
|
---|
| 12 | }
|
---|
| 13 | versions.forEach((v) => {
|
---|
| 14 | if (rangeObj.test(v)) {
|
---|
| 15 | // satisfies(v, range, options)
|
---|
| 16 | if (!max || maxSV.compare(v) === -1) {
|
---|
| 17 | // compare(max, v, true)
|
---|
| 18 | max = v
|
---|
| 19 | maxSV = new SemVer(max, options)
|
---|
| 20 | }
|
---|
| 21 | }
|
---|
| 22 | })
|
---|
| 23 | return max
|
---|
| 24 | }
|
---|
| 25 | module.exports = maxSatisfying
|
---|
Note:
See
TracBrowser
for help on using the repository browser.