From 2da1b2af1abe6d988c5a39dea6b687eb44ef5c56 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Thu, 9 Jul 2015 19:42:04 -0700 Subject: [PATCH] Drop boolean `orders` param support in `_.sortByOrder`. --- lodash.src.js | 6 +++--- test/test.js | 16 ++++++---------- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/lodash.src.js b/lodash.src.js index 938c720df..c2fa0d802 100644 --- a/lodash.src.js +++ b/lodash.src.js @@ -473,7 +473,7 @@ return result; } var order = orders[index]; - return result * ((order === 'asc' || order === true) ? 1 : -1); + return result * (order === 'asc' ? 1 : -1); } } // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications @@ -2647,7 +2647,7 @@ * @private * @param {Array|Object|string} collection The collection to iterate over. * @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by. - * @param {boolean[]|string[]} orders The sort orders of `iteratees`. + * @param {string[]} orders The sort orders of `iteratees`. * @returns {Array} Returns the new sorted array. */ function baseSortByOrder(collection, iteratees, orders) { @@ -6679,7 +6679,7 @@ * @category Collection * @param {Array|Object|string} collection The collection to iterate over. * @param {Function[]|Object[]|string[]} [iteratees=[_.identity]] The iteratees to sort by. - * @param {boolean[]|string[]} [orders] The sort orders of `iteratees`. + * @param {string[]} [orders] The sort orders of `iteratees`. * @param- {Object} [guard] Enables use as an iteratee for functions like `_.reduce`. * @returns {Array} Returns the new sorted array. * @example diff --git a/test/test.js b/test/test.js index d24cb4085..1b196ad3b 100644 --- a/test/test.js +++ b/test/test.js @@ -14173,18 +14173,14 @@ { 'a': 'y', 'b': 2 } ]; - test('should sort multiple properties by specified orders', 2, function() { - _.each([[false, true], ['desc', 'asc']], function(orders) { - var actual = _.sortByOrder(objects, ['a', 'b'], orders); - deepEqual(actual, [objects[3], objects[1], objects[2], objects[0]]); - }); + test('should sort multiple properties by specified orders', 1, function() { + var actual = _.sortByOrder(objects, ['a', 'b'], ['desc', 'asc']); + deepEqual(actual, [objects[3], objects[1], objects[2], objects[0]]); }); - test('should sort a property in ascending order when its order is not specified', 2, function() { - _.each([[false], ['desc']], function(orders) { - var actual = _.sortByOrder(objects, ['a', 'b'], orders); - deepEqual(actual, [objects[3], objects[1], objects[2], objects[0]]); - }); + test('should sort a property in ascending order when its order is not specified', 1, function() { + var actual = _.sortByOrder(objects, ['a', 'b'], ['desc']); + deepEqual(actual, [objects[3], objects[1], objects[2], objects[0]]); }); }());