1 var baseUniq = require('./_baseUniq');
4 * This method is like `_.uniq` except that it accepts `comparator` which
5 * is invoked to compare elements of `array`. The order of result values is
6 * determined by the order they occur in the array.The comparator is invoked
7 * with two arguments: (arrVal, othVal).
13 * @param {Array} array The array to inspect.
14 * @param {Function} [comparator] The comparator invoked per element.
15 * @returns {Array} Returns the new duplicate free array.
18 * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 2 }];
20 * _.uniqWith(objects, _.isEqual);
21 * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]
23 function uniqWith(array, comparator) {
24 comparator = typeof comparator == 'function' ? comparator : undefined;
25 return (array && array.length) ? baseUniq(array, undefined, comparator) : [];
28 module.exports = uniqWith;