VersionRange

A range of versions that are acceptable

While not directly described in SemVer v2.0.0, a common set of range operators have appeared among package managers. We mostly NPM's: https://semver.npmjs.com/

Hence the acceptable forms for this string are as follows:

  • "1.0.0" - a single version in SemVer format
  • "==1.0.0" - alternative single version notation
  • ">1.0.0" - version range with a single bound
  • ">1.0.0 <2.0.0" - version range with two bounds
  • "~>1.0.0" - a fuzzy version range
  • "~>1.0" - a fuzzy version range with partial version
  • "^1.0.0" - semver compatible version range (same version if 0.x.y, ==major >=minor.patch if x.y.z)
  • "^1.0" - same as ^1.0.0
  • "~master" - a branch name
  • "*" - match any version (see also VersionRange.Any)

Apart from "<" and ">", ">=" and "<=" are also valid comparators.

Members

Functions

isValid
bool isValid()
Undocumented in source. Be warned that the author may not have intended to support it.
matches
bool matches(Version v, VersionMatchMode mode)
Undocumented in source. Be warned that the author may not have intended to support it.
matchesAny
bool matchesAny()

Determines if this dependency specification matches arbitrary versions. This is true in particular for the any constant.

merge
void merge(VersionRange o)

Modify in place

opCmp
int opCmp(VersionRange o)
toString
string toString()

Returns a string representation of this range

Properties

isExactVersion
bool isExactVersion [@property getter]

Returns true iff the version range only matches a specific version.

Static functions

fromString
VersionRange fromString(string ves)
Undocumented in source. Be warned that the author may not have intended to support it.

Static variables

Any
auto Any;

Matches any version

Invalid
auto Invalid;

Doesn't match any version

Meta