mapValue.js 748 B

123456789101112131415161718192021222324252627
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = mapValue;
  6. var _objectEntries3 = _interopRequireDefault(require("../polyfills/objectEntries"));
  7. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  8. /**
  9. * Creates an object map with the same keys as `map` and values generated by
  10. * running each value of `map` thru `fn`.
  11. */
  12. function mapValue(map, fn) {
  13. var result = Object.create(null);
  14. for (var _i2 = 0, _objectEntries2 = (0, _objectEntries3.default)(map); _i2 < _objectEntries2.length; _i2++) {
  15. var _ref2 = _objectEntries2[_i2];
  16. var _key = _ref2[0];
  17. var _value = _ref2[1];
  18. result[_key] = fn(_value, _key);
  19. }
  20. return result;
  21. }