| 1 |
var baseIteratee = require('./_baseIteratee'), |
| 2 |
baseSortedUniq = require('./_baseSortedUniq'); |
| 3 |
|
| 4 |
/** |
| 5 |
* This method is like `_.uniqBy` except that it's designed and optimized |
| 6 |
* for sorted arrays. |
| 7 |
* |
| 8 |
* @static |
| 9 |
* @memberOf _ |
| 10 |
* @since 4.0.0 |
| 11 |
* @category Array |
| 12 |
* @param {Array} array The array to inspect. |
| 13 |
* @param {Function} [iteratee] The iteratee invoked per element. |
| 14 |
* @returns {Array} Returns the new duplicate free array. |
| 15 |
* @example |
| 16 |
* |
| 17 |
* _.sortedUniqBy([1.1, 1.2, 2.3, 2.4], Math.floor); |
| 18 |
* // => [1.1, 2.3] |
| 19 |
*/ |
| 20 |
function sortedUniqBy(array, iteratee) { |
| 21 |
return (array && array.length) |
| 22 |
? baseSortedUniq(array, baseIteratee(iteratee, 2)) |
| 23 |
: []; |
| 24 |
} |
| 25 |
|
| 26 |
module.exports = sortedUniqBy; |