mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-29 06:27:49 +00:00
35 lines
863 B
JavaScript
35 lines
863 B
JavaScript
define(['./eq'], function(eq) {
|
|
|
|
/**
|
|
* The base implementation of `_.sortedUniqBy` without support for iteratee
|
|
* shorthands.
|
|
*
|
|
* @private
|
|
* @param {Array} array The array to inspect.
|
|
* @param {Function} [iteratee] The iteratee invoked per element.
|
|
* @returns {Array} Returns the new duplicate free array.
|
|
*/
|
|
function baseSortedUniqBy(array, iteratee) {
|
|
var index = 0,
|
|
length = array.length,
|
|
value = array[0],
|
|
computed = iteratee ? iteratee(value) : value,
|
|
seen = computed,
|
|
resIndex = 1,
|
|
result = [value];
|
|
|
|
while (++index < length) {
|
|
value = array[index],
|
|
computed = iteratee ? iteratee(value) : value;
|
|
|
|
if (!eq(computed, seen)) {
|
|
seen = computed;
|
|
result[resIndex++] = value;
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
|
|
return baseSortedUniqBy;
|
|
});
|