get
ts
function Map.get<K, V>(
target: ReadonlyMap<K, V>,
key: NoInfer<K>,
): V | undefinedGets the value associated with the specified key, or undefined if the key doesn't exist.
Example
ts
import { Map } from "@monstermann/map";
Map.get(
new Map([
["a", 1],
["b", 2],
]),
"a",
); // 1
Map.get(
new Map([
["a", 1],
["b", 2],
]),
"c",
); // undefinedts
import { Map } from "@monstermann/map";
pipe(
new Map([
["a", 1],
["b", 2],
]),
Map.get("a"),
); // 1
pipe(
new Map([
["a", 1],
["b", 2],
]),
Map.get("c"),
); // undefined