Hyperlinkv0.8.0-beta.28

HashMap

HashMap.entriesconsteffect/HashMap.ts:627
<K, V>(self: HashMap<K, V>): IterableIterator<[K, V]>

Returns an IterableIterator of the entries within the HashMap.

Example (Iterating entries)

import { HashMap } from "effect"

// Create a configuration map
const config = HashMap.make(
  ["database.host", "localhost"],
  ["database.port", "5432"],
  ["cache.enabled", "true"]
)

// Sort the derived array for deterministic output
const settings = Array.from(HashMap.entries(config))
  .sort(([left], [right]) => left.localeCompare(right))
  .map(([key, value]) => `Setting ${key} = ${value}`)

console.log(settings)
// ["Setting cache.enabled = true", "Setting database.host = localhost", "Setting database.port = 5432"]

// Convert to array when you need all entries at once
const allEntries = Array.from(HashMap.entries(config))
console.log(allEntries.length) // 3
getters
Source effect/HashMap.ts:6271 lines
export const entries: <K, V>(self: HashMap<K, V>) => IterableIterator<[K, V]> = internal.entries
Referenced by 1 symbols