Skip to content

mapKeys

mapKeys<K, T>(mapFn, keys): { [key in string]: T }

Build a key-value mapped object

Constructs a mapped object where values of properties corresponding to each key from the union are evaluated by the provided mapping function called on these keys.

Type Parameters

K extends readonly string[]

Union of string keys

T

Type of a mapped object values

Parameters

mapFn

Function mapping a key to a value

keys: K

Returns

{ [key in string]: T }

Mapped object of keys