compare-versions-roku
v1.0.1
Published
Compare semver version strings in BrightScript
Downloads
12
Maintainers
Readme
compare-versions-roku
Compare semver version strings to find greater, equal or lesser.
Based on https://github.com/omichelsen/compare-versions.
Installation
with kopytko-packager
When using kopytko-packager you can simly define this package as a dependecy.
npm i compare-versions-roku
without kopytko-packager
Copy compareVersions.brs
file from this repository to your project.
Remember that it uses also the getProperty
, getType
, and ternary
functions from the kopytko-utils
, so copy it along with it, or create a similar one.
Usage
' @import /components/libs/compareVersions.brs from compare-versions-roku
function areVersionsTheSame() as Boolean
return compareVersions("1.2.0", "1.2")
end function
For more examples, you can see test cases.
Documentation
Currently, there is only compareVersions function. It will return 1 if the first version is greater, 0 if the versions are equal, and -1 if the second version is greater:
compareVersions(v1, v2)
params:
- v1 (roString) - first version string
- v2 (roString) - second version string
returns (roInteger):
-1
- the second version is greater0
- versions are equal1
- first version is greater