SemVer - MSUTeam/MSU GitHub Wiki
- isSemver
- getTable
- compare
- compareVersionWithOperator
- compareMajorVersionWithOperator
- compareMinorVersionWithOperator
- getVersionString
- getShortVersionString
File path: scripts/config/msu/semver.nut
Functions relating to semantic versioning, used by MSU when working with mod versions.
::MSU.SemVer.isSemver( _string )
// _string is a stringReturn true if _string is a valid semantic version.
Returns false otherwise.
::MSU.SemVer.getTable( _version )
// _version is a string_version must be a semver version.
Returns a table representation of _version,
with separate Version, PreRelease and Metadata arrays as values.
::MSU.SemVer.compare( _version1, _version2 )
// _version1 and _version2 are tables_version1 and _version are SemVer tables returned by getTable.
Returns the equivalent of _version1 <=> _version2 if they were integers:
Returns -1 if _version1 < _version2.
Returns 1 if _version1 > _version2.
Returns 0 if they are equal.
::MSU.SemVer.compareVersionWithOperator( _version1, _operator, _version2 )
// _version1 and version2 are tables or strings
// _operator is a string or null_version1 and _version are either SemVer tables returned by getTable,
or Semantic Version strings.
_operator is one of the following symbols:
< <= = null >= >
The function returns _version1 _operator _version2,
null is considered equivalent to =.
local table1 = ::MSU.SemVer.getTable("1.0.0");
local table2 = ::MSU.SemVer.getTable("1.0.2");
::logInfo(::MSU.compareVersionWithOperator(table1, "<", table2)); // prints true
::logInfo(::MSU.compareVersionWithOperator(table1, "=", table2)); // prints false
::logInfo(::MSU.compareVersionWithOperator(table1, ">", table2)); // prints false::MSU.SemVer.compareMajorVersionWithOperator( _version1, _operator, _version2 )
// _version1 and version2 are tables or strings
// _operator is a string or null_version1 and _version are either SemVer tables returned by getTable,
or Semantic Version strings.
_operator is one of the following symbols:
< <= = null >= >
The function compares the MAJOR sections of the Semantic Versions
and returns true or false depending on the operator.
::MSU.SemVer.compareMinorVersionWithOperator( _version1, _operator, _version2 )
// _version1 and version2 are tables or strings
// _operator is a string or null_version1 and _version are either SemVer tables returned by getTable,
or Semantic Version strings.
_operator is one of the following symbols:
< <= = null >= >
The function compares the MAJOR and MINOR sections of the Semantic Versions
and returns true or false depending on the operator.
::MSU.SemVer.getVersionString( _version )
// _version is a table_version is a table returned by getTable.
Returns the string version of the Semantic Version stored in the table.
::MSU.SemVer.getShortVersionString( _version )
// _version is a table_version is a table returned by getTable.
Returns the string version of the Semantic Version stored in the table,
without including the prerelease and metadata portions.