Package: effect
Module: Array
Removes duplicates using a custom equivalence, preserving the order of the first occurrence.
When to use
Use to remove all duplicate elements with a custom equivalence when default equality is not appropriate.
Example (Deduplicating with custom equality)
import { Array } from "effect"
console.log(Array.dedupeWith([1, 2, 2, 3, 3, 3], (a, b) => a === b)) // [1, 2, 3]
See
dedupe — uses default equalitydedupeAdjacentWith — only dedupes consecutive elementsSignature
declare const dedupeWith: { <S extends Iterable<any>>(isEquivalent: (self: ReadonlyArray.Infer<S>, that: ReadonlyArray.Infer<S>) => boolean): (self: S) => ReadonlyArray.With<S, ReadonlyArray.Infer<S>>; <A>(self: NonEmptyReadonlyArray<A>, isEquivalent: (self: A, that: A) => boolean): NonEmptyArray<A>; <A>(self: Iterable<A>, isEquivalent: (self: A, that: A) => boolean): Array<A>; }
Since v2.0.0