object/pickBy.js

  1. import { lodashFpConvertOptions } from '../consts'
  2. import pickBy from 'lodash/fp/pickBy'
  3. import update from '../object/update'
  4. const rawPickBy = pickBy.convert(lodashFpConvertOptions)
  5. /**
  6. * Creates an object composed of the object properties predicate returns truthy
  7. * for. The predicate is invoked with two arguments: (value, key).
  8. * @function pickBy
  9. * @memberof object
  10. * @param {Object} object The object to modify.
  11. * @param {Array|string} path The path of the property to set.
  12. * @param {function} [predicate={@link https://lodash.com/docs#identity|lodash.identity}] The function invoked per iteration.
  13. * @return {Object} Returns the updated object.
  14. * @example pickBy({ nested: { a: 1, b: 2, c: 3, d: 4 } }, 'nested', v => v < 3) // => { nested: { a: 1, b: 2 } }
  15. * @see {@link object.update|update} for more information.
  16. * @see {@link https://lodash.com/docs#pickBy|lodash.pickBy} for more information.
  17. * @see {@link https://lodash.com/docs#identity|lodash.identity} for more information.
  18. * @since 0.1.12
  19. */
  20. export default update(rawPickBy)