Hyperlinkv0.8.0-beta.28

HashMap

HashMap.filterconsteffect/HashMap.ts:1113
<K, A>(f: (a: NoInfer<A>, k: K) => boolean): (
  self: HashMap<K, A>
) => HashMap<K, A>
<K, A>(self: HashMap<K, A>, f: (a: A, k: K) => boolean): HashMap<K, A>

Filters entries out of a HashMap using the specified predicate.

Example (Filtering entries)

import { HashMap } from "effect"

const map1 = HashMap.make(["a", 1], ["b", 2], ["c", 3], ["d", 4])
const map2 = HashMap.filter(map1, (value) => value % 2 === 0)

console.log(HashMap.size(map2)) // 2
console.log(HashMap.has(map2, "b")) // true
console.log(HashMap.has(map2, "d")) // true
console.log(HashMap.has(map2, "a")) // false
filtering
export const filter: {
  <K, A>(f: (a: NoInfer<A>, k: K) => boolean): (self: HashMap<K, A>) => HashMap<K, A>
  <K, A>(self: HashMap<K, A>, f: (a: A, k: K) => boolean): HashMap<K, A>
} = internal.filter
Referenced by 1 symbols