kitchensink
Version:
Dispatch's awesome components and style guide
12 lines (10 loc) • 304 B
JavaScript
/* @flow */
export default function mapObject<TValue, TNext>(
object: {[key: string]: TValue},
mapper: (value: TValue, key: string) => TNext
): {[key: string]: TNext} {
return Object.keys(object).reduce((result, key) => {
result[key] = mapper(object[key], key);
return result;
}, {});
}