<K extends string | symbol, X extends K>(key: X): <A>(
self: ReadonlyRecord<K, A>
) => Option.Option<[A, Record<Exclude<K, X>, A>]>
<K extends string | symbol, A, X extends K>(
self: ReadonlyRecord<K, A>,
key: X
): Option.Option<[A, Record<Exclude<K, X>, A>]>Retrieves the value of the property with the given key from a record safely and returns an Option
of a tuple with the value and the record with the removed property.
If the key is not present, returns Option.none().
Example (Popping a value and removing its key)
import { Record } from "effect"
const input: Record<string, number> = { a: 1, b: 2 }
Record.pop(input, "a") // Option.some([1, { b: 2 }])
Record.pop(input, "c") // Option.none()export const const pop: {
<K extends string | symbol, X extends K>(
key: X
): <A>(
self: ReadonlyRecord<K, A>
) => Option.Option<
[A, Record<Exclude<K, X>, A>]
>
<K extends string | symbol, A, X extends K>(
self: ReadonlyRecord<K, A>,
key: X
): Option.Option<[A, Record<Exclude<K, X>, A>]>
}
Retrieves the value of the property with the given key from a record safely and returns an Option
of a tuple with the value and the record with the removed property.
If the key is not present, returns Option.none().
Example (Popping a value and removing its key)
import { Record } from "effect"
const input: Record<string, number> = { a: 1, b: 2 }
Record.pop(input, "a") // Option.some([1, { b: 2 }])
Record.pop(input, "c") // Option.none()
pop: {
<function (type parameter) K in <K extends string | symbol, X extends K>(key: X): <A>(self: ReadonlyRecord<K, A>) => Option.Option<[A, Record<Exclude<K, X>, A>]>K extends string | symbol, function (type parameter) X in <K extends string | symbol, X extends K>(key: X): <A>(self: ReadonlyRecord<K, A>) => Option.Option<[A, Record<Exclude<K, X>, A>]>X extends function (type parameter) K in <K extends string | symbol, X extends K>(key: X): <A>(self: ReadonlyRecord<K, A>) => Option.Option<[A, Record<Exclude<K, X>, A>]>K>(
key: X extends Kkey: function (type parameter) X in <K extends string | symbol, X extends K>(key: X): <A>(self: ReadonlyRecord<K, A>) => Option.Option<[A, Record<Exclude<K, X>, A>]>X
): <function (type parameter) A in <A>(self: ReadonlyRecord<K, A>): Option.Option<[A, Record<Exclude<K, X>, A>]>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, X extends K>(key: X): <A>(self: ReadonlyRecord<K, A>) => Option.Option<[A, Record<Exclude<K, X>, A>]>K, function (type parameter) A in <A>(self: ReadonlyRecord<K, A>): Option.Option<[A, Record<Exclude<K, X>, A>]>A>) => import OptionOption.type Option.Option = /*unresolved*/ anyOption<[function (type parameter) A in <A>(self: ReadonlyRecord<K, A>): Option.Option<[A, Record<Exclude<K, X>, A>]>A, type Record<K extends keyof any, T> = {
[P in K]: T
}
Construct a type with a set of properties K of type T
Record<type Exclude<T, U> = T extends U
? never
: T
Exclude from T those types that are assignable to U
Exclude<function (type parameter) K in <K extends string | symbol, X extends K>(key: X): <A>(self: ReadonlyRecord<K, A>) => Option.Option<[A, Record<Exclude<K, X>, A>]>K, function (type parameter) X in <K extends string | symbol, X extends K>(key: X): <A>(self: ReadonlyRecord<K, A>) => Option.Option<[A, Record<Exclude<K, X>, A>]>X>, function (type parameter) A in <A>(self: ReadonlyRecord<K, A>): Option.Option<[A, Record<Exclude<K, X>, A>]>A>]>
<function (type parameter) K in <K extends string | symbol, A, X extends K>(self: ReadonlyRecord<K, A>, key: X): Option.Option<[A, Record<Exclude<K, X>, A>]>K extends string | symbol, function (type parameter) A in <K extends string | symbol, A, X extends K>(self: ReadonlyRecord<K, A>, key: X): Option.Option<[A, Record<Exclude<K, X>, A>]>A, function (type parameter) X in <K extends string | symbol, A, X extends K>(self: ReadonlyRecord<K, A>, key: X): Option.Option<[A, Record<Exclude<K, X>, A>]>X extends function (type parameter) K in <K extends string | symbol, A, X extends K>(self: ReadonlyRecord<K, A>, key: X): Option.Option<[A, Record<Exclude<K, X>, A>]>K>(
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, X extends K>(self: ReadonlyRecord<K, A>, key: X): Option.Option<[A, Record<Exclude<K, X>, A>]>K, function (type parameter) A in <K extends string | symbol, A, X extends K>(self: ReadonlyRecord<K, A>, key: X): Option.Option<[A, Record<Exclude<K, X>, A>]>A>,
key: X extends Kkey: function (type parameter) X in <K extends string | symbol, A, X extends K>(self: ReadonlyRecord<K, A>, key: X): Option.Option<[A, Record<Exclude<K, X>, A>]>X
): import OptionOption.type Option.Option = /*unresolved*/ anyOption<[function (type parameter) A in <K extends string | symbol, A, X extends K>(self: ReadonlyRecord<K, A>, key: X): Option.Option<[A, Record<Exclude<K, X>, A>]>A, type Record<K extends keyof any, T> = {
[P in K]: T
}
Construct a type with a set of properties K of type T
Record<type Exclude<T, U> = T extends U
? never
: T
Exclude from T those types that are assignable to U
Exclude<function (type parameter) K in <K extends string | symbol, A, X extends K>(self: ReadonlyRecord<K, A>, key: X): Option.Option<[A, Record<Exclude<K, X>, A>]>K, function (type parameter) X in <K extends string | symbol, A, X extends K>(self: ReadonlyRecord<K, A>, key: X): Option.Option<[A, Record<Exclude<K, X>, A>]>X>, function (type parameter) A in <K extends string | symbol, A, X extends K>(self: ReadonlyRecord<K, A>, key: X): Option.Option<[A, Record<Exclude<K, X>, A>]>A>]>
} = import dualdual(2, <function (type parameter) K in <K extends string | symbol, A, X extends K>(self: ReadonlyRecord<K, A>, key: X): Option.Option<[A, Record<Exclude<K, X>, A>]>K extends string | symbol, function (type parameter) A in <K extends string | symbol, A, X extends K>(self: ReadonlyRecord<K, A>, key: X): Option.Option<[A, Record<Exclude<K, X>, A>]>A, function (type parameter) X in <K extends string | symbol, A, X extends K>(self: ReadonlyRecord<K, A>, key: X): Option.Option<[A, Record<Exclude<K, X>, A>]>X extends function (type parameter) K in <K extends string | symbol, A, X extends K>(self: ReadonlyRecord<K, A>, key: X): Option.Option<[A, Record<Exclude<K, X>, A>]>K>(
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, X extends K>(self: ReadonlyRecord<K, A>, key: X): Option.Option<[A, Record<Exclude<K, X>, A>]>K, function (type parameter) A in <K extends string | symbol, A, X extends K>(self: ReadonlyRecord<K, A>, key: X): Option.Option<[A, Record<Exclude<K, X>, A>]>A>,
key: X extends Kkey: function (type parameter) X in <K extends string | symbol, A, X extends K>(self: ReadonlyRecord<K, A>, key: X): Option.Option<[A, Record<Exclude<K, X>, A>]>X
): import OptionOption.type Option.Option = /*unresolved*/ anyOption<[function (type parameter) A in <K extends string | symbol, A, X extends K>(self: ReadonlyRecord<K, A>, key: X): Option.Option<[A, Record<Exclude<K, X>, A>]>A, type Record<K extends keyof any, T> = {
[P in K]: T
}
Construct a type with a set of properties K of type T
Record<type Exclude<T, U> = T extends U
? never
: T
Exclude from T those types that are assignable to U
Exclude<function (type parameter) K in <K extends string | symbol, A, X extends K>(self: ReadonlyRecord<K, A>, key: X): Option.Option<[A, Record<Exclude<K, X>, A>]>K, function (type parameter) X in <K extends string | symbol, A, X extends K>(self: ReadonlyRecord<K, A>, key: X): Option.Option<[A, Record<Exclude<K, X>, A>]>X>, function (type parameter) A in <K extends string | symbol, A, X extends K>(self: ReadonlyRecord<K, A>, key: X): Option.Option<[A, Record<Exclude<K, X>, A>]>A>]> =>
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
}
has(self: ReadonlyRecord<K, A>self, key: X extends Kkey) ? import OptionOption.some([self: ReadonlyRecord<K, A>self[key: X extends Kkey], const remove: {
<K extends string | symbol, X extends K>(
key: X
): <A>(
self: ReadonlyRecord<K, A>
) => Record<Exclude<K, X>, A>
<K extends string | symbol, A, X extends K>(
self: ReadonlyRecord<K, A>,
key: X
): Record<Exclude<K, X>, A>
}
remove(self: ReadonlyRecord<K, A>self, key: X extends Kkey)]) : import OptionOption.none())