-
Notifications
You must be signed in to change notification settings - Fork 1
isUnique
Subhajit Sahu edited this page May 17, 2020
·
23 revisions
Checks if there are no duplicate values. 🏃 📼 📦 🌔 📒
iterable.isUnique(x, [fc], [fm]);
// x: an iterable
// fc: compare function (a, b)
// fm: map function (v, i, x)
⏱️ Compare function => O(n²).
const iterable = require('extra-iterable');
var x = [1, 2, -1, -2];
iterable.isUnique(x);
// true
iterable.isUnique(x, (a, b) => Math.abs(a) - Math.abs(b));
// false
iterable.isUnique(x, null, v => Math.abs(v));
// false