@extra-map/union-update.min

Gives entries present in any map. :package: :smiley_cat: :running: :vhs: :moon: :scroll: :newspaper: :blue_book:

Usage no npm install needed!

<script type="module">
  import extraMapUnionUpdateMin from 'https://cdn.skypack.dev/@extra-map/union-update.min';
</script>

README

Gives entries present in any map. :package: :smiley_cat: :running: :vhs: :moon: :scroll: :newspaper: :blue_book:

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

This is part of package extra-map.

This is browserified, minified version of @extra-map/union-update.
It is exported as global variable map_union$.
CDN: unpkg, jsDelivr.


map.union$(x, y, [fc]);
// x:  a map (updated)
// y:  another map
// fc: combine function (a, b)
// → x
const map = require("extra-map");

var x = new Map([["a", 1], ["b", 2], ["c", 3]]);
var y = new Map([["b", 20], ["c", 30], ["d", 40]]);
map.union$(x, y);
// Map(4) { "a" => 1, "b" => 2, "c" => 3, "d" => 40 }

x;
// Map(4) { "a" => 1, "b" => 2, "c" => 3, "d" => 40 }

var x = new Map([["a", 1], ["b", 2], ["c", 3]]);
map.union$(x, y, (a, b) => b);
// Map(4) { "a" => 1, "b" => 20, "c" => 30, "d" => 40 }


References