object/pick.js

  1. import _pick from 'lodash/pick'
  2. import { convert } from 'util/convert'
  3. /**
  4. * Replaces by an object picking specified properties.
  5. * @function
  6. * @memberof object
  7. * @param {Object} object The object to modify.
  8. * @param {Array|string} path The path of the property to set.
  9. * @param {...(string|string[])} [paths] The property paths to pick.
  10. * @return {Object} Returns the updated object.
  11. * @example pick({ nested: { a: 1, b: 2, c: 3 } }, 'nested', 'b') // => { nested: { b: 2 } }
  12. * @see {@link https://lodash.com/docs#pick|lodash.pick} for more information.
  13. * @since 0.3.0
  14. */
  15. const pick = convert(_pick)
  16. export { pick, pick as default }