map.js 395 B

1234567891011121314
  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 result = {}, thisArg = arguments[2];
  7. callable(cb);
  8. forEach(obj, function (value, key, targetObj, index) {
  9. result[key] = call.call(cb, thisArg, value, key, targetObj, index);
  10. });
  11. return result;
  12. };