- @std/semver
all symbols
The semantic version parser.
Examples
Example 1
Example 1
import { parse, parseRange, greaterThan, lessThan, format } from "@std/semver"; const semver = parse("1.2.3"); const range = parseRange("1.x || >=2.5.0 || 5.0.0 - 7.2.3"); const s0 = parse("1.2.3"); const s1 = parse("9.8.7"); greaterThan(s0, s1); // false lessThan(s0, s1); // true format(semver) // "1.2.3"
Functions
Compare two semantic version objects.
Returns difference between two versions by the release type, or undefined if the versions are the same.
Returns true if both semantic versions are logically equivalent, even if they're not the exact same version object.
Format a SemVer object into a string.
Formats the range into a string
Greater than or equal to comparison
Greater than comparison
Returns the new version resulting from an increment by release type.
Does a deep check on the object to determine if its a valid range.
Checks to see if value is a valid SemVer object. It does a check into each field including prerelease and build.
Less than or equal to comparison
Less than comparison
Returns the highest version in the list that satisfies the range, or undefined
if none of them do.
Returns the lowest version in the list that satisfies the range, or undefined if
none of them do.
Not equal comparison
Attempt to parse a string as a semantic version, returning either a SemVer
object or throws a TypeError.
Parses a range string into a Range object or throws a TypeError.
The ranges intersect every range of AND comparators intersects with a least one range of OR ranges.
The maximum valid SemVer for a given range or INVALID
The minimum valid SemVer for a given range or INVALID
Test to see if the version satisfies the range.
Returns the parsed version, or undefined if it's not valid.
A tries to parse a valid Range string or returns undefined
Checks to see if the version is greater than all possible versions of the range.
Less than range comparison
Sorts a list of semantic versions in descending order.
Interfaces
The shape of a valid semantic version comparator
Type Aliases
SemVer comparison operators.
A type representing a semantic version range. The ranges consist of a nested array, which represents a set of OR comparisons while the inner array represents AND comparisons.
| "major"
| "premajor"
| "minor"
| "preminor"
| "patch"
| "prepatch"
| "prerelease"
The possible release types are used as an operator for the increment function and as a result of the difference function.
Variables
A comparator which will span all valid semantic versions
ANY is a sentinel value used by some range calculations. It is not a valid SemVer object and should not be used directly.
A sentinel value used to denote an invalid SemVer object which may be the result of impossible ranges or comparator operations.
MAX is a sentinel value used by some range calculations.
It is equivalent to ∞.∞.∞.
The minimum valid SemVer object. Equivalent to 0.0.0.
A comparator which will not span any semantic versions
Variables
A comparator which will span all valid semantic versions
ANY is a sentinel value used by some range calculations. It is not a valid SemVer object and should not be used directly.
A sentinel value used to denote an invalid SemVer object which may be the result of impossible ranges or comparator operations.
MAX is a sentinel value used by some range calculations.
It is equivalent to ∞.∞.∞.
The minimum valid SemVer object. Equivalent to 0.0.0.
A comparator which will not span any semantic versions
Functions
Returns difference between two versions by the release type, or undefined if the versions are the same.
Functions
Returns true if both semantic versions are logically equivalent, even if they're not the exact same version object.
Functions
Formats the range into a string
Functions
Greater than or equal to comparison
Functions
Greater than comparison
Functions
Checks to see if the version is greater than all possible versions of the range.
Functions
Returns the new version resulting from an increment by release type.
Functions
Does a deep check on the object to determine if its a valid range.
Functions
Checks to see if value is a valid SemVer object. It does a check into each field including prerelease and build.
Functions
Less than or equal to comparison
Functions
Returns the highest version in the list that satisfies the range, or undefined
if none of them do.
Functions
Returns the lowest version in the list that satisfies the range, or undefined if
none of them do.
Functions
Not equal comparison
Functions
Attempt to parse a string as a semantic version, returning either a SemVer
object or throws a TypeError.
Functions
Parses a range string into a Range object or throws a TypeError.
Functions
The ranges intersect every range of AND comparators intersects with a least one range of OR ranges.
Functions
The maximum valid SemVer for a given range or INVALID
Functions
The minimum valid SemVer for a given range or INVALID
Functions
Sorts a list of semantic versions in descending order.
Functions
Test to see if the version satisfies the range.
Functions
Returns the parsed version, or undefined if it's not valid.
Functions
A tries to parse a valid Range string or returns undefined
Interfaces
The shape of a valid semantic version comparator
Type Aliases
SemVer comparison operators.
A type representing a semantic version range. The ranges consist of a nested array, which represents a set of OR comparisons while the inner array represents AND comparisons.
| "major"
| "premajor"
| "minor"
| "preminor"
| "patch"
| "prepatch"
| "prerelease"
The possible release types are used as an operator for the increment function and as a result of the difference function.