union - nodef/extra-map GitHub Wiki

Obtain entries present in any map.

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

function union(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](/nodef/extra-map/wiki/'a',-1],-['b',-2],-['c',-3));
var y = new Map(['b', 20], ['c', 30], ['d', 40](/nodef/extra-map/wiki/'b',-20],-['c',-30],-['d',-40));
map.union(x, y);
// → Map(4) { 'a' => 1, 'b' => 2, 'c' => 3, 'd' => 40 }

map.union(x, y, (a, b) => b);
// → Map(4) { 'a' => 1, 'b' => 20, 'c' => 30, 'd' => 40 }

References