<K extends string, A>(self: Readonly<Record<K, A>>): Array<[K, A]>Converts a record into an array of [key, value] tuples.
When to use
Use to convert a record into an array of key-value tuples for iteration or transformation.
Details
Key order follows Object.entries semantics. Empty records produce an empty
array.
Example (Converting a record to entries)
import { Array } from "effect"
const result = Array.fromRecord({ a: 1, b: 2, c: 3 })
console.log(result) // [["a", 1], ["b", 2], ["c", 3]]export const const fromRecord: <K extends string, A>(
self: Readonly<Record<K, A>>
) => Array<[K, A]>
Converts a record into an array of [key, value] tuples.
When to use
Use to convert a record into an array of key-value tuples for iteration or
transformation.
Details
Key order follows Object.entries semantics. Empty records produce an empty
array.
Example (Converting a record to entries)
import { Array } from "effect"
const result = Array.fromRecord({ a: 1, b: 2, c: 3 })
console.log(result) // [["a", 1], ["b", 2], ["c", 3]]
fromRecord: <function (type parameter) K in <K extends string, A>(self: Readonly<Record<K, A>>): Array<[K, A]>K extends string, function (type parameter) A in <K extends string, A>(self: Readonly<Record<K, A>>): Array<[K, A]>A>(self: Readonly<Record<K, A>>self: type Readonly<T> = {
readonly [P in keyof T]: T[P]
}
Make all properties in T readonly
Readonly<type Record<K extends keyof any, T> = {
[P in K]: T
}
Construct a type with a set of properties K of type T
Record<function (type parameter) K in <K extends string, A>(self: Readonly<Record<K, A>>): Array<[K, A]>K, function (type parameter) A in <K extends string, A>(self: Readonly<Record<K, A>>): Array<[K, A]>A>>) => interface Array<T>Array<[function (type parameter) K in <K extends string, A>(self: Readonly<Record<K, A>>): Array<[K, A]>K, function (type parameter) A in <K extends string, A>(self: Readonly<Record<K, A>>): Array<[K, A]>A]> = import RecordRecord.const toEntries: <K extends string, A>(
self: ReadonlyRecord<K, A>
) => Array<[K, A]>
Takes a record and returns an array of tuples containing its keys and values.
Example (Converting a record to entries)
import { Record } from "effect"
import * as assert from "node:assert"
const x = { a: 1, b: 2, c: 3 }
assert.deepStrictEqual(Record.toEntries(x), [["a", 1], ["b", 2], ["c", 3]])
toEntries