1
0

map-keys.js 372 B

123456789101112131415
  1. 'use strict';
  2. var callable = require('./valid-callable')
  3. , forEach = require('./for-each')
  4. , call = Function.prototype.call;
  5. module.exports = function (obj, cb/*, thisArg*/) {
  6. var o = {}, thisArg = arguments[2];
  7. callable(cb);
  8. forEach(obj, function (value, key, obj, index) {
  9. o[call.call(cb, thisArg, key, value, this, index)] = value;
  10. }, obj);
  11. return o;
  12. };