array/intersectionWith.js

  1. import { intersectionWith as _intersectionWith } from 'lodash'
  2. import { apply } from 'immutadot/core'
  3. /**
  4. * This method is like {@link array.intersection} except that it uses <code>comparator</code> to compare elements of the former array to <code>arrays</code>.
  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} [comparator] The comparator invoked per element.
  11. * @return {Object} Returns the updated object.
  12. * @example intersectionWith({ nested: { prop: [{ x: 1 }, { x: 2 }] } }, 'nested.prop', [{ x: 2 }, { x: 3 }], (a, b) => a.x === b.x) // => { nested: { prop: [{ x: 2 }] } }
  13. * @see {@link https://lodash.com/docs#intersectionWith|lodash.intersectionWith} for more information.
  14. * @since 1.0.0
  15. */
  16. const intersectionWith = apply(_intersectionWith, { arity: 2 })
  17. export { intersectionWith }