| 1 |
var eq = require('./eq'); |
| 2 |
|
| 3 |
/** |
| 4 |
* The base implementation of `_.sortedUniq` and `_.sortedUniqBy` without |
| 5 |
* support for iteratee shorthands. |
| 6 |
* |
| 7 |
* @private |
| 8 |
* @param {Array} array The array to inspect. |
| 9 |
* @param {Function} [iteratee] The iteratee invoked per element. |
| 10 |
* @returns {Array} Returns the new duplicate free array. |
| 11 |
*/ |
| 12 |
function baseSortedUniq(array, iteratee) { |
| 13 |
var index = -1, |
| 14 |
length = array.length, |
| 15 |
resIndex = 0, |
| 16 |
result = []; |
| 17 |
|
| 18 |
while (++index < length) { |
| 19 |
var value = array[index], |
| 20 |
computed = iteratee ? iteratee(value) : value; |
| 21 |
|
| 22 |
if (!index || !eq(computed, seen)) { |
| 23 |
var seen = computed; |
| 24 |
result[resIndex++] = value === 0 ? 0 : value; |
| 25 |
} |
| 26 |
} |
| 27 |
return result; |
| 28 |
} |
| 29 |
|
| 30 |
module.exports = baseSortedUniq; |