( self: S )
| 4497 | * @since 2.0.0 |
| 4498 | */ |
| 4499 | export const dedupe = <S extends Iterable<any>>( |
| 4500 | self: S |
| 4501 | ): S extends NonEmptyReadonlyArray<infer A> ? NonEmptyArray<A> : S extends Iterable<infer A> ? Array<A> : never => { |
| 4502 | const input = fromIterable(self) |
| 4503 | if (input.length < 2) { |
| 4504 | return [...input] as any |
| 4505 | } |
| 4506 | const buckets: HashBuckets = new Map() |
| 4507 | const out: Array<unknown> = [] |
| 4508 | for (const value of input) { |
| 4509 | if (hashBucketsAdd(buckets, value)) { |
| 4510 | out.push(value) |
| 4511 | } |
| 4512 | } |
| 4513 | return out as any |
| 4514 | } |
| 4515 | |
| 4516 | /** |
| 4517 | * Removes consecutive duplicate elements using a custom equivalence. |
no test coverage detected