array/differenceWith.js

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