Skip to content

filterWithKey

filterWithKey<K, A>(predicate): (m) => ReadonlyMap<K, A>

Defined in: Utils/Dict.ts:296

Returns a new dictionary containing only the entries for which the predicate returns true. The predicate also receives the key.

K

A

(key, a) => boolean

(m): ReadonlyMap<K, A>

ReadonlyMap<K, A>

ReadonlyMap<K, A>

pipe(Dict.fromEntries([["a", 1], ["b", 2]]), Dict.filterWithKey((k, v) => k !== "a" && v > 0));
// ReadonlyMap { "b" => 2 }