union - nodef/extra-entries GitHub Wiki

Obtain entries present in any entries.

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

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

var x = ["a", 1], ["b", 2], ["c", 3](/nodef/extra-entries/wiki/"a",-1],-["b",-2],-["c",-3);
var y = ["b", 20], ["c", 30], ["d", 40](/nodef/extra-entries/wiki/"b",-20],-["c",-30],-["d",-40);
[...entries.union(x, y)];
// → [ [ "a", 1 ], [ "b", 2 ], [ "c", 3 ], [ "d", 40 ] ]

[...entries.union(x, y, (a, b) => b)];
// → [ [ "a", 1 ], [ "b", 20 ], [ "c", 30 ], [ "d", 40 ] ]

References