Hyperlinkv0.8.0-beta.28

TxHashMap

TxHashMap.isNonEmptyconsteffect/TxHashMap.ts:673
<K, V>(self: TxHashMap<K, V>): Effect.Effect<boolean>

Checks whether the TxHashMap is non-empty.

Example (Checking for a non-empty map)

import { Effect, TxHashMap } from "effect"

const program = Effect.gen(function*() {
  const inventory = yield* TxHashMap.make(["laptop", 5])

  const hasItems = yield* TxHashMap.isNonEmpty(inventory)
  console.log(hasItems) // true

  // Clear inventory
  yield* TxHashMap.clear(inventory)
  const stillHasItems = yield* TxHashMap.isNonEmpty(inventory)
  console.log(stillHasItems) // false
})
combinators
export const isNonEmpty = <K, V>(self: TxHashMap<K, V>): Effect.Effect<boolean> =>
  Effect.map(isEmpty(self), (empty) => !empty)