effect-io-ai

Package: effect
Module: TxHashMap

TxHashMap.entries

Returns an array of all key-value pairs in the TxHashMap.

Example (Reading entries)

import { Effect, TxHashMap } from "effect"

const program = Effect.gen(function*() {
  const config = yield* TxHashMap.make(
    ["host", "localhost"],
    ["port", "3000"],
    ["ssl", "false"]
  )

  const allEntries = yield* TxHashMap.entries(config)
  const sortedEntries = allEntries.toSorted(([left], [right]) => left.localeCompare(right))
  console.log(sortedEntries)
  // [["host", "localhost"], ["port", "3000"], ["ssl", "false"]]

  // Process configuration entries
  for (const [key, value] of sortedEntries) {
    console.log(`${key}=${value}`)
  }
  // host=localhost
  // port=3000
  // ssl=false
})

Signature

declare const entries: <K, V>(self: TxHashMap<K, V>) => Effect.Effect<Array<readonly [K, V]>>

Source

Since v4.0.0