union - nodef/extra-lists GitHub Wiki

Obtain entries present in any lists.

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

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

var x = ['a', 'b', 'c'], [1, 2, 3](/nodef/extra-lists/wiki/'a',-'b',-'c'],-[1,-2,-3);
var y = ['b', 'c', 'd'], [20, 30, 40](/nodef/extra-lists/wiki/'b',-'c',-'d'],-[20,-30,-40);
xlists.union(x, y).map(v => [...v]);
// → [ [ 'a', 'b', 'c', 'd' ], [ 1, 2, 3, 40 ] ]

xlists.union(x, y, (a, b) => b).map(v => [...v]);
// → [ [ 'a', 'b', 'c', 'd' ], [ 1, 20, 30, 40 ] ]

References