@extra-map/swap.min

Exchanges two values.

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
@extra-map/swap.min
322.2.152 years ago3 years agoMinified + gzip package size for @extra-map/swap.min in KB

Readme

Exchanges two values. :package: :smileycat: :running: :vhs: :moon: :scroll: :newspaper: :bluebook:
Alternatives: swap, swap$.

This is part of package extra-map.

This is browserified, minified version of @extra-map/swap.
It is exported as global variable mapswap.
CDN: unpkg
, jsDelivr.



map.swap(x, k, l);
// x: a map
// k: a key
// l: another key

const map = require("extra-map");

var x = new Map([["a", 1], ["b", 2], ["c", 3], ["d", 4]]);
map.swap(x, "a", "b");
// Map(4) { "a" => 2, "b" => 1, "c" => 3, "d" => 4 }

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



References