array/intersectionBy.js

  1. import { intersectionBy as _intersectionBy } from 'lodash'
  2. import { apply } from 'immutadot/core'
  3. /**
  4. * This method is like {@link array.intersection} except that it uses <code>iteratee</code> to generate the value to be compared for each element.
  5. * @function
  6. * @memberof array
  7. * @param {Object} object The object to modify.
  8. * @param {Array|string} path The path of the property to set.
  9. * @param {...Array} [arrays] The arrays to inspect.
  10. * @param {Function} [iteratee={@link https://lodash.com/docs#identity|lodash.identity}] The iteratee invoked per element.
  11. * @return {Object} Returns the updated object.
  12. * @example intersectionBy({ nested: { prop: [1.2, 2.1] } }, 'nested.prop', [2.3, 3.2], Math.floor) // => { nested: { prop: [2.1] } }
  13. * @see {@link https://lodash.com/docs#intersectionBy|lodash.intersectionBy} for more information.
  14. * @since 1.0.0
  15. */
  16. const intersectionBy = apply(_intersectionBy, { arity: 2 })
  17. export { intersectionBy }