<K extends string, A>(self: Readonly<Record<K, A>>): Iterable<[K, A]>Takes a record and returns an Iterable of tuples containing its keys and values.
Example (Converting a record to entries)
import { Iterable } from "effect"
import * as assert from "node:assert"
const x = { a: 1, b: 2, c: 3 }
assert.deepStrictEqual(Array.from(Iterable.fromRecord(x)), [["a", 1], ["b", 2], [
"c",
3
]])converting
Source effect/Iterable.ts:1909 lines
export const const fromRecord: <K extends string, A>(
self: Readonly<Record<K, A>>
) => Iterable<[K, A]>
Takes a record and returns an Iterable of tuples containing its keys and values.
Example (Converting a record to entries)
import { Iterable } from "effect"
import * as assert from "node:assert"
const x = { a: 1, b: 2, c: 3 }
assert.deepStrictEqual(Array.from(Iterable.fromRecord(x)), [["a", 1], ["b", 2], [
"c",
3
]])
fromRecord = <function (type parameter) K in <K extends string, A>(self: Readonly<Record<K, A>>): Iterable<[K, A]>K extends string, function (type parameter) A in <K extends string, A>(self: Readonly<Record<K, A>>): Iterable<[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>>): Iterable<[K, A]>K, function (type parameter) A in <K extends string, A>(self: Readonly<Record<K, A>>): Iterable<[K, A]>A>>): interface Iterable<T, TReturn = any, TNext = any>Iterable<[function (type parameter) K in <K extends string, A>(self: Readonly<Record<K, A>>): Iterable<[K, A]>K, function (type parameter) A in <K extends string, A>(self: Readonly<Record<K, A>>): Iterable<[K, A]>A]> => ({
*[var Symbol: SymbolConstructorSymbol.SymbolConstructor.iterator: typeof Symbol.iteratorA method that returns the default iterator for an object. Called by the semantics of the
for-of statement.
iterator]() {
for (const const key: Extract<K, string>key in self: Readonly<Record<K, A>>self) {
if (var Object: ObjectConstructorProvides functionality common to all JavaScript objects.
Object.ObjectConstructor.hasOwn(o: object, v: PropertyKey): booleanDetermines whether an object has a property with the specified name.
hasOwn(self: Readonly<Record<K, A>>self, const key: Extract<K, string>key)) {
yield [const key: Extract<K, string>key, self: Readonly<Record<K, A>>self[const key: Extract<K, string>key]]
}
}
}
})