From adce718d63035232bbe82f9932fa19ecf1bcf753 Mon Sep 17 00:00:00 2001 From: jdalton Date: Wed, 4 Mar 2015 00:45:42 -0800 Subject: [PATCH] Another cleanup pass on `createAssigner`. --- lodash.src.js | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/lodash.src.js b/lodash.src.js index 8201fba8b..aaae2864a 100644 --- a/lodash.src.js +++ b/lodash.src.js @@ -3168,17 +3168,22 @@ if (length < 2 || object == null) { return object; } - if (length > 3 && typeof args[length - 2] == 'function') { - var index = (length -= 2); - } else if (length > 2 && typeof args[length - 1] == 'function') { - index = --length; + var customizer = args[length - 2], + thisArg = args[length - 1], + guard = args[3]; + + if (length > 3 && typeof customizer == 'function') { + customizer = bindCallback(customizer, thisArg, 5); + length -= 2; + } else { + customizer = (length > 2 && typeof thisArg == 'function') ? thisArg : null; + length -= (customizer ? 1 : 0); } - var customizer = index && bindCallback(args[index], args[index + 1], 5); - if (length > 3 && isIterateeCall(args[1], args[2], args[3])) { + if (guard && isIterateeCall(args[1], args[2], guard)) { + customizer = length == 3 ? null : customizer; length = 2; - customizer = index === 3 ? null : customizer; } - index = 0; + var index = 0; while (++index < length) { var source = args[index]; if (source) {