satisfiesRange
Checks if a version satisfies a range, according to the given scheme (simple
implementation — see each scheme’s own doc for exactly which operators are supported).
'semver' (default) — >=, >, <=, <, ^ (caret, patch+minor updates within the
same major), ~ (tilde, patch updates within the same major.minor), or an exact match.
'gentoo' — >=, >, <=, <, or an exact match, compared per Gentoo/Portage
ordering (see compare). ^/~ throw: Portage’s own atom syntax gives those
characters different, unrelated meanings, so silently reusing SemVer’s semantics for them
would be actively misleading rather than merely unsupported.
Available since v1.9.0
Import
Section titled “Import”Signature
Section titled “Signature”Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
version | string | Version to check |
range | string | Range pattern (e.g., ”>=1.0.0”, “~1.2.0”, “^1.0.0”) |
scheme | VersionScheme | Which version scheme to interpret `version`/`range` as. Defaults to `‘semver’`. |
Returns
Section titled “Returns”boolean — True if version satisfies the range
Examples
Section titled “Examples”Check caret range
Section titled “Check caret range”Caret (^) allows patch and minor updates within the same major.
Check greater-than-or-equal range
Section titled “Check greater-than-or-equal range”The >= operator checks if the version is at least the specified value.
Out of range
Section titled “Out of range”Returns false when the version does not satisfy the range.
Check a Gentoo/Portage range
Section titled “Check a Gentoo/Portage range”Supports >=, >, <=, <, and exact match — ^ and ~ throw, since Portage gives those characters different, unrelated meanings.
Related Types
Section titled “Related Types”VersionScheme
Section titled “VersionScheme”Identifies which version scheme parse/compare should use to interpret a
version string. Defaults to 'semver' everywhere it’s accepted.
