Hyperlinkv0.8.0-beta.28

MutableHashMap

MutableHashMap.valuesconsteffect/MutableHashMap.ts:366
<K, V>(self: MutableHashMap<K, V>): Iterable<V>

Returns an iterable over the values in the MutableHashMap.

When to use

Use to iterate over the values currently stored in a mutable hash map.

Example (Reading values)

import { MutableHashMap } from "effect"

const map = MutableHashMap.make(
  ["apple", 1],
  ["banana", 2],
  ["cherry", 3]
)

const allValues = Array.from(MutableHashMap.values(map))
console.log(allValues) // [1, 2, 3]

// Useful for calculations
const total = allValues.reduce((sum, value) => sum + value, 0)
console.log(total) // 6

// Filter values
const largeValues = allValues.filter((value) => value > 1)
console.log(largeValues) // [2, 3]
elementskeys
export const values = <K, V>(self: MutableHashMap<K, V>): Iterable<V> => self.backing.values()
Referenced by 2 symbols