2016-11-16 01:59:39 +01:00
|
|
|
var baseGet = require('./_baseGet'),
|
|
|
|
baseSet = require('./_baseSet');
|
2016-10-10 03:43:44 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The base implementation of `_.pickBy` without support for iteratee shorthands.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @param {Object} object The source object.
|
2016-11-16 01:59:39 +01:00
|
|
|
* @param {string[]} paths The property paths to pick.
|
2016-10-10 03:43:44 +02:00
|
|
|
* @param {Function} predicate The function invoked per property.
|
|
|
|
* @returns {Object} Returns the new object.
|
|
|
|
*/
|
2016-11-16 01:59:39 +01:00
|
|
|
function basePickBy(object, paths, predicate) {
|
2016-10-10 03:43:44 +02:00
|
|
|
var index = -1,
|
2016-11-16 01:59:39 +01:00
|
|
|
length = paths.length,
|
2016-10-10 03:43:44 +02:00
|
|
|
result = {};
|
|
|
|
|
|
|
|
while (++index < length) {
|
2016-11-16 01:59:39 +01:00
|
|
|
var path = paths[index],
|
|
|
|
value = baseGet(object, path);
|
2016-10-10 03:43:44 +02:00
|
|
|
|
2016-11-16 01:59:39 +01:00
|
|
|
if (predicate(value, path)) {
|
|
|
|
baseSet(result, path, value);
|
2016-10-10 03:43:44 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = basePickBy;
|