Hyperlinkv0.8.0-beta.28

Record

Record.hasconsteffect/Record.ts:401
<K extends string | symbol>(key: NoInfer<K>): <A>(
  self: ReadonlyRecord<K, A>
) => boolean
<K extends string | symbol, A>(
  self: ReadonlyRecord<K, A>,
  key: NoInfer<K>
): boolean

Checks whether a given key exists in a record.

Example (Checking key membership)

import { Record } from "effect"
import * as assert from "node:assert"

assert.deepStrictEqual(Record.has({ a: 1, b: 2 }, "a"), true)
assert.deepStrictEqual(Record.has(Record.empty<string>(), "c"), false)
guards
Source effect/Record.ts:40115 lines
export const has: {
  <K extends string | symbol>(
    key: NoInfer<K>
  ): <A>(self: ReadonlyRecord<K, A>) => boolean
  <K extends string | symbol, A>(
    self: ReadonlyRecord<K, A>,
    key: NoInfer<K>
  ): boolean
} = dual(
  2,
  <K extends string | symbol, A>(
    self: ReadonlyRecord<K, A>,
    key: NoInfer<K>
  ): boolean => Object.hasOwn(self, key)
)
Referenced by 8 symbols