SIGN IN SIGN UP

A modern JavaScript utility library delivering modularity, performance, & extras.

0 0 2043 JavaScript
2016-04-19 22:17:16 -07:00
define(['./eq'], function(eq) {
2015-12-16 17:53:20 -08:00
/**
2016-04-19 22:17:16 -07:00
* The base implementation of `_.sortedUniq` and `_.sortedUniqBy` without
* support for iteratee shorthands.
2015-12-16 17:53:20 -08:00
*
* @private
* @param {Array} array The array to inspect.
2016-04-19 22:17:16 -07:00
* @param {Function} [iteratee] The iteratee invoked per element.
2015-12-16 17:53:20 -08:00
* @returns {Array} Returns the new duplicate free array.
*/
2016-04-19 22:17:16 -07:00
function baseSortedUniq(array, iteratee) {
var index = -1,
length = array.length,
resIndex = 0,
result = [];
while (++index < length) {
var value = array[index],
computed = iteratee ? iteratee(value) : value;
if (!index || !eq(computed, seen)) {
var seen = computed;
result[resIndex++] = value === 0 ? 0 : value;
}
}
return result;
2015-12-16 17:53:20 -08:00
}
return baseSortedUniq;
});