From c396b60612f0f862e354673a36bc89dd3cad90d4 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sun, 30 Aug 2015 04:45:32 -0700 Subject: [PATCH] Cleanup `_.pairs` and `_.invert`. --- lodash.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lodash.js b/lodash.js index 104fd6eec..b7ff16f1b 100644 --- a/lodash.js +++ b/lodash.js @@ -9105,6 +9105,7 @@ * @category Object * @param {Object} object The object to invert. * @param {boolean} [multiValue] Allow multiple values per key. + * @param- {Object} [guard] Enables use as an iteratee for functions like `_.map`. * @returns {Object} Returns the new inverted object. * @example * @@ -9117,11 +9118,10 @@ * _.invert(object, true); * // => { '1': ['a', 'c'], '2': ['b'] } */ - function invert(object, multiValue) { - multiValue = typeof multiValue == 'boolean' && multiValue; + function invert(object, multiValue, guard) { return arrayReduce(keys(object), function(result, key) { var value = object[key]; - if (multiValue) { + if (multiValue && !guard) { if (hasOwnProperty.call(result, value)) { result[value].push(key); } else { @@ -9416,7 +9416,6 @@ * // => [['barney', 36], ['fred', 40]] (iteration order is not guaranteed) */ function pairs(object) { - object = Object(object); return arrayMap(keys(object), function(key) { return [key, object[key]]; });