UNPKG

378 BJavaScriptView Raw
1import { _isArray } from './_internals/_isArray'
2import { equals } from './equals'
3
4export function dropRepeats(list){
5 if (!_isArray(list)){
6 throw new Error(`${ list } is not a list`)
7 }
8
9 const toReturn = []
10
11 list.reduce((prev, current) => {
12 if (!equals(prev, current)){
13 toReturn.push(current)
14 }
15
16 return current
17 }, undefined)
18
19 return toReturn
20}