Ensure fp.nthArg returns a curried function.

This commit is contained in:
John-David Dalton
2016-08-01 16:55:12 -07:00
parent a4999575d0
commit 6dd8fb12ad
4 changed files with 33 additions and 8 deletions

View File

@@ -143,6 +143,7 @@ function baseConvert(util, name, func, options) {
'keys': util.keys,
'rearg': util.rearg,
'spread': util.spread,
'toInteger': util.toInteger,
'toPath': util.toPath
};
@@ -156,6 +157,7 @@ function baseConvert(util, name, func, options) {
keys = helpers.keys,
rearg = helpers.rearg,
spread = helpers.spread,
toInteger = helpers.toInteger,
toPath = helpers.toPath;
var aryMethodKeys = keys(mapping.aryMethod);
@@ -209,10 +211,16 @@ function baseConvert(util, name, func, options) {
return func;
};
},
'nthArg': function(nthArg) {
return function(n) {
var arity = n < 0 ? 1 : (toInteger(n) + 1);
return curry(nthArg(n), arity);
};
},
'rearg': function(rearg) {
return function(func, indexes) {
var n = indexes ? indexes.length : 0;
return curry(rearg(func, indexes), n);
var arity = indexes ? indexes.length : 0;
return curry(rearg(func, indexes), arity);
};
},
'runInContext': function(runInContext) {

View File

@@ -73,10 +73,10 @@ exports.aryMethod = {
'1': [
'assignAll', 'assignInAll', 'attempt', 'castArray', 'ceil', 'create',
'curry', 'curryRight', 'defaultsAll', 'defaultsDeepAll', 'floor', 'flow',
'flowRight', 'fromPairs', 'invert', 'iteratee', 'memoize', 'method',
'mergeAll', 'methodOf', 'mixin', 'over', 'overEvery', 'overSome', 'rest',
'reverse', 'round', 'runInContext', 'spread', 'template', 'trim', 'trimEnd',
'trimStart', 'uniqueId', 'words', 'zipAll'
'flowRight', 'fromPairs', 'invert', 'iteratee', 'memoize', 'method', 'mergeAll',
'methodOf', 'mixin', 'nthArg', 'over', 'overEvery', 'overSome','rest', 'reverse',
'round', 'runInContext', 'spread', 'template', 'trim', 'trimEnd', 'trimStart',
'uniqueId', 'words', 'zipAll'
],
'2': [
'add', 'after', 'ary', 'assign', 'assignAllWith', 'assignIn', 'assignInAllWith',