No Description

mapObject.js 562B

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