effect-io-ai

Package: effect
Module: TxHashMap

TxHashMap.isEmpty

Checks whether the TxHashMap is empty.

Example (Checking for an empty map)

import { Effect, TxHashMap } from "effect"

const program = Effect.gen(function*() {
  // Start with empty map
  const cache = yield* TxHashMap.empty<string, any>()
  const empty = yield* TxHashMap.isEmpty(cache)
  console.log(empty) // true

  // Add an item
  yield* TxHashMap.set(cache, "key1", "value1")
  const stillEmpty = yield* TxHashMap.isEmpty(cache)
  console.log(stillEmpty) // false

  // Clear and check again
  yield* TxHashMap.clear(cache)
  const emptyAgain = yield* TxHashMap.isEmpty(cache)
  console.log(emptyAgain) // true
})

Signature

declare const isEmpty: <K, V>(self: TxHashMap<K, V>) => Effect.Effect<boolean>

Source

Since v2.0.0