1 var baseUniq = require('./internal/baseUniq');
4 * This method is like `_.uniq` except that it accepts `comparator` which
5 * is invoked to compare elements of `array`. The comparator is invoked with
6 * two arguments: (arrVal, othVal).
11 * @param {Array} array The array to inspect.
12 * @param {Function} [comparator] The comparator invoked per element.
13 * @returns {Array} Returns the new duplicate free array.
16 * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 2 }];
18 * _.uniqWith(objects, _.isEqual);
19 * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]
21 function uniqWith(array, comparator) {
22 return (array && array.length)
23 ? baseUniq(array, undefined, comparator)
27 module.exports = uniqWith;