Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: lib/coreUtils.js

Issue 29548719: Issue 5728 - Replace Services.vc.compare (Closed)
Patch Set: Created Sept. 18, 2017, 6:05 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | lib/notification.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
« no previous file with comments | « no previous file | lib/notification.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld