Version 1
[yaffs-website] / node_modules / uncss / node_modules / lodash / uniqWith.js
1 var baseUniq = require('./internal/baseUniq');
2
3 /**
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).
7  *
8  * @static
9  * @memberOf _
10  * @category Array
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.
14  * @example
15  *
16  * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 },  { 'x': 1, 'y': 2 }];
17  *
18  * _.uniqWith(objects, _.isEqual);
19  * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]
20  */
21 function uniqWith(array, comparator) {
22   return (array && array.length)
23     ? baseUniq(array, undefined, comparator)
24     : [];
25 }
26
27 module.exports = uniqWith;