2.2.15 • Published 4 years ago

@extra-map/set-path-update v2.2.15

Weekly downloads
19
License
MIT
Repository
github
Last release
4 years ago

Sets value at path in a nested map. :package: :smiley_cat: :running: :vhs: :moon: :scroll: :newspaper: :blue_book:

Alternatives: set, set$, setPath$. Similar: hasPath, getPath, setPath$, removePath$. Similar: get, set, remove.

This is part of package extra-map.

map.setPath$(x, p, v);
// x: a nested map (updated)
// p: path
// v: value
// → 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.setPath$(y, ["e"], 100);
// Map(3) {
//   "x" => Map(3) { "a" => 2, "b" => 4, "c" => 6 },
//   "e" => 100,
//   "f" => 12
// }

y;
// Map(3) {
//   "x" => Map(3) { "a" => 2, "b" => 4, "c" => 6 },
//   "e" => 100,
//   "f" => 12
// }

map.setPath$(y, ["x", "b"], 40);
// Map(3) {
//   "x" => Map(3) { "a" => 2, "b" => 40, "c" => 6 },
//   "e" => 100,
//   "f" => 12
// }

map.setPath$(y, ["x", "b", "c"], 60);
// Map(3) {  (no effect)
//   "x" => Map(3) { "a" => 2, "b" => 40, "c" => 6 },
//   "e" => 100,
//   "f" => 12
// }

References

2.2.15

4 years ago

2.2.13

4 years ago

2.2.14

4 years ago

2.2.11

4 years ago

2.2.12

4 years ago

2.2.10

4 years ago

2.2.8

5 years ago

2.2.7

5 years ago

2.2.6

5 years ago

2.2.4

5 years ago

2.2.5

5 years ago

2.2.3

5 years ago

2.2.2

5 years ago

2.2.1

5 years ago

2.2.0

5 years ago

2.1.43

5 years ago

2.1.42

5 years ago

2.1.41

5 years ago

2.1.40

5 years ago