Checks if `range` matches `version`. `range` should be a "simple" range (ie.
not a compound range using the " - " or "||" operators).

@param {string} range
@param {string} version
@returns {boolean}
763632
function checkSimpleExpression(range, version) {
  range = range.trim();
  if (range === '') {
    return true;
  }

  const versionComponents = version.split(componentRegex);
  const {modifier, rangeComponents} = getModifierAndComponents(range);
  switch (modifier) {
    case '<':
      return checkLessThan(versionComponents, rangeComponents);
    case '<=':
      return checkLessThanOrEqual(versionComponents, rangeComponents);
    case '>=':
      return checkGreaterThanOrEqual(versionComponents, rangeComponents);
    case '>':
      return checkGreaterThan(versionComponents, rangeComponents);
    case '~':
    case '~>':
      return checkApproximateVersion(versionComponents, rangeComponents);
    default:
      return checkEqual(versionComponents, rangeComponents);
  }
}
85788
function packageVersion (rangeString) {
  if (!rangeString || typeof rangeString !== 'string') {
    // 默认装 latest
    return 'latest'
  }

  const range = semverUtils.parseRange(rangeString)[0]
  const version = [
    range.major,
    range.minor,
    range.patch
  ].join('.')

  return range.release
    ? `${version}-${range.release}`
    : version
}
1267141
function isEqualRange(range1, range2) {
    return range1.from === range2.from && range1.to === range2.to;
}
538836
def check_version(version: str):
    
    code_version = parse_version(__version__)
    given_version = parse_version(version)
    check_condition(code_version[0] == given_version[0],
                    "Given release version (%s) does not match release code version (%s)" % (version, __version__))
    check_condition(code_version[1] == given_version[1],
                    "Given major version (%s) does not match major code version (%s)" % (version, __version__))
613967
public boolean contains(final CharRange range) {
        Validate.isTrue(range != null, "The Range must not be null");
        if (negated) {
            if (range.negated) {
                return start >= range.start && end <= range.end;
            }
            return range.end < start || range.start > end;
        }
        if (range.negated) {
            return start == 0 && end == Character.MAX_VALUE;
        }
        return start <= range.start && end >= range.end;
    }
1272737
function versionGreaterThan (version1, version2) {
      if (version1 === version2) return false;
      if (version1 === -1) return version2;
      if (version2 === -1) return version1;

      if (version1.indexOf('.') === -1 && version2.indexOf('.') === -1) {
        return version1 > version2;
      }

      // The versions have multiple components (i.e. 0.10.30) and
      // must be compared piecewise.
      // Note: I'm ignoring the case where one version has multiple
      // components and the other doesn't.
      var v1 = version1.split('.'),
          v2 = version2.split('.'),
          versionLength = (v1.length > v2.length ? v2 : v1).length;


      for (var i = 0; i < versionLength; ++i) {
        if (parseInt(v1[i], 10) > parseInt(v2[i], 10)) {
          return true;
        }
      }

      // Special case, v1 has extra components but the initial components
      // were identical, we assume this means newer but it might also mean
      // that someone changed versioning systems.
      if (i < v1.length) {
        return true;
      }

      return false;
    }
1184620
def _check_ver_range(self, version, ver_range):
        

        lower, upper, lower_inc, upper_inc = ver_range

        #If the range extends over everything, we automatically match
        if lower is None and upper is None:
            return True

        if lower is not None:
            if lower_inc and version < lower:
                return False
            elif not lower_inc and version <= lower:
                return False

        if upper is not None:
            if upper_inc and version > upper:
                return False
            elif not upper_inc and version >= upper:
                return False

        # Prereleases have special matching requirements
        if version.is_prerelease:
            # Prereleases cannot match ranges that are not defined as prereleases
            if (lower is None or not lower.is_prerelease) and (upper is None or not upper.is_prerelease):
                return False

            # Prereleases without the same major.minor.patch as a range end point cannot match
            if (lower is not None and version.release_tuple != lower.release_tuple) and \
               (upper is not None and version.release_tuple != upper.release_tuple):
                return False

        return True
1061086
def validate_version_range(version_range)
      SemanticPuppet::VersionRange.parse(version_range)
    rescue ArgumentError => e
      raise ArgumentError, _("Invalid 'version_range' field in metadata.json: %{err}") % { err: e }
    end
773825
@Override
  public void exitSimple_range(VersionParser.Simple_rangeContext ctx)
  {
    String operator = ctx.getChild(0).getText();
    Object o = stack.pop();
    if (o instanceof SemanticVersion) {
      //range = new SemanticVersionRange((SemanticVersion)o);
      switch (operator) {
        case "~>":
          // Special case for "pessimistic" range, see
          // https://www.devalot.com/articles/2012/04/gem-versions.html
          SemanticVersion sv = (SemanticVersion) o;
          VersionRange from = new VersionRange(">=", sv);
          VersionRange to = new VersionRange("<", sv.getNextParentVersion());
          range = new AndRange(from, to);
          break;
        default:
          range = new VersionRange(operator, (SemanticVersion) o);
          break;
      }
      stack.push(range);
    }
    else {
      throw new InvalidRangeRuntimeException("Expected a semantic version, got a " + o.getClass().getSimpleName());
    }
  }
101785
public static boolean isValidVersion(final String version) {
        return StringUtils.isNotBlank(version)
                && (ALTERNATE_PATTERN.matcher(version).matches() || STANDARD_PATTERN
                        .matcher(version).matches());
    }
243292
function range(a, b) {
    var total = b - a;
    var rec = function(x, y) {
        if (y - a >= total) return x;

        x[y] = y++;
        return rec(x, y);
    };
    return rec([], a);
}
1144597
function(range) {
			if (this.overlap(range)) {
				var start = Math.max(range.start, this.start);
				var end = Math.min(range.end, this.end);
				return new Range(start, end - start);
			}
			
			return null;
		}
422580
def contains_version(self, version):
        """"""
        if len(self.bounds) < 5:
            # not worth overhead of binary search
            for bound in self.bounds:
                i = bound.version_containment(version)
                if i == 0:
                    return True
                if i == -1:
                    return False
        else:
            _, contains = self._contains_version(version)
            return contains

        return False
1250119
@Override
  public boolean contains(IVersion version)
  {
    return range1.contains(version) && range2.contains(version);
  }
572079
func (rf Range) OR(f Range) Range {
	return Range(func(v Version) bool {
		return rf(v) || f(v)
	})
}
1070981
public static boolean contains(Range range, Range subrange) {
        return range.getMinimum().doubleValue() <= subrange.getMinimum().doubleValue()
                && range.getMaximum().doubleValue() >= subrange.getMaximum().doubleValue();
        
    }
463923
function ensureUpperBound (range, maximum) {
  return function applyUpperBound (comparators) {
    var hasUpperBound = isBounded.comparators(comparators)
    if (hasUpperBound) return comparators
    var msg = printf(
      'Cannot determine major versions: ' +
      '"%s" is unbounded and ',
      range
    )
    if (maximum == null) {
      throw new Error(msg + 'no maximum was provided')
    }
    var upper = last(comparators)
    if (!upper.test(maximum)) {
      var explanation = printf('"%s" does not satisfy "%s"', maximum, upper.toString())
      throw new Error(msg + explanation)
    }
    return comparators.concat(new semver.Comparator('<=' + maximum))
  }
}