-
Notifications
You must be signed in to change notification settings - Fork 4
SemVer
- 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 string
Return 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.
- NOTE: MSU guarantees backwards compatibility for documented features and code only. Undocumented features/code of MSU may be changed at any time without notice, so we advise against using/referencing such code in your projects.
- For bug reports or feature requests, please create issues.
- If you would like to join the team, write to us at msu.team@protonmail.com.