From aca07530aac448be5f71b3d6bd8b5c158659e550 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Tue, 13 Jan 2015 01:37:15 -0800 Subject: [PATCH] Ensure `_.sortByAll` iteratee call guard works when `_.partialRight` is applied. --- lodash.src.js | 2 +- test/test.js | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lodash.src.js b/lodash.src.js index c7ed50d61..6befd3fd8 100644 --- a/lodash.src.js +++ b/lodash.src.js @@ -6541,7 +6541,7 @@ */ function sortByAll(collection) { var args = arguments; - if (args.length == 4 && isIterateeCall(args[1], args[2], args[3])) { + if (args.length > 3 && isIterateeCall(args[1], args[2], args[3])) { args = [collection, args[1]]; } var index = -1, diff --git a/test/test.js b/test/test.js index b5e57e55d..7084c5b8a 100644 --- a/test/test.js +++ b/test/test.js @@ -11809,8 +11809,14 @@ { 'a': 'y', '0': 2 } ]; - var actual = _.reduce([['a']], _.sortByAll, objects); - deepEqual(actual, [objects[0], objects[2], objects[1], objects[3]]); + var funcs = [_.sortByAll, _.partialRight(_.sortByAll, 'bogus')], + expected = _.map(funcs, _.constant([objects[0], objects[2], objects[1], objects[3]])); + + var actual = _.map(funcs, function(func) { + return _.reduce([['a']], func, objects); + }); + + deepEqual(actual, expected); }); }());