Skip to content

Instantly share code, notes, and snippets.

@oldaccountarchived
Created February 10, 2016 19:57
Show Gist options
  • Save oldaccountarchived/1b1682d4e1e81f487e9c to your computer and use it in GitHub Desktop.
Save oldaccountarchived/1b1682d4e1e81f487e9c to your computer and use it in GitHub Desktop.
function compareSemver(ver1, ver2) {
ver1 = ver1.split('.');
ver2 = ver2.split('.');
for (var i = 0; i < 3; i++) {
var nver1 = parseInt(ver1[i]);
var nver2 = parseInt(ver2[i]);
if (nver1 > nver2)
return 1;
if (nver1 < nver2)
return -1;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment