Skip to content

Alias mapObject to mapValues #2073

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1381,6 +1381,7 @@ <h2 id="objects">Object Functions</h2>

<p id="mapObject">
<b class="header">mapObject</b><code>_.mapObject(object, iteratee, [context])</code>
<span class="alias">Alias: <b>mapValues</b></span>
<br />
Like <a href="#map">map</a>, but for objects. Transform the value
of each property in turn.
Expand Down
4 changes: 4 additions & 0 deletions test/objects.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
}());
2 changes: 1 addition & 1 deletion underscore.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down