-
Notifications
You must be signed in to change notification settings - Fork 1
intersection
Subhajit Sahu edited this page May 11, 2020
·
26 revisions
Gives values present in both iterables. 🏃 📼 📦 🌔 📒
iterable.intersection(x, y, [fn]);
// x: an iterable
// y: another iterable
// fn: compare function (a, b)
const iterable = require('extra-iterable');
var x = [1, 2, 3, 4];
[...iterable.intersection(x, [2, 3, 5])];
// [ 2, 3 ]
[...iterable.intersection(x, [-2, -3, -5], (a, b) => Math.abs(a) - Math.abs(b))];
// [ 2, 3 ]