1 var baseIteratee = require('./_baseIteratee'),
2 baseUniq = require('./_baseUniq');
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 order of result values is determined by the
8 * order they occur in the array. The iteratee is invoked with one argument:
15 * @param {Array} array The array to inspect.
16 * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
17 * @returns {Array} Returns the new duplicate free array.
20 * _.uniqBy([2.1, 1.2, 2.3], Math.floor);
23 * // The `_.property` iteratee shorthand.
24 * _.uniqBy([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x');
25 * // => [{ 'x': 1 }, { 'x': 2 }]
27 function uniqBy(array, iteratee) {
28 return (array && array.length) ? baseUniq(array, baseIteratee(iteratee, 2)) : [];
31 module.exports = uniqBy;