Package: effect
Module: Array
Computes elements in the first array that are not in the second, using a custom equivalence.
When to use
Use when you need to keep only values from the first array and equality must be defined by a custom comparator, such as matching objects by id.
Example (Computing differences with custom equality)
import { Array } from "effect"
const diff = Array.differenceWith<number>((a, b) => a === b)([1, 2, 3], [2, 3, 4])
console.log(diff) // [1]
See
difference for the Equal.equivalence() variantunionWith for keeping values from either array with custom equalityintersectionWith for keeping values present in both arrays with custom equalitySignature
declare const differenceWith: <A>(isEquivalent: (self: A, that: A) => boolean) => { (that: Iterable<A>): (self: Iterable<A>) => Array<A>; (self: Iterable<A>, that: Iterable<A>): Array<A>; }
Since v2.0.0