This repository has been archived on 2026-03-06. You can view files and clone it, but cannot push or open issues or pull requests.
todo/client/node_modules/underscore/amd/mapObject.js
2025-06-13 14:04:40 +08:00

20 lines
562 B
JavaScript

define(['./keys', './_cb'], function (keys, _cb) {
// Returns the results of applying the `iteratee` to each element of `obj`.
// In contrast to `_.map` it returns an object.
function mapObject(obj, iteratee, context) {
iteratee = _cb(iteratee, context);
var _keys = keys(obj),
length = _keys.length,
results = {};
for (var index = 0; index < length; index++) {
var currentKey = _keys[index];
results[currentKey] = iteratee(obj[currentKey], currentKey, obj);
}
return results;
}
return mapObject;
});