From 80dbd4cbfab6a800668602b955eaa98de9b691c2 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sat, 23 Jul 2016 20:48:07 -0700 Subject: [PATCH] Add `props` param to `basePickBy`. --- lodash.js | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/lodash.js b/lodash.js index 50501093c..8d573e148 100644 --- a/lodash.js +++ b/lodash.js @@ -3470,12 +3470,9 @@ */ function basePick(object, props) { object = Object(object); - return arrayReduce(props, function(result, key) { - if (key in object) { - result[key] = object[key]; - } - return result; - }, {}); + return basePickBy(object, props, function(value, key) { + return key in object; + }); } /** @@ -3483,12 +3480,12 @@ * * @private * @param {Object} object The source object. + * @param {string[]} props The property identifiers to pick from. * @param {Function} predicate The function invoked per property. * @returns {Object} Returns the new object. */ - function basePickBy(object, predicate) { + function basePickBy(object, props, predicate) { var index = -1, - props = getAllKeysIn(object), length = props.length, result = {}; @@ -13035,10 +13032,7 @@ * // => { 'b': '2' } */ function omitBy(object, predicate) { - predicate = getIteratee(predicate); - return basePickBy(object, function(value, key) { - return !predicate(value, key); - }); + return pickBy(object, negate(getIteratee(predicate))); } /** @@ -13081,7 +13075,7 @@ * // => { 'a': 1, 'c': 3 } */ function pickBy(object, predicate) { - return object == null ? {} : basePickBy(object, getIteratee(predicate)); + return object == null ? {} : basePickBy(object, getAllKeysIn(object), getIteratee(predicate)); } /**