Hyperlinkv0.8.0-beta.28

MutableHashMap

MutableHashMap.hasconsteffect/MutableHashMap.ts:411
<K>(key: K): <V>(self: MutableHashMap<K, V>) => boolean
<K, V>(self: MutableHashMap<K, V>, key: K): boolean

Checks whether the MutableHashMap contains the specified key.

When to use

Use to test whether a key is present in a MutableHashMap without reading its value.

Example (Checking for a key)

import { MutableHashMap } from "effect"

const map = MutableHashMap.make(["key1", 42], ["key2", 100])

console.log(MutableHashMap.has(map, "key1")) // true
console.log(MutableHashMap.has(map, "key3")) // false

// Pipe-able version
const hasKey = MutableHashMap.has("key1")
console.log(hasKey(map)) // true
elementsget
export const has: {
  <K>(key: K): <V>(self: MutableHashMap<K, V>) => boolean
  <K, V>(self: MutableHashMap<K, V>, key: K): boolean
} = dual<
  <K>(key: K) => <V>(self: MutableHashMap<K, V>) => boolean,
  <K, V>(self: MutableHashMap<K, V>, key: K) => boolean
>(2, (self, key) => Option.isSome(get(self, key)))
Referenced by 4 symbols