semver

semantic versioner.

Syntax

  • r = semver(version_str, version_range)

Input argument

  • version_str - a string: current version.

  • version_range - a string: version to compare or range.

Output argument

  • r - a double: -1, 0 or 1.

Description

semver compares a version string to an version or an range version.

if an range version is used, r return 0 (not satisfied) or 1 (satisfied).

if an simple version is used, an comparaison value r is returned -1 (inferior), 0 (equal) or 1 (superior).

supported range operators:

= - Equality

>= - Higher or equal to

<= - Lower or equal to

< - Lower than

> - Higher than

^ - Caret operator comparison

~ - Tilde operator comparison

Used function(s)

semver.c

Bibliography

https://semver.org/

Example

semver('1.5.10', '2.3.0')
semver('2.3.0', '1.5.10');
semver('1.5.10', '1.5.10')
semver('1.2.3', '~1.2.3')
semver('1.5.3', '~1.2.3')
semver('1.0.3', '~1')
semver('2.0.3', '~1')
semver('1.2.3-alpha', '&gt;1.2.3-beta')
semver('1.2.3-alpha', '&lt;1.2.3-beta')
semver('1.2.3', '^1.2.3')
semver('1.2.2', '^1.2.3')
semver('1.9.9', '^1.2.3')
semver('2.0.1', '^1.2.3')

See also

version, getmodules.

History

VersionDescription

1.0.0

initial version

Author

Allan CORNET

Last updated