UNPKG

789 BJavaScriptView Raw
1import baseGet from './_baseGet.js';
2import baseSet from './_baseSet.js';
3import castPath from './_castPath.js';
4
5/**
6 * The base implementation of `_.pickBy` without support for iteratee shorthands.
7 *
8 * @private
9 * @param {Object} object The source object.
10 * @param {string[]} paths The property paths to pick.
11 * @param {Function} predicate The function invoked per property.
12 * @returns {Object} Returns the new object.
13 */
14function basePickBy(object, paths, predicate) {
15 var index = -1,
16 length = paths.length,
17 result = {};
18
19 while (++index < length) {
20 var path = paths[index],
21 value = baseGet(object, path);
22
23 if (predicate(value, path)) {
24 baseSet(result, castPath(path, object), value);
25 }
26 }
27 return result;
28}
29
30export default basePickBy;