Version 1
[yaffs-website] / node_modules / uncss / node_modules / lodash / uniqBy.js
1 var baseIteratee = require('./internal/baseIteratee'),
2     baseUniq = require('./internal/baseUniq');
3
4 /**
5  * This method is like `_.uniq` except that it accepts `iteratee` which is
6  * invoked for each element in `array` to generate the criterion by which
7  * uniqueness is computed. The iteratee is invoked with one argument: (value).
8  *
9  * @static
10  * @memberOf _
11  * @category Array
12  * @param {Array} array The array to inspect.
13  * @param {Function|Object|string} [iteratee=_.identity] The iteratee invoked per element.
14  * @returns {Array} Returns the new duplicate free array.
15  * @example
16  *
17  * _.uniqBy([2.1, 1.2, 2.3], Math.floor);
18  * // => [2.1, 1.2]
19  *
20  * // using the `_.property` iteratee shorthand
21  * _.uniqBy([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x');
22  * // => [{ 'x': 1 }, { 'x': 2 }]
23  */
24 function uniqBy(array, iteratee) {
25   return (array && array.length)
26     ? baseUniq(array, baseIteratee(iteratee))
27     : [];
28 }
29
30 module.exports = uniqBy;