mapValue.mjs 513 B

123456789101112131415161718
  1. import objectEntries from '../polyfills/objectEntries';
  2. /**
  3. * Creates an object map with the same keys as `map` and values generated by
  4. * running each value of `map` thru `fn`.
  5. */
  6. export default function mapValue(map, fn) {
  7. var result = Object.create(null);
  8. for (var _i2 = 0, _objectEntries2 = objectEntries(map); _i2 < _objectEntries2.length; _i2++) {
  9. var _ref2 = _objectEntries2[_i2];
  10. var _key = _ref2[0];
  11. var _value = _ref2[1];
  12. result[_key] = fn(_value, _key);
  13. }
  14. return result;
  15. }