diff options
author | 0neGal <mail@0negal.com> | 2024-06-08 18:10:06 +0200 |
---|---|---|
committer | 0neGal <mail@0negal.com> | 2024-06-08 18:10:06 +0200 |
commit | 7f011d34a2d5e13ba312b44ce6871e48a495ea8f (patch) | |
tree | 907875087645c62f3e8f3bbcd610bee6d06bc796 /src/app/js/version.js | |
parent | dbd8c6b152acc1188d2edd288488aa2da8f6310b (diff) | |
download | Viper-7f011d34a2d5e13ba312b44ce6871e48a495ea8f.tar.gz Viper-7f011d34a2d5e13ba312b44ce6871e48a495ea8f.zip |
replace js/misc.js file with js/version.js module
Diffstat (limited to 'src/app/js/version.js')
-rw-r--r-- | src/app/js/version.js | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/app/js/version.js b/src/app/js/version.js new file mode 100644 index 0000000..97223f9 --- /dev/null +++ b/src/app/js/version.js @@ -0,0 +1,44 @@ +module.exports = { + is_newer: (version1, version2) => { + version1 = version.format(version1, true).split("."); + version2 = version.format(version2, true).split("."); + + for (let i = 0; i < version1.length; i++) { + + + let nums = [ + parseInt(version1[i]) || 0, + parseInt(version2[i]) || 0 + ]; + if (nums[0] > nums[1]) { + return true; + } else if (nums[0] < nums[1]) { + return false; + } + } + + return false; + }, + format: (version_number, no_leading_v) => { + version_number = version_number.trim(); + + if (no_leading_v) { + if (version_number[0] == "v") { + return version_number.slice(1, version_number.length); + } + + return version_number; + if (no_leading_v) { + return version_number + } + + return "v" + version_number; + } else { + if (version_number[0] != "v") { + return "v" + version_number; + } + } + + return version_number; + } +} |