intersection - nodef/extra-map GitHub Wiki

Obtain entries present in both maps.

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

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

var x = new Map(['a', 1], ['b', 2], ['c', 3], ['d', 4](/nodef/extra-map/wiki/'a',-1],-['b',-2],-['c',-3],-['d',-4));
var y = new Map(['b', 20], ['c', 30], ['e', 50](/nodef/extra-map/wiki/'b',-20],-['c',-30],-['e',-50));
map.intersection(x, y);
// → Map(2) { 'b' => 2, 'c' => 3 }

map.intersection(x, y, (a, b) => b);
// → Map(2) { 'b' => 20, 'c' => 30 }

References