uniq
ArrayRemoves consecutive duplicate values from an array. Like the Unix uniq command: only adjacent duplicates are removed. Sort the array first if you need all duplicates removed regardless of position.
Syntax
uniqUse cases
| Use case | Description | URL | |
|---|---|---|---|
| Remove adjacent duplicates | Strip consecutive repeated values from a pre-sorted list. | https://httpip.es/api/pipe/echo:[1,1,2,2,2,3,3,4]|uniq | |
| Collapse repeated statuses | Reduce a run-length-encoded status log to a sequence of distinct states. | https://httpip.es/api/pipe/echo:[{"s":"ok"},{"s":"ok"},{"s":"err"},{"s":"ok"}]|pluck:s|uniq | |
| Dedupe sorted plucked field | Sort a field, then uniq to get sorted unique values efficiently. | https://httpip.es/api/pipe/fetch:https://jsonplaceholder.typicode.com/todos|pluck:userId|sort|uniq |