Range
a version requirement: a disjunction (logical OR) of
ComparatorSets, of the kind found in package manifests. Parse one with
from-string and test membership with satisfies?.
Supported syntax (a practical subset of the npm/node-semver grammar):
- comparators:
>=1.2.3,>1.2.3,<=1.2.3,<1.2.3,=1.2.3 - an exact version:
1.2.3(equivalent to=1.2.3) - caret ranges:
^1.2.3(compatible up to the next non-zero component) - tilde ranges:
~1.2.3(patch-level changes within the minor) - x-ranges and partials:
1.2.x,1.2.*,1.x,1,* - hyphen ranges:
1.2.3 - 2.3.4(inclusive on both ends) - whitespace joins comparators with
AND;||joins sets withOR
A leading v (as in v1.2.3) is accepted and ignored.
from-string
(Fn [(Ref String a)] (Maybe Range))
(from-string s)
parses a range string such as ^1.2.3, >=1.0.0 <2.0.0, or
1.2.x || 2.0.0 into a Range. Returns Nothing when the string is malformed.
The empty string and * both parse to the universal range that every version
satisfies.
max-satisfying
(Fn [(Ref Range a), (Ref (Array Semver) a)] (Maybe Semver))
(max-satisfying r versions)
returns the highest-precedence version in versions that
satisfies the range r, or Nothing when none of them do. This is the version
a dependency resolver picks for r.
min-satisfying
(Fn [(Ref Range a), (Ref (Array Semver) a)] (Maybe Semver))
(min-satisfying r versions)
returns the lowest-precedence version in versions that
satisfies the range r, or Nothing when none of them do.
satisfies?
(Fn [(Ref Range a), (Ref Semver a)] Bool)
(satisfies? r v)
returns whether the version v satisfies the range r.
Comparisons follow SemVer 2.0.0 precedence. Following node-semver's default,
a pre-release version (e.g. 1.2.3-beta) satisfies the range only when some
comparator explicitly names a pre-release at the same major.minor.patch.
satisfying
(Fn [(Ref Range a), (Ref (Array Semver) a)] (Array Semver))
(satisfying r versions)
returns every version in versions that satisfies the range
r, sorted ascending by SemVer precedence. The result is empty when none match;
its last element, when present, is the version max-satisfying
returns, and its first the version min-satisfying returns.
set-sets!
(Fn [(Ref Range a), (Array ComparatorSet)] ())
sets the sets property of a Range in place.
sets
(Fn [(Ref Range a)] (Ref (Array ComparatorSet) a))
gets the sets property of a Range.
str
(Fn [(Ref Range a)] String)
(str r)
renders a range back to string form; comparator sets are joined by
||. The output is normalized and may differ from the parsed input.
update-sets
(Fn [Range, (Ref (Fn [(Array ComparatorSet)] (Array ComparatorSet) a) b)] Range)
updates the sets property of a Range using a function f.