object/pickBy.js

  1. import { pickBy as _pickBy } from 'lodash'
  2. import { convert } from 'immutadot'
  3. /**
  4. * Replaces by an object picking properties that <code>predicate</code> returns truthy for.
  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 {function} [predicate={@link https://lodash.com/docs#identity|lodash.identity}] The function invoked per iteration.
  10. * @return {Object} Returns the updated object.
  11. * @example pickBy({ nested: { a: 1, b: 2, c: 3, d: 4 } }, 'nested', v => v < 3) // => { nested: { a: 1, b: 2 } }
  12. * @see {@link https://lodash.com/docs#pickBy|lodash.pickBy} for more information.
  13. * @since 1.0.0
  14. */
  15. const pickBy = convert(_pickBy)
  16. export { pickBy }