CoolFace
Datasetpublic

basant307/AI_Governance_Project

sourceHugging Faceapache-2.0updated 2mo agoView on Hugging Face
0likes45downloads
pickBy.js38 linesDownload Raw Back to lodash
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` returns8 * truthy for. The predicate is invoked with two arguments: (value, key).9 *10 * @static11 * @memberOf _12 * @since 4.0.013 * @category Object14 * @param {Object} object The source object.15 * @param {Function} [predicate=_.identity] The function invoked per property.16 * @returns {Object} Returns the new object.17 * @example18 *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;38 
basant307/AI_Governance_Project · CoolFace