stringify
Reconstructs a version string from a AnyParsedVersion object — the scheme is read from
the object’s own scheme field, not passed separately (a ParsedGentooVersion can only ever
stringify as Gentoo, so there’s nothing to disambiguate).
This is the inverse of parse:
stringify(parse(v)) === stripV(v) for any valid version string v, in any scheme — up to
canonicalization (a Debian 0: epoch is dropped, a Gentoo _beta0 becomes _beta).
Available since v2.0.0
Import
Section titled “Import”Signature
Section titled “Signature”Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
parsed | AnyParsedVersion | A parsed version object, as returned by parse. |
Returns
Section titled “Returns”string — The reconstructed version string (without leading v).
Examples
Section titled “Examples”Reconstruct a stable version
Section titled “Reconstruct a stable version”Converts a ParsedVersion object back to a version string.
Round-trip with parse
Section titled “Round-trip with parse”stringify(parse(v)) returns the original version string (without leading v).
Reconstruct a Gentoo/Portage version
Section titled “Reconstruct a Gentoo/Portage version”The scheme is read from the parsed object itself, not passed separately.
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.
