mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-09 02:17:50 +00:00
Add props param to basePickBy.
This commit is contained in:
20
lodash.js
20
lodash.js
@@ -3470,12 +3470,9 @@
|
|||||||
*/
|
*/
|
||||||
function basePick(object, props) {
|
function basePick(object, props) {
|
||||||
object = Object(object);
|
object = Object(object);
|
||||||
return arrayReduce(props, function(result, key) {
|
return basePickBy(object, props, function(value, key) {
|
||||||
if (key in object) {
|
return key in object;
|
||||||
result[key] = object[key];
|
});
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}, {});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -3483,12 +3480,12 @@
|
|||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Object} object The source object.
|
* @param {Object} object The source object.
|
||||||
|
* @param {string[]} props The property identifiers to pick from.
|
||||||
* @param {Function} predicate The function invoked per property.
|
* @param {Function} predicate The function invoked per property.
|
||||||
* @returns {Object} Returns the new object.
|
* @returns {Object} Returns the new object.
|
||||||
*/
|
*/
|
||||||
function basePickBy(object, predicate) {
|
function basePickBy(object, props, predicate) {
|
||||||
var index = -1,
|
var index = -1,
|
||||||
props = getAllKeysIn(object),
|
|
||||||
length = props.length,
|
length = props.length,
|
||||||
result = {};
|
result = {};
|
||||||
|
|
||||||
@@ -13035,10 +13032,7 @@
|
|||||||
* // => { 'b': '2' }
|
* // => { 'b': '2' }
|
||||||
*/
|
*/
|
||||||
function omitBy(object, predicate) {
|
function omitBy(object, predicate) {
|
||||||
predicate = getIteratee(predicate);
|
return pickBy(object, negate(getIteratee(predicate)));
|
||||||
return basePickBy(object, function(value, key) {
|
|
||||||
return !predicate(value, key);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -13081,7 +13075,7 @@
|
|||||||
* // => { 'a': 1, 'c': 3 }
|
* // => { 'a': 1, 'c': 3 }
|
||||||
*/
|
*/
|
||||||
function pickBy(object, predicate) {
|
function pickBy(object, predicate) {
|
||||||
return object == null ? {} : basePickBy(object, getIteratee(predicate));
|
return object == null ? {} : basePickBy(object, getAllKeysIn(object), getIteratee(predicate));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user