Hyperlinkv0.8.0-beta.28

RcMap

RcMap.hasconsteffect/RcMap.ts:541
<K>(key: K): <A, E>(self: RcMap<K, A, E>) => Effect.Effect<boolean>
<K, A, E>(self: RcMap<K, A, E>, key: K): Effect.Effect<boolean>

Returns whether the RcMap currently contains an entry for the specified key.

When to use

Use to check whether a key is already present in an RcMap without running the lookup function or acquiring a missing resource.

Details

This operation only checks the current map state.

Gotchas

Closed maps return false, so false does not distinguish a missing key from a closed map.

combinatorsgetkeys
Source effect/RcMap.ts:54111 lines
export const has: {
  <K>(key: K): <A, E>(self: RcMap<K, A, E>) => Effect.Effect<boolean>
  <K, A, E>(self: RcMap<K, A, E>, key: K): Effect.Effect<boolean>
} = dual(
  2,
  <K, A, E>(self: RcMap<K, A, E>, key: K) =>
    Effect.sync(() => {
      if (self.state._tag === "Closed") return false
      return MutableHashMap.has(self.state.map, key)
    })
)