mapValue.js 407 B

1234567891011121314151617181920
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', {
  3. value: true,
  4. });
  5. exports.mapValue = mapValue;
  6. /**
  7. * Creates an object map with the same keys as `map` and values generated by
  8. * running each value of `map` thru `fn`.
  9. */
  10. function mapValue(map, fn) {
  11. const result = Object.create(null);
  12. for (const key of Object.keys(map)) {
  13. result[key] = fn(map[key], key);
  14. }
  15. return result;
  16. }