Skip to content

filter

filter(map, predicate)

Filters map by keeping only the entries where predicate returns true for the value.

ts
filter(
    new Map([
        ["a", 1],
        ["b", 2],
        ["c", 3],
    ]),
    (value) => value > 1,
); // Map(2) { "b" => 2, "c" => 3 }
ts
pipe(
    new Map([
        ["a", 1],
        ["b", 2],
        ["c", 3],
    ]),
    filter((value) => value > 1),
); // Map(2) { "b" => 2, "c" => 3 }