So I want to use the optimized algorithm but, according to the code of the function this is not the case:
function uniq(array, isSorted, iteratee, context) {
// [...]
if (isSorted && !iteratee) { // Why the condition "&& !iteratee" ? Juste "if(isSorted)" is fine no ?
if (!i || seen !== computed) result.push(value);
seen = computed;
} else if (iteratee) {
// So we go here and isn't the optimized algorithm :/
if (!contains(seen, computed)) {
seen.push(computed);
result.push(value);
}
} else if (!contains(result, value)) {
result.push(value);
}
I have an array of objects that I want to make unique based on a property of the object, and I know the array is already sorted by that property.
So I want to use the optimized algorithm but, according to the code of the function this is not the case: