mirror of
https://github.com/S2-/gitlit
synced 2025-08-04 05:10:05 +02:00
packager
This commit is contained in:
33
app/node_modules/compare-version/index.js
generated
vendored
Normal file
33
app/node_modules/compare-version/index.js
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Compare semver version numbers
|
||||
*
|
||||
* @param {String} a
|
||||
* @param {String} b
|
||||
* @api public
|
||||
*/
|
||||
|
||||
module.exports = function(a, b) {
|
||||
var i;
|
||||
var len;
|
||||
|
||||
if (typeof a + typeof b !== 'stringstring') {
|
||||
return false;
|
||||
}
|
||||
|
||||
a = a.split('.');
|
||||
b = b.split('.');
|
||||
i = 0;
|
||||
len = Math.max(a.length, b.length);
|
||||
|
||||
for (; i < len; i++) {
|
||||
if ((a[i] && !b[i] && parseInt(a[i]) > 0) || (parseInt(a[i]) > parseInt(b[i]))) {
|
||||
return 1;
|
||||
} else if ((b[i] && !a[i] && parseInt(b[i]) > 0) || (parseInt(a[i]) < parseInt(b[i]))) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
};
|
Reference in New Issue
Block a user