-
Notifications
You must be signed in to change notification settings - Fork 1
unique
wolfram77 edited this page Mar 27, 2020
·
28 revisions
Removes duplicate elements.
iterable.unique(x, [fn]);
// x: an iterable
// fn: compare function (a, b)
// --> unique values
const iterable = require('extra-iterable');
var x = [1, 2, 3, 4, 2, 3];
iterable.unique(x);
// [1, 2, 3, 4]
var x = [1, 2, 3, 4, -2, -3];
iterable.unique(x, (a, b) => Math.abs(a) - Math.abs(b));
// [1, 2, 3, 4]