Import: version
The version import provides functions for parsing versions and version constraints, and verifying versions against a set of constraints.
Versions are created through the new
function, which accepts a string type in dotted-tri format (i.e. 1.0.0-alpha.1+001) that can represent a version.
version.new(v)
Constructs a version from string value.
version.major
An integer representation of the Major number for a given version .
version.minor
An integer representation of the Minor number for a given version.
version.patch
An integer representation of the Patch number for a given version.
version.prerelease
A string representation of the Prerelease for a given version.
version.metadata
A string representation of the Metadata for a given version.
version.version
A string representation of the version including pre-release and metadata information.
version.greater_than(v)
Tests that the version is greater than a given version.
version.greater_than_or_equals(v)
Tests that the version is greater than or equal to a given version.
version.less_than(v)
Tests that the version is less than a given version.
version.less_than_or_equals(v)
Tests that the version is less than or equal to a given version.
version.less_than_or_equals(v)
Tests that the version equals a given version.
version.compare(v)
Compares one version with a given version. Compare returns -1, 0, or 1 if the version is less, equal, or greater than the other version, respectively.
version.satisfies(v, x)
Tests that a version adheres to one or more version constraints. Satisfies supports the following restriction operators:
- =
- !=
- >
- <
- >=
- <=
- ~>
Satisfies supports the following usage scenarios:
- A constraint with a pre-release can only match a pre-release version that contains the same major, minor and patch identifiers.
- A constraint without a pre-release can only match a version without a pre-release.