mapValue.mjs 303 B

12345678910111213
  1. /**
  2. * Creates an object map with the same keys as `map` and values generated by
  3. * running each value of `map` thru `fn`.
  4. */
  5. export function mapValue(map, fn) {
  6. const result = Object.create(null);
  7. for (const key of Object.keys(map)) {
  8. result[key] = fn(map[key], key);
  9. }
  10. return result;
  11. }