map.js 500 B

123456789101112131415161718
  1. var forOwn = require('./forOwn');
  2. var makeIterator = require('../function/makeIterator_');
  3. /**
  4. * Creates a new object where all the values are the result of calling
  5. * `callback`.
  6. */
  7. function mapValues(obj, callback, thisObj) {
  8. callback = makeIterator(callback, thisObj);
  9. var output = {};
  10. forOwn(obj, function(val, key, obj) {
  11. output[key] = callback(val, key, obj);
  12. });
  13. return output;
  14. }
  15. module.exports = mapValues;