LanguageValues and typesStandard typesSoftware
SemanticVersion
On this page
A software version: 1.2.3-alpha.1+build.5.
Use it for your own or a package's release number. < compares two the way versions are meant to compare. For a range such as ^1.2, use VersionRange.
Shape
| Field | Type | Required? |
|---|---|---|
major |
Int |
Yes |
minor |
Int |
Yes |
patch |
Int |
Yes |
pre_release |
Text |
No |
build |
Text |
No |
Write every field when you build one, and give a field that isn't required as none.
Example
SemanticVersion { major: 1 minor: 2 patch: 3 pre_release: none build: none }text.parse(raw, as: SemanticVersion) reads one from text that comes from outside. Text that isn't one at all fails malformed, such as v1.0.0, 1.0 or 1.0.0.0.
Good to know
text.parsereads1.2.3. Avat the front and1.0are refused, so give all three numbers.- Build metadata, the part after
+, is ignored when ordering. ==tells you whether two are the same, and<andlist.sort_bycompare and sort them.
In JSON
A string, in a request, a response or json.write:
"1.0.0-alpha""1.0.0-alpha.1""1.0.0-alpha.beta"
When you read one, a field that isn't required may be left out, or sent as null.
Details
Text form, storage, how it is shown, and operations
SemanticVersion is in the group Software, and has been in Jadpo since 0.1.0.
Text form
text.from writes one standard text form, the same form text.parse reads back: 1.0.0-alpha, 1.0.0-alpha.1 and 1.0.0-alpha.beta.
How it is stored
It is stored in 5 columns, each named for the field, _ and its suffix. This is 1.0.0-beta.11:
| Column | Type | Holds |
|---|---|---|
<field>_major |
bigint |
1 |
<field>_minor |
bigint |
0 |
<field>_patch |
bigint |
0 |
<field>_pre_release |
text |
'beta.11' |
<field>_build |
text |
NULL::text |
How it is shown to people
text.format(value, locale:) shows it to people in their locale.
With locale: Locale.en_gb:
| Value | Shown |
|---|---|
1.0.0-alpha |
1.0.0-alpha |
1.0.0-alpha.1 |
1.0.0-alpha.1 |
1.0.0-alpha.beta |
1.0.0-alpha.beta |
1.0.0-beta |
1.0.0-beta |
1.0.0-beta.2 |
1.0.0-beta.2 |
1.0.0-beta.11 |
1.0.0-beta.11 |
1.0.0-rc.1 |
1.0.0-rc.1 |
1.0.0 |
1.0.0 |
1.9.0 |
1.9.0 |
1.10.0+build.5 |
1.10.0+build.5 |
2.0.0 |
2.0.0 |
Operations
semver.satisfies(version: SemanticVersion, range: VersionRange) -> Bool: Whetherversionis insiderange, as node-semver reads the range: in one of its sets joined by||, meeting each comparison of it. A pre-release is inside only where a comparison of that set names a pre-release of the same major, minor and patch, so^1.2.3never takes2.0.0-beta.1.
It also takes text.parse, text.from, text.format, json.read, json.write and ==. How every standard type behaves says how they work.
Markdown for agents: /docs/types/type-semantic-version.md.Built from Jadpo main at aee2e8f.