blob: d6b5da44e0db5c89fc492842e54ce84a943c48ae (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
// @flow strict
import objectEntries from '../polyfills/objectEntries';
import type { ObjMap } from './ObjMap';
/**
* Creates an object map with the same keys as `map` and values generated by
* running each value of `map` thru `fn`.
*/
export default function mapValue<T, V>(
map: ObjMap<T>,
fn: (value: T, key: string) => V,
): ObjMap<V> {
const result = Object.create(null);
for (const [key, value] of objectEntries(map)) {
result[key] = fn(value, key);
}
return result;
}
|