Browse the docs

parseVersion

Reads a version such as 2.10.3-beta.2 into major, minor, patch, pre and build.

Details #

parseVersion(text) returns a record: major, minor and patch as numbers, pre (the part after -, such as beta.2) and build (the part after +) as text. A missing minor or patch is 0, and a leading v is allowed.

Parameters #

Takes 1 argument. {{ parseVersion(text) }}

Examples #

parseVersion("2.10.3-beta.2").pre
→ beta.2
parseVersion("v1.4")
→ { "build" : "", "major" : 1, "minor" : 4, "patch" : 0, "pre" : "" }

Gotchas #

  • Text that is not a version fails with parseVersion() couldn't read a version.