dropRepeats
Removes consecutively repeated elements from an array using strict
equality (===).
Only adjacent duplicates are removed — non-adjacent duplicates are kept.
Use uniq to remove all duplicates regardless of position.
Quirks (inherent to ===):
NaN !== NaN, so adjacentNaNs are not collapsed.-0 === 0, so adjacent-0and0are collapsed.- Object/array elements compare by reference, not structure.
Usage
dropRepeats<T>(array: readonly T[])
Removes consecutively repeated elements from an array using strict
equality (===).
Only adjacent duplicates are removed — non-adjacent duplicates are kept.
Use uniq to remove all duplicates regardless of position.
Quirks (inherent to ===):
NaN !== NaN, so adjacentNaNs are not collapsed.-0 === 0, so adjacent-0and0are collapsed.- Object/array elements compare by reference, not structure.
Parameters
arrayreadonly T[]required
the source array.
Returns
a new array with consecutive duplicate elements removed.