Package: effect
Module: HashMap
Returns an Array of the values within the HashMap.
Example (Converting values to an array)
import { HashMap } from "effect"
const employees = HashMap.make(
["alice", { department: "engineering", salary: 90000 }],
["bob", { department: "marketing", salary: 75000 }],
["charlie", { department: "engineering", salary: 95000 }]
)
// Extract all employee records
const allEmployees = HashMap.toValues(employees)
console.log(allEmployees.length) // 3
// Calculate total salary
const totalSalary = allEmployees.reduce((sum, emp) => sum + emp.salary, 0)
console.log(totalSalary) // 260000
// Filter by department
const engineers = allEmployees.filter((emp) => emp.department === "engineering")
console.log(engineers.length) // 2
Signature
declare const toValues: <K, V>(self: HashMap<K, V>) => Array<V>
Since v3.13.0