Skip to content

intersection

Subhajit Sahu edited this page Dec 22, 2022 · 15 revisions

Obtain ientries present in both ientries.

Similar: union, intersection, difference, symmetricDifference, isDisjoint.


function intersection(x, y, fc)
// x:  ientries
// y:  another ientries
// fc: combine function (a, b)
const ientries = require('extra-ientries');

var x = [["a", 1], ["b", 2], ["c", 3], ["d", 4]];
var y = [["b", 20], ["c", 30], ["e", 50]];
[...ientries.intersection(x, y)];
// → [ [ "b", 2 ], [ "c", 3 ] ]

[...ientries.intersection(x, y, (a, b) => b)];
// → [ [ "b", 20 ], [ "c", 30 ] ]


References

Clone this wiki locally