8000 Ensure `fp.over` doesn't cap its iteratee args. · lodash/lodash@b424f3b · GitHub
[go: up one dir, main page]

Skip to content

Commit b424f3b

Browse files
committed
Ensure fp.over doesn't cap its iteratee args.
1 parent 201ea9a commit b424f3b

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

lodash.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4624,9 +4624,15 @@
46244624
*/
46254625
function createOver(arrayFunc) {
46264626
return rest(function(iteratees) {
4627+
var toIteratee = getIteratee();
4628+
46274629
iteratees = (iteratees.length == 1 && isArray(iteratees[0]))
4628-
? arrayMap(iteratees[0], getIteratee())
4629-
: arrayMap(baseFlatten(iteratees, 1, isFlattenableIteratee), getIteratee());
4630+
? iteratees[0]
4631+
: baseFlatten(iteratees, 1, isFlattenableIteratee);
4632+
4633+
iteratees = arrayMap(iteratees, function(iteratee) {
4634+
return toIteratee(iteratee, Infinity);
4635+
});
46304636

46314637
return rest(function(args) {
46324638
var thisArg = this;

test/test-fp.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1443,6 +1443,21 @@
14431443

14441444
/*--------------------------------------------------------------------------*/
14451445

1446+
QUnit.module('fp.over');
1447+
1448+
(function() {
1449+
QUnit.test('should not cap iteratee args', function(assert) {
1450+
assert.expect(2);
1451+
1452+
_.each([fp.over, convert('over', _.over)], function(func) {
1453+
var over = func([Math.max, Math.min]);
1454+
assert.deepEqual(over(1, 2, 3, 4), [4, 1]);
1455+
});
1456+
});
1457+
}());
1458+
1459+
/*--------------------------------------------------------------------------*/
1460+
14461461
QUnit.module('fp.omitBy and fp.pickBy');
14471462

14481463
_.each(['omitBy', 'pickBy'], function(methodName) {

0 commit comments

Comments
 (0)
0