Skip to content

Commit c4038ba

Browse files
committed
Alias mapObject to mapValues
For the record, I like `_.mapObject` better. But this change was undiscussed. Re: #2061, 4f771e0
1 parent 0e6d1e5 commit c4038ba

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1381,6 +1381,7 @@ <h2 id="objects">Object Functions</h2>
13811381

13821382
<p id="mapObject">
13831383
<b class="header">mapObject</b><code>_.mapObject(object, iteratee, [context])</code>
1384+
<span class="alias">Alias: <b>mapValues</b></span>
13841385
<br />
13851386
Like <a href="#map">map</a>, but for objects. Transform the value
13861387
of each property in turn.

test/objects.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -997,4 +997,8 @@
997997
assert.deepEqual(_.mapObject(protoObj, _.identity), {a: 1}, 'ignore inherited values from prototypes');
998998

999999
});
1000+
1001+
QUnit.test('mapValues', function(assert) {
1002+
assert.strictEqual(_.mapValues, _.mapObject, 'is an alias for mapObject');
1003+
});
10001004
}());

underscore.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -993,7 +993,7 @@
993993

994994
// Returns the results of applying the iteratee to each element of the object
995995
// In contrast to _.map it returns an object
996-
_.mapObject = function(obj, iteratee, context) {
996+
_.mapObject = _.mapValues = function(obj, iteratee, context) {
997997
iteratee = cb(iteratee, context);
998998
var keys = _.keys(obj),
999999
length = keys.length,

0 commit comments

Comments
 (0)