<K extends string | symbol, A>(self: ReadonlyRecord<K, A>): Array<
K & string
>Retrieves the keys of a given record as an array.
Example (Getting record keys)
import { Record } from "effect"
import * as assert from "node:assert"
assert.deepStrictEqual(Record.keys({ a: 1, b: 2, c: 3 }), ["a", "b", "c"])getters
Source effect/Record.ts:10042 lines
export const const keys: <
K extends string | symbol,
A
>(
self: ReadonlyRecord<K, A>
) => Array<K & string>
Retrieves the keys of a given record as an array.
Example (Getting record keys)
import { Record } from "effect"
import * as assert from "node:assert"
assert.deepStrictEqual(Record.keys({ a: 1, b: 2, c: 3 }), ["a", "b", "c"])
keys = <function (type parameter) K in <K extends string | symbol, A>(self: ReadonlyRecord<K, A>): Array<K & string>K extends string | symbol, function (type parameter) A in <K extends string | symbol, A>(self: ReadonlyRecord<K, A>): Array<K & string>A>(self: ReadonlyRecord<K, A>self: type ReadonlyRecord<in out K extends string | symbol, out A> = { readonly [P in K]: A; }Represents a readonly record with keys of type K and values of type A.
This is the foundational type for immutable key-value mappings in Effect.
Example (Defining a readonly record type)
import type { Record } from "effect"
// Creating a readonly record type
type UserRecord = Record.ReadonlyRecord<"name" | "age", string | number>
const user: UserRecord = {
name: "John",
age: 30
}
Namespace containing utility types for working with readonly records.
These types help with type-level operations on record keys and values.
Example (Using readonly record helper types)
import type { Record } from "effect"
// Using NonLiteralKey to convert literal keys to generic types
type GenericKey = Record.ReadonlyRecord.NonLiteralKey<"foo" | "bar"> // string
// Using IntersectKeys to find common keys between record types
type CommonKeys = Record.ReadonlyRecord.IntersectKeys<"a" | "b", "b" | "c"> // "b"
ReadonlyRecord<function (type parameter) K in <K extends string | symbol, A>(self: ReadonlyRecord<K, A>): Array<K & string>K, function (type parameter) A in <K extends string | symbol, A>(self: ReadonlyRecord<K, A>): Array<K & string>A>): interface Array<T>Array<function (type parameter) K in <K extends string | symbol, A>(self: ReadonlyRecord<K, A>): Array<K & string>K & string> =>
var Object: ObjectConstructorProvides functionality common to all JavaScript objects.
Object.ObjectConstructor.keys(o: {}): string[] (+1 overload)Returns the names of the enumerable string properties and methods of an object.
keys(self: ReadonlyRecord<K, A>self) as interface Array<T>Array<function (type parameter) K in <K extends string | symbol, A>(self: ReadonlyRecord<K, A>): Array<K & string>K & string>Referenced by 19 symbols