source: trip-planner-front/node_modules/lodash/pickBy.js@ eed0bf8

Last change on this file since eed0bf8 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.0 KB
RevLine 
[6a3a178]1var arrayMap = require('./_arrayMap'),
2 baseIteratee = require('./_baseIteratee'),
3 basePickBy = require('./_basePickBy'),
4 getAllKeysIn = require('./_getAllKeysIn');
5
6/**
7 * Creates an object composed of the `object` properties `predicate` returns
8 * truthy for. The predicate is invoked with two arguments: (value, key).
9 *
10 * @static
11 * @memberOf _
12 * @since 4.0.0
13 * @category Object
14 * @param {Object} object The source object.
15 * @param {Function} [predicate=_.identity] The function invoked per property.
16 * @returns {Object} Returns the new object.
17 * @example
18 *
19 * var object = { 'a': 1, 'b': '2', 'c': 3 };
20 *
21 * _.pickBy(object, _.isNumber);
22 * // => { 'a': 1, 'c': 3 }
23 */
24function pickBy(object, predicate) {
25 if (object == null) {
26 return {};
27 }
28 var props = arrayMap(getAllKeysIn(object), function(prop) {
29 return [prop];
30 });
31 predicate = baseIteratee(predicate);
32 return basePickBy(object, props, function(value, path) {
33 return predicate(value, path[0]);
34 });
35}
36
37module.exports = pickBy;
Note: See TracBrowser for help on using the repository browser.