Hyperlinkv0.8.0-beta.28

Record

Record.fromEntriesconsteffect/Record.ts:310
<Entry extends readonly [string | symbol, any]>(
  entries: Iterable<Entry>
): Record<ReadonlyRecord.NonLiteralKey<Entry[0]>, Entry[1]>

Builds a record from an iterable of key-value pairs.

Details

If there are conflicting keys when using fromEntries, the last occurrence of the key/value pair will overwrite the previous ones. So the resulting record will only have the value of the last occurrence of each key.

Example (Building a record from entries)

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

const input: Array<[string, number]> = [["a", 1], ["b", 2]]

assert.deepStrictEqual(Record.fromEntries(input), { a: 1, b: 2 })
constructors
Source effect/Record.ts:3103 lines
export const fromEntries: <Entry extends readonly [string | symbol, any]>(
  entries: Iterable<Entry>
) => Record<ReadonlyRecord.NonLiteralKey<Entry[0]>, Entry[1]> = Object.fromEntries