MCPcopy Index your code
hub / github.com/npm/node-semver / testSet

Function testSet

classes/range.js:543–577  ·  view source on GitHub ↗
(set, version, options)

Source from the content-addressed store, hash-verified

541}
542
543const testSet = (set, version, options) => {
544 for (let i = 0; i < set.length; i++) {
545 if (!set[i].test(version)) {
546 return false
547 }
548 }
549
550 if (version.prerelease.length && !options.includePrerelease) {
551 // Find the set of versions that are allowed to have prereleases
552 // For example, ^1.2.3-pr.1 desugars to >=1.2.3-pr.1 <2.0.0
553 // That should allow `1.2.3-pr.2` to pass.
554 // However, `1.2.4-alpha.notready` should NOT be allowed,
555 // even though it's within the range set by the comparators.
556 for (let i = 0; i < set.length; i++) {
557 debug(set[i].semver)
558 if (set[i].semver === Comparator.ANY) {
559 continue
560 }
561
562 if (set[i].semver.prerelease.length > 0) {
563 const allowed = set[i].semver
564 if (allowed.major === version.major &&
565 allowed.minor === version.minor &&
566 allowed.patch === version.patch) {
567 return true
568 }
569 }
570 }
571
572 // Version has a -pre, but it's not one of the ones we like.
573 return false
574 }
575
576 return true
577}

Callers 1

testMethod · 0.85

Calls 1

testMethod · 0.45

Tested by 1

testMethod · 0.68