aboutsummaryrefslogtreecommitdiff
path: root/src/app/js/version.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/app/js/version.js')
-rw-r--r--src/app/js/version.js44
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;
+ }
+}