effect-io-ai

Package: effect
Module: Record

Record.fromEntries

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 })

Signature

declare const fromEntries: <Entry extends readonly [string | symbol, any]>(entries: Iterable<Entry>) => Record<ReadonlyRecord.NonLiteralKey<Entry[0]>, Entry[1]>

Source

Since v2.0.0