From c4038ba1e55d4c060483b6d053a05b782100d1a8 Mon Sep 17 00:00:00 2001 From: Justin Ridgewell Date: Fri, 20 Feb 2015 11:56:12 -0500 Subject: [PATCH] Alias mapObject to mapValues For the record, I like `_.mapObject` better. But this change was undiscussed. Re: https://github.com/jashkenas/underscore/issues/2061, 4f771e0 --- index.html | 1 + test/objects.js | 4 ++++ underscore.js | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/index.html b/index.html index a5d9ec206..24b227505 100644 --- a/index.html +++ b/index.html @@ -1381,6 +1381,7 @@

Object Functions

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,