_basePick.js 552 B

12345678910111213141516171819202122
  1. var arrayReduce = require('./_arrayReduce');
  2. /**
  3. * The base implementation of `_.pick` without support for individual
  4. * property identifiers.
  5. *
  6. * @private
  7. * @param {Object} object The source object.
  8. * @param {string[]} props The property identifiers to pick.
  9. * @returns {Object} Returns the new object.
  10. */
  11. function basePick(object, props) {
  12. object = Object(object);
  13. return arrayReduce(props, function(result, key) {
  14. if (key in object) {
  15. result[key] = object[key];
  16. }
  17. return result;
  18. }, {});
  19. }
  20. module.exports = basePick;