diff --git a/index.html b/index.html index a5d9ec206..24b227505 100644 --- a/index.html +++ b/index.html @@ -1381,6 +1381,7 @@
mapObject_.mapObject(object, iteratee, [context])
+ Alias: mapValues
Like map, but for objects. Transform the value
of each property in turn.
diff --git a/test/objects.js b/test/objects.js
index 614d1cd8f..db70b0932 100644
--- a/test/objects.js
+++ b/test/objects.js
@@ -997,4 +997,8 @@
assert.deepEqual(_.mapObject(protoObj, _.identity), {a: 1}, 'ignore inherited values from prototypes');
});
+
+ QUnit.test('mapValues', function(assert) {
+ assert.strictEqual(_.mapValues, _.mapObject, 'is an alias for mapObject');
+ });
}());
diff --git a/underscore.js b/underscore.js
index 9db5560d7..824b3f781 100644
--- a/underscore.js
+++ b/underscore.js
@@ -993,7 +993,7 @@
// Returns the results of applying the iteratee to each element of the object
// In contrast to _.map it returns an object
- _.mapObject = function(obj, iteratee, context) {
+ _.mapObject = _.mapValues = function(obj, iteratee, context) {
iteratee = cb(iteratee, context);
var keys = _.keys(obj),
length = keys.length,