⚠ Deprecated: use Lodash _.uniq, _.uniqBy or _.uniqWith instead.
De-duplicate arrays of arbitrary objects with a equality function.
npm install --save dedupe-compare
With standart comparator function
const dedupe = require("dedupe-compare");
const array = [1, 1, 2, 2, 3, 1, 5];
const result = dedupe(array);
// [1, 2, 3, 5];
With a custom comparator function.
const dedupe = require("dedupe-compare");
const array = [{ a: "x", b: "y" }, { a: "x", b: "y" }, { a: "b", b: "y" }];
const equal = (x, y) => x.a === y.a;
const result = dedupe(array, equal);
// [{ a: "x", b: "y" }, { a: "b", b: "y" }]