mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-29 06:27:49 +00:00
Ensure fp.rearg returns a curried function. [closes #2413]
This commit is contained in:
@@ -209,6 +209,12 @@ function baseConvert(util, name, func, options) {
|
||||
return func;
|
||||
};
|
||||
},
|
||||
'rearg': function(rearg) {
|
||||
return function(func, indexes) {
|
||||
var n = indexes ? indexes.length : 0;
|
||||
return curry(rearg(func, indexes), n);
|
||||
};
|
||||
},
|
||||
'runInContext': function(runInContext) {
|
||||
return function(context) {
|
||||
return baseConvert(util, runInContext(context), options);
|
||||
|
||||
@@ -321,6 +321,7 @@ exports.skipFixed = {
|
||||
'flowRight': true,
|
||||
'iteratee': true,
|
||||
'mixin': true,
|
||||
'rearg': true,
|
||||
'runInContext': true
|
||||
};
|
||||
|
||||
|
||||
@@ -1779,6 +1779,30 @@
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
QUnit.module('fp.rearg');
|
||||
|
||||
(function() {
|
||||
function fn(a, b, c) {
|
||||
return [a, b, c];
|
||||
}
|
||||
|
||||
QUnit.test('should be curried', function(assert) {
|
||||
assert.expect(1);
|
||||
|
||||
var rearged = fp.rearg([1, 2, 0])(fn);
|
||||
assert.deepEqual(rearged('c', 'a', 'b'), ['a', 'b', 'c']);
|
||||
});
|
||||
|
||||
QUnit.test('should curry the rearged function', function(assert) {
|
||||
assert.expect(1);
|
||||
|
||||
var rearged = fp.rearg([1, 2, 0], fn);
|
||||
assert.deepEqual(rearged('c')('a')('b'), ['a', 'b', 'c']);
|
||||
});
|
||||
}());
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
QUnit.module('reduce methods');
|
||||
|
||||
_.each(['reduce', 'reduceRight'], function(methodName) {
|
||||
|
||||
Reference in New Issue
Block a user