mapObject.js 530 B

1234567891011121314151617
  1. import cb from './_cb.js';
  2. import keys from './keys.js';
  3. // Returns the results of applying the `iteratee` to each element of `obj`.
  4. // In contrast to `_.map` it returns an object.
  5. export default function mapObject(obj, iteratee, context) {
  6. iteratee = cb(iteratee, context);
  7. var _keys = keys(obj),
  8. length = _keys.length,
  9. results = {};
  10. for (var index = 0; index < length; index++) {
  11. var currentKey = _keys[index];
  12. results[currentKey] = iteratee(obj[currentKey], currentKey, obj);
  13. }
  14. return results;
  15. }