/** * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow strict */ import { type ObjMap } from './ObjMap'; import objectEntries from '../polyfills/objectEntries'; /** * 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( map: ObjMap, fn: (value: T, key: string) => V, ): ObjMap { const result = Object.create(null); for (const [key, value] of objectEntries(map)) { result[key] = fn(value, key); } return result; }