collection/filter.js

  1. import _filter from 'lodash/filter'
  2. import { convert } from 'util/convert'
  3. /**
  4. * Replaces by an array of elements <code>predicate</code> returns truthy for.
  5. * @function
  6. * @memberof collection
  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. * @see {@link https://lodash.com/docs#filter|lodash.filter} for more information.
  12. * @example filter({ nested: { prop: [1, 2, 3, 4] } }, 'nested.prop', v => v % 2) // => { nested: { prop: [1, 3] } }
  13. * @since 0.3.0
  14. */
  15. const filter = convert(_filter)
  16. export { filter, filter as default }