sort expects a 1, 0, or -1 to be returned, not a boolean

This commit is contained in:
Spencer Alger 2014-06-19 09:52:29 -07:00
parent aac88eaa83
commit 808703c0cd
2 changed files with 3 additions and 4 deletions

View file

@ -8,18 +8,18 @@ define(function (require) {
// Get the max version in this cluster
var max = function (versions) {
return _.last(sortVersions(versions));
return sortVersions(versions).pop();
};
// Return the lowest version in the cluster
var min = function (versions) {
return _.first(sortVersions(versions));
return sortVersions(versions).shift();
};
// Sort versions from lowest to highest
var sortVersions = function (versions) {
return _.uniq(versions).sort(function (a, b) {
return !compare(a, b);
return compare(a, b) ? -1 : 1;
});
};

View file

@ -17,7 +17,6 @@ define(function (require) {
];
describe('version math (0.90.0 - 2.3.1)', function () {
var methods = 'max,min,eq,is,lt,lte,gt,gte'.split(',');
describe('methods', function () {
it('should have ' + methods.join(', ') + ' methods', function () {