( self: S )
| 4687 | * @since 2.0.0 |
| 4688 | */ |
| 4689 | export const dedupe = <S extends Iterable<any>>( |
| 4690 | self: S |
| 4691 | ): S extends NonEmptyReadonlyArray<infer A> ? NonEmptyArray<A> : S extends Iterable<infer A> ? Array<A> : never => { |
| 4692 | const input = fromIterable(self) |
| 4693 | if (input.length < 2) { |
| 4694 | return [...input] as any |
| 4695 | } |
| 4696 | const buckets: HashBuckets = new Map() |
| 4697 | const out: Array<unknown> = [] |
| 4698 | for (const value of input) { |
| 4699 | if (hashBucketsAdd(buckets, value)) { |
| 4700 | out.push(value) |
| 4701 | } |
| 4702 | } |
| 4703 | return out as any |
| 4704 | } |
| 4705 | |
| 4706 | /** |
| 4707 | * Removes consecutive duplicate elements using a custom equivalence. |
no test coverage detected