1 | /* @flow */
|
2 |
|
3 | export default function mapObject<TValue, TNext>(
|
4 | object: {[key: string]: TValue},
|
5 | mapper: (value: TValue, key: string) => TNext,
|
6 | ): {[key: string]: TNext} {
|
7 | return Object.keys(object).reduce(
|
8 | (result, key) => {
|
9 | result[key] = mapper(object[key], key);
|
10 | return result;
|
11 | },
|
12 | {},
|
13 | );
|
14 | }
|