-
Notifications
You must be signed in to change notification settings - Fork 1
removePath$
Subhajit Sahu edited this page Feb 3, 2021
·
10 revisions
Deletes value at path in a nested map. 🏃 📼 📦 🌔 📒
Alternatives: remove, remove$, removePath$.
Similar: hasPath, getPath, setPath$, removePath$.
Similar: get, set, remove.
map.removePath$(x, p);
// x: a nested map (updated)
// p: path
// --> x
const map = require("extra-map");
var x = new Map([["a", 2], ["b", 4], ["c", 6]]);
var y = new Map([["x", x], ["e", 10], ["f", 12]]);
map.removePath$(y, ["e"]);
// Map(2) { "x" => Map(3) { "a" => 2, "b" => 4, "c" => 6 }, "f" => 12 }
y;
// Map(2) { "x" => Map(3) { "a" => 2, "b" => 4, "c" => 6 }, "f" => 12 }
map.removePath$(y, ["x", "b"]);
// Map(2) { "x" => Map(2) { "a" => 2, "c" => 6 }, "f" => 12 }
map.removePath$(y, ["x", "b", "c"]);
// Map(2) { "x" => Map(2) { "a" => 2, "c" => 6 }, "f" => 12 } (no effect)