diff options
Diffstat (limited to 'src/app/js/misc.js')
-rw-r--r-- | src/app/js/misc.js | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/app/js/misc.js b/src/app/js/misc.js new file mode 100644 index 0000000..b35f239 --- /dev/null +++ b/src/app/js/misc.js @@ -0,0 +1,44 @@ +version = { + 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; + } +} |