Index: lib/coreUtils.js |
=================================================================== |
--- a/lib/coreUtils.js |
+++ b/lib/coreUtils.js |
@@ -34,3 +34,23 @@ |
return Object.create(cls.prototype, desc(properties)); |
} |
exports.extend = extend; |
+ |
+function compareVersion(v1, v2) |
+{ |
+ let components1 = v1.split("."); |
+ let components2 = v2.split("."); |
+ let result = 0; |
+ |
+ for (let i = 0; result == 0 && (i < components1.length || |
+ i < components2.length); i++) |
+ { |
+ let comp1 = components1[i]; |
+ let comp2 = components2[i]; |
+ |
+ result = (comp1 == "*" ? Number.MAX_VALUE : parseInt(comp1, 10) || 0) - |
Manish Jethani
2017/09/19 07:53:14
I'd just like to point out that parseInt doesn't j
Manish Jethani
2017/09/19 08:21:40
Bitwise OR-ing with 0 will mess up any values larg
Sebastian Noack
2017/09/19 22:53:43
How exactly might parseInt() return Infinity? It s
Manish Jethani
2017/09/20 01:15:38
Number.MAX_VALUE is approximately 1.79E+308, so fo
Sebastian Noack
2017/09/20 01:31:25
Interesting. It's probably not a too relevant scen
|
+ (comp2 == "*" ? Number.MAX_VALUE : parseInt(comp2, 10) || 0); |
Manish Jethani
2017/09/19 07:53:14
Also of course this version differs from the previ
|
+ } |
+ |
+ return result; |
+} |
+exports.compareVersion = compareVersion; |