Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

min-satisfying.js 577B

123456789101112131415161718192021222324
  1. const SemVer = require('../classes/semver')
  2. const Range = require('../classes/range')
  3. const minSatisfying = (versions, range, options) => {
  4. let min = null
  5. let minSV = null
  6. let rangeObj = null
  7. try {
  8. rangeObj = new Range(range, options)
  9. } catch (er) {
  10. return null
  11. }
  12. versions.forEach((v) => {
  13. if (rangeObj.test(v)) {
  14. // satisfies(v, range, options)
  15. if (!min || minSV.compare(v) === 1) {
  16. // compare(min, v, true)
  17. min = v
  18. minSV = new SemVer(min, options)
  19. }
  20. }
  21. })
  22. return min
  23. }
  24. module.exports = minSatisfying