UNPKG

766 BJavaScriptView Raw
1import baseIteratee from './_baseIteratee';
2import basePickBy from './_basePickBy';
3
4/**
5 * Creates an object composed of the `object` properties `predicate` returns
6 * truthy for. The predicate is invoked with two arguments: (value, key).
7 *
8 * @static
9 * @memberOf _
10 * @since 4.0.0
11 * @category Object
12 * @param {Object} object The source object.
13 * @param {Array|Function|Object|string} [predicate=_.identity]
14 * The function invoked per property.
15 * @returns {Object} Returns the new object.
16 * @example
17 *
18 * var object = { 'a': 1, 'b': '2', 'c': 3 };
19 *
20 * _.pickBy(object, _.isNumber);
21 * // => { 'a': 1, 'c': 3 }
22 */
23function pickBy(object, predicate) {
24 return object == null ? {} : basePickBy(object, baseIteratee(predicate));
25}
26
27export default pickBy;