Hyperlinkv0.8.0-beta.28

Array

Array.dedupeconsteffect/Array.ts:4439
<S extends Iterable<any>>(self: S): S extends NonEmptyReadonlyArray<
  infer A
>
  ? NonEmptyArray<A>
  : S extends Iterable<infer A>
  ? Array<A>
  : never

Removes duplicates using Equal.equivalence(), preserving the order of the first occurrence.

When to use

Use to remove repeated values from an iterable when Effect's default equality is the right comparison, preserving the first occurrence.

Example (Removing duplicates)

import { Array } from "effect"

console.log(Array.dedupe([1, 2, 1, 3, 2, 4])) // [1, 2, 3, 4]
Source effect/Array.ts:44394 lines
export const dedupe = <S extends Iterable<any>>(
  self: S
): S extends NonEmptyReadonlyArray<infer A> ? NonEmptyArray<A> : S extends Iterable<infer A> ? Array<A> : never =>
  dedupeWith(self, Equal.asEquivalence()) as any
Referenced by 1 symbols