MCPcopy
hub / github.com/primer/react / mapValues

Function mapValues

packages/react/src/hooks/useSlots.ts:87–95  ·  view source on GitHub ↗

Map the values of an object

(obj: T, fn: (value: T[keyof T]) => V)

Source from the content-addressed store, hash-verified

85
86/** Map the values of an object */
87function mapValues<T extends Record<string, unknown>, V>(obj: T, fn: (value: T[keyof T]) => V) {
88 return Object.keys(obj).reduce(
89 (result, key: keyof T) => {
90 result[key] = fn(obj[key])
91 return result
92 },
93 {} as Record<keyof T, V>,
94 )
95}

Callers 1

useSlotsFunction · 0.85

Calls 1

fnFunction · 0.85

Tested by

no test coverage detected