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: Handle case in which the same compnent in both versions are rounded to Infinity Created Sept. 20, 2017, 1:28 a.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 == "*" ? Infinity : parseInt(comp1, 10) || 0) -
+ (comp2 == "*" ? Infinity : parseInt(comp2, 10) || 0) || 0;
+ }
+
+ 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