1 2 3 4 5 6 7 8 9 10 | 1× 993× | /** * Maps all the values in the given object through the given function and saves them, by key, to a result object */ export default function mapValues(obj, fn) { return obj ? Object.keys(obj).reduce((accumulator, key) => ({ ...accumulator, [key]: fn(obj[key], key) }), {}) : obj; } |