From a73b92b58e8970031664286263a623f272886a42 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Fri, 2 Feb 2018 17:08:43 -0800 Subject: [PATCH] =?UTF-8?q?Avoid=20using=20the=20values=20toString=20metho?= =?UTF-8?q?d=20in=20=5F.invert=20if=20it=E2=80=99s=20not=20a=20function.?= =?UTF-8?q?=20[closes=20#3260]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lodash.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lodash.js b/lodash.js index 1f8aafcfc..04d9ffd80 100644 --- a/lodash.js +++ b/lodash.js @@ -13173,6 +13173,11 @@ * // => { '1': 'c', '2': 'b' } */ var invert = createInverter(function(result, value, key) { + if (value != null && + typeof value.toString != 'function') { + value = nativeObjectToString.call(value); + } + result[value] = key; }, constant(identity)); @@ -13203,6 +13208,11 @@ * // => { 'group1': ['a', 'c'], 'group2': ['b'] } */ var invertBy = createInverter(function(result, value, key) { + if (value != null && + typeof value.toString != 'function') { + value = nativeObjectToString.call(value); + } + if (hasOwnProperty.call(result, value)) { result[value].push(key); } else {