diff --git a/lib/fp/baseConvert.js b/lib/fp/baseConvert.js index 3c50222b3..5d9c305c8 100644 --- a/lib/fp/baseConvert.js +++ b/lib/fp/baseConvert.js @@ -99,7 +99,10 @@ function baseConvert(util, name, func) { var wrappers = { 'iteratee': function(iteratee) { - return function(func, arity) { + return function() { + var func = arguments[0], + arity = arguments[1]; + arity = arity > 2 ? (arity - 2) : 1; func = iteratee(func); var length = func.length; diff --git a/lib/fp/mapping.js b/lib/fp/mapping.js index b3df474f0..916a5b92a 100644 --- a/lib/fp/mapping.js +++ b/lib/fp/mapping.js @@ -74,31 +74,42 @@ module.exports = { /** Used to map ary to method names. */ 'aryMethod': { - 1: ( - 'attempt,ceil,create,curry,curryRight,floor,fromPairs,iteratee,invert,over,' + - 'overEvery,overSome,memoize,method,methodOf,mixin,rest,reverse,round,' + - 'runInContext,template,trim,trimLeft,trimRight,uniqueId,words').split(','), - 2: ( - 'add,ary,assign,at,bind,bindKey,chunk,cloneDeepWith,cloneWith,concat,countBy,', - 'curryN,curryRightN,debounce,defaults,defaultsDeep,delay,difference,drop,' + - 'dropRight,dropRightWhile,dropWhile,endsWith,eq,every,extend,filter,find,' + - 'find,findIndex,findKey,findLast,findLastIndex,findLastKey,flatMap,forEach,' + - 'forEachRight,forIn,forInRight,forOwn,forOwnRight,get,groupBy,gt,gte,has,' + - 'hasIn,includes,indexBy,indexOf,intersection,invoke,invokeMap,isEqual,' + - 'isMatch,lastIndexOf,lt,lte,map,mapKeys,mapValues,matchesProperty,maxBy,' + - 'mean,minBy,merge,omit,orderBy,overArgs,pad,padLeft,padRight,parseInt,' + - 'partition,pick,pull,pullAll,pullAt,random,range,rangeRight,rearg,reject,' + - 'remove,repeat,result,sampleSize,some,sortBy,sortedIndexBy,sortedLastIndexBy,' + - 'sortedUniqBy,split,startsWith,subtract,sumBy,take,takeRight,takeRightWhile,' + - 'takeWhile,throttle,times,truncate,union,uniqBy,uniqWith,without,wrap,xor,' + - 'zip,zipObject').split(','), - 3: ( - 'assignWith,assignInWith,clamp,differenceBy,differenceWith,getOr,inRange,' + - 'intersectionBy,intersectionWith,isEqualWith,isMatchWith,mergeWith,omitBy,' + - 'pickBy,pullAllBy,reduce,reduceRight,replace,set,slice,transform,unionBy,' + - 'unionWith,xorBy,xorWith,zipWith').split(','), - 4: - ['fill', 'setWith'] + 1:[ + 'attempt', 'ceil', 'create', 'curry', 'curryRight', 'floor', 'fromPairs', + 'invert', 'iteratee', 'memoize', 'method', 'methodOf', 'mixin', 'over', + 'overEvery', 'overSome', 'rest', 'reverse', 'round', 'runInContext', + 'template', 'trim', 'trimEnd', 'trimStart', 'uniqueId', 'unset', 'words' + ], + 2:[ + 'add', 'after', 'ary', 'assign', 'at', 'before', 'bind', 'bindKey', + 'chunk', 'cloneDeepWith', 'cloneWith', 'concat', 'countBy', 'curryN', + 'curryRightN', 'debounce', 'defaults', 'defaultsDeep', 'delay', 'difference', + 'drop', 'dropRight', 'dropRightWhile', 'dropWhile', 'endsWith', 'eq', + 'every', 'extend', 'filter', 'find', 'find', 'findIndex', 'findKey', + 'findLast', 'findLastIndex', 'findLastKey', 'flatMap', 'forEach', + 'forEachRight', 'forIn', 'forInRight', 'forOwn', 'forOwnRight', 'get', + 'groupBy', 'gt', 'gte', 'has', 'hasIn', 'includes', 'indexOf', 'intersection', + 'invoke', 'invokeMap', 'isEqual', 'isMatch', 'join', 'keyBy', 'lastIndexOf', + 'lt', 'lte', 'map', 'mapKeys', 'mapValues', 'matchesProperty', 'maxBy', + 'mean', 'merge', 'minBy', 'omit', 'orderBy', 'overArgs', 'pad', 'padEnd', + 'padStart', 'parseInt', 'partition', 'pick', 'pull', 'pullAll', 'pullAt', + 'random', 'range', 'rangeRight', 'rearg', 'reject', 'remove', 'repeat', + 'result', 'sampleSize', 'some', 'sortBy', 'sortedIndex', 'sortedIndexOf', + 'sortedLastIndex', 'sortedLastIndexOf', 'sortedUniqBy', 'split', 'startsWith', + 'subtract', 'sumBy', 'take', 'takeRight', 'takeRightWhile', 'takeWhile', + 'tap', 'throttle', 'thru', 'times', 'truncate', 'union', 'uniqBy', 'uniqWith', + 'unzipWith', 'without', 'wrap', 'xor', 'zip', 'zipObject' + ], + 3:[ + 'assignInWith', 'assignWith', 'clamp', 'differenceBy', 'differenceWith', + 'getOr', 'inRange', 'intersectionBy', 'intersectionWith', 'isEqualWith', + 'isMatchWith', 'mergeWith', 'omitBy', 'pickBy', 'pullAllBy', 'reduce', + 'reduceRight', 'replace', 'set', 'slice', 'sortedIndexBy', 'sortedLastIndexBy', + 'transform', 'unionBy', 'unionWith', 'xorBy', 'xorWith', 'zipWith' + ], + 4:[ + 'fill', 'setWith' + ] }, /** Used to map ary to rearg configs by method ary. */ @@ -119,7 +130,7 @@ module.exports = { 'transform': [2, 0, 1] }, - /** Used to iterate `mapping.aryMethodMap` keys. */ + /** Used to iterate `mapping.aryMethod` keys. */ 'caps': [1, 2, 3, 4], /** Used to map keys to other keys. */ diff --git a/test/test-fp.js b/test/test-fp.js index 3ee4e07e3..e60223626 100644 --- a/test/test-fp.js +++ b/test/test-fp.js @@ -67,6 +67,22 @@ console.log('Running lodash/fp tests.'); + QUnit.module('method arity checks'); + + (function() { + QUnit.test('should wrap methods with an arity > `1`', function(assert) { + assert.expect(1); + + var methodNames = _.filter(_.functions(fp), function(methodName) { + return fp[methodName].length > 1; + }); + + assert.deepEqual(methodNames, []); + }); + }()); + + /*--------------------------------------------------------------------------*/ + QUnit.module('method aliases'); (function() {