isPrerelease
Returns true when the version string has a prerelease suffix, according to the given
scheme.
'semver' (default) — true when there’s a - after the core MAJOR.MINOR.PATCH.
'gentoo' — true when the last suffix segment is alpha/beta/pre/rc (these sort
below the plain release). A p suffix or a -r revision don’t count — p sorts above the
release, and a revision isn’t a prerelease of anything, it’s a rebuild of the same version.
'debian' — true when the upstream part contains ~, the Debian convention for a
version that must sort before the final release (1.0~rc1). A ~ in the revision doesn’t
count — 1.0-1~bpo12+1 is a backport of the 1.0 release, not a prerelease of it.
Available since v2.0.0
Import
Section titled “Import”Signature
Section titled “Signature”Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
version | string | A version string (e.g. `‘2.0.0-alpha.1’`, `‘1.0.0’`, `‘1.2.3_rc1’`). |
scheme | VersionScheme | Which version scheme to interpret `version` as. Defaults to `‘semver’`. (optional) |
Returns
Section titled “Returns”boolean — true if the version is a prerelease, false otherwise.
Examples
Section titled “Examples”Detect a prerelease version
Section titled “Detect a prerelease version”Returns true for any version string that contains a prerelease suffix.
Stable versions return false
Section titled “Stable versions return false”Returns false when the version has no prerelease suffix.
Accept a ParsedVersion object
Section titled “Accept a ParsedVersion object”Works with the result of parse() — checks the prerelease array instead of string matching.
Related Types
Section titled “Related Types”AnyParsedVersion
Section titled “AnyParsedVersion”A version parsed by parse, in whichever scheme it was parsed as — narrow on the
scheme field to access scheme-specific properties (major/minor/patch for 'semver',
components/letter/suffixes/revision for 'gentoo', epoch/upstream/revision for
'debian').
Deliberately not named ParsedVersion: that name has been public API since 2.0.0 for
the flat SemVer-only shape (.major/.minor/.patch directly, no narrowing needed), and
turning it into a union would silently break any existing code typed as ParsedVersion that
reads those fields without narrowing first — a real compatibility break with no
MIGRATION.md entry, since this repo ties breaking changes to major-version bumps.
VersionScheme
Section titled “VersionScheme”Identifies which version scheme parse/compare should use to interpret a
version string. Defaults to 'semver' everywhere it’s accepted.
