effect-io-ai

Package: effect
Module: FiberMap

FiberMap.has

Checks whether a key exists in the FiberMap. This is the Effect-wrapped version of hasUnsafe.

Example (Checking if a key exists)

import { Effect, FiberMap } from "effect"

const program = Effect.gen(function*() {
  const map = yield* FiberMap.make<string>()

  // Add a fiber to the map
  yield* FiberMap.run(map, "task1", Effect.never)

  // Check if keys exist using Effect
  const exists1 = yield* FiberMap.has(map, "task1")
  const exists2 = yield* FiberMap.has(map, "task2")

  console.log(exists1) // true
  console.log(exists2) // false
})

Signature

declare const has: { <K>(key: K): <A, E>(self: FiberMap<K, A, E>) => Effect.Effect<boolean>; <K, A, E>(self: FiberMap<K, A, E>, key: K): Effect.Effect<boolean>; }

Source

Since v2.0.0