Package: effect
Module: TxHashMap
Returns an array of all values in the TxHashMap.
Example (Reading values)
import { Effect, TxHashMap } from "effect"
const program = Effect.gen(function*() {
const scores = yield* TxHashMap.make(
["alice", 95],
["bob", 87],
["charlie", 92]
)
const allScores = yield* TxHashMap.values(scores)
console.log(allScores.sort((a, b) => a - b)) // [87, 92, 95]
// Calculate average
const average = allScores.reduce((sum, score) => sum + score, 0) /
allScores.length
console.log(average.toFixed(2)) // "91.33"
// Find maximum
const maxScore = Math.max(...allScores)
console.log(maxScore) // 95
})
Signature
declare const values: <K, V>(self: TxHashMap<K, V>) => Effect.Effect<Array<V>>
Since v2.0.0