lodash: Add thisArg to groupBy and optimize invoke. [jddalton]

Former-commit-id: 74b0105af083471a56d60ac423409ae39e17d44a
This commit is contained in:
John-David Dalton
2012-04-25 00:08:46 -04:00
parent 774f159e67
commit 313ffb8821
4 changed files with 66 additions and 31 deletions

View File

@@ -87,6 +87,20 @@
/*--------------------------------------------------------------------------*/
QUnit.module('lodash.groupBy');
(function() {
test('supports the `thisArg` argument', function() {
var actual = _.groupBy([1.3, 2.1, 2.4], function(num) {
return this.floor(num);
}, Math);
deepEqual(actual, { '1': [1.3], '2': [2.1, 2.4] });
});
}());
/*--------------------------------------------------------------------------*/
QUnit.module('lodash.initial');
(function() {
@@ -136,6 +150,20 @@
/*--------------------------------------------------------------------------*/
QUnit.module('lodash.sortBy');
(function() {
test('supports the `thisArg` argument', function() {
var actual = _.sortBy([1, 2, 3, 4], function(num) {
return this.sin(num);
}, Math);
deepEqual(actual, [4, 3, 1, 2]);
});
}());
/*--------------------------------------------------------------------------*/
QUnit.module('lodash.toArray');
(function() {