@extra-array/is-unique
v2.10.19
Published
Checks if there are no duplicate values.
Downloads
286
Maintainers
Readme
Checks if there are no duplicate values. :package: :smiley_cat: :running: :vhs: :moon: :scroll: :newspaper: :blue_book:
Similar: isUnique, isDisjoint, intersection.
This is part of package extra-array.
array.isUnique(x, [fc], [fm]);
// x: an array
// fc: compare function (a, b)
// fm: map function (v, i, x)
:stopwatch: Compare function => O(n²).
const array = require("extra-array");
var x = [1, 2, -1, -2];
array.isUnique(x);
// true
array.isUnique(x, (a, b) => Math.abs(a) - Math.abs(b));
// false
array.isUnique(x, null, v => Math.abs(v));
// false