Hyperlinkv0.8.0-beta.28

Struct

Struct.Recordfunctioneffect/Struct.ts:970
<const Keys extends ReadonlyArray<string | symbol>, Value>(
  keys: Keys,
  value: Value
): Record<Keys[number], Value>

Creates a record with the given keys and value.

When to use

Use to build an object where each provided key receives the same value.

Example (Creating a record)

import { Struct } from "effect"

const record = Struct.Record(["a", "b"], "value")
console.log(record) // { a: "value", b: "value" }
constructors
Source effect/Struct.ts:97010 lines
export function Record<const Keys extends ReadonlyArray<string | symbol>, Value>(
  keys: Keys,
  value: Value
): Record<Keys[number], Value> {
  const out: any = {}
  for (const key of keys) {
    out[key] = value
  }
  return out
}