mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-13 04:17:49 +00:00
Cleanup fp mapping and tests.
This commit is contained in:
@@ -73,21 +73,22 @@ module.exports = {
|
|||||||
/** Used to map ary to method names. */
|
/** Used to map ary to method names. */
|
||||||
'aryMethodMap': {
|
'aryMethodMap': {
|
||||||
1: (
|
1: (
|
||||||
'attempt,ceil,create,curry,curryRight,floor,fromPairs,iteratee,invert,over,overEvery,' +
|
'attempt,ceil,create,curry,curryRight,floor,fromPairs,iteratee,invert,over,' +
|
||||||
'overSome,memoize,method,methodOf,mixin,rest,reverse,round,runInContext,sample,template,' +
|
'overEvery,overSome,memoize,method,methodOf,mixin,rest,reverse,round,' +
|
||||||
'trim,trimLeft,trimRight,uniqueId,words').split(','),
|
'runInContext,template,trim,trimLeft,trimRight,uniqueId,words').split(','),
|
||||||
2: (
|
2: (
|
||||||
'add,ary,assign,at,bind,bindKey,cloneDeepWith,cloneWith,concat,countBy,curryN,curryRightN,' +
|
'add,ary,assign,at,bind,bindKey,cloneDeepWith,cloneWith,concat,countBy,curryN,' +
|
||||||
'debounce,defaults,defaultsDeep,delay,difference,drop,dropRight,dropRightWhile,' +
|
'curryRightN,debounce,defaults,defaultsDeep,delay,difference,drop,dropRight,' +
|
||||||
'dropWhile,endsWith,every,extend,filter,find,find,findIndex,findKey,findLast,' +
|
'dropRightWhile,dropWhile,endsWith,every,extend,filter,find,find,findIndex,' +
|
||||||
'findLastIndex,findLastKey,flatMap,forEach,forEachRight,forIn,forInRight,' +
|
'findKey,findLast,findLastIndex,findLastKey,flatMap,forEach,forEachRight,' +
|
||||||
'forOwn,forOwnRight,get,groupBy,includes,indexBy,indexOf,intersection,invoke,' +
|
'forIn,forInRight,forOwn,forOwnRight,get,groupBy,includes,indexBy,indexOf,' +
|
||||||
'invokeMap,isMatch,lastIndexOf,map,mapKeys,mapValues,matchesProperty,maxBy,' +
|
'intersection,invoke,invokeMap,isMatch,lastIndexOf,map,mapKeys,mapValues,' +
|
||||||
'mean,minBy,merge,omit,overArgs,pad,padLeft,padRight,parseInt,partition,' +
|
'matchesProperty,maxBy,mean,minBy,merge,omit,overArgs,pad,padLeft,padRight,' +
|
||||||
'pick,pull,pullAll,pullAt,random,range,rangeRight,rearg,reject,remove,repeat,' +
|
'parseInt,partition,pick,pull,pullAll,pullAt,random,range,rangeRight,rearg,' +
|
||||||
'result,sampleSize,some,sortBy,sortByOrder,sortedIndexBy,sortedLastIndexBy,' +
|
'reject,remove,repeat,result,sampleSize,some,sortBy,sortByOrder,sortedIndexBy,' +
|
||||||
'sortedUniqBy,startsWith,subtract,sumBy,take,takeRight,takeRightWhile,takeWhile,' +
|
'sortedLastIndexBy,sortedUniqBy,startsWith,subtract,sumBy,take,takeRight,' +
|
||||||
'throttle,times,truncate,union,uniqBy,without,wrap,xor,zip,zipObject').split(','),
|
'takeRightWhile,takeWhile,throttle,times,truncate,union,uniqBy,without,wrap,' +
|
||||||
|
'xor,zip,zipObject').split(','),
|
||||||
3: (
|
3: (
|
||||||
'assignWith,clamp,differenceBy,extendWith,getOr,inRange,intersectionBy,' +
|
'assignWith,clamp,differenceBy,extendWith,getOr,inRange,intersectionBy,' +
|
||||||
'isEqualWith,isMatchWith,mergeWith,omitBy,pickBy,pullAllBy,reduce,' +
|
'isEqualWith,isMatchWith,mergeWith,omitBy,pickBy,pullAllBy,reduce,' +
|
||||||
@@ -120,8 +121,7 @@ module.exports = {
|
|||||||
'keyMap': {
|
'keyMap': {
|
||||||
'curryN': 'curry',
|
'curryN': 'curry',
|
||||||
'curryRightN': 'curryRight',
|
'curryRightN': 'curryRight',
|
||||||
'getOr': 'get',
|
'getOr': 'get'
|
||||||
'sampleSize': 'sample'
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/** Used to identify methods which mutate arrays or objects. */
|
/** Used to identify methods which mutate arrays or objects. */
|
||||||
|
|||||||
@@ -300,67 +300,32 @@
|
|||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------------*/
|
||||||
|
|
||||||
QUnit.module('fp.curry');
|
QUnit.module('curry methods');
|
||||||
|
|
||||||
(function() {
|
_.each(['curry', 'curryRight'], function(methodName) {
|
||||||
QUnit.test('should accept only a `func` param', function(assert) {
|
var func = fp[methodName];
|
||||||
|
|
||||||
|
QUnit.test('`_.' + methodName + '` should only accept a `func` param', function(assert) {
|
||||||
assert.expect(1);
|
assert.expect(1);
|
||||||
|
|
||||||
assert.raises(function() { fp.curry(1, _.noop); }, TypeError);
|
assert.raises(function() { func(1, _.noop); }, TypeError);
|
||||||
});
|
});
|
||||||
}());
|
});
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------------*/
|
||||||
|
|
||||||
QUnit.module('fp.curryN');
|
QUnit.module('curryN methods');
|
||||||
|
|
||||||
(function() {
|
_.each(['curryN', 'curryRightN'], function(methodName) {
|
||||||
QUnit.test('should accept an `arity` param', function(assert) {
|
var func = fp[methodName];
|
||||||
|
|
||||||
|
QUnit.test('`_.' + methodName + '` accept an `arity` param', function(assert) {
|
||||||
assert.expect(1);
|
assert.expect(1);
|
||||||
|
|
||||||
var actual = fp.curryN(1, function(a, b) { return [a, b]; })('a');
|
var actual = func(1, function(a, b) { return [a, b]; })('a');
|
||||||
assert.deepEqual(actual, ['a', undefined]);
|
assert.deepEqual(actual, ['a', undefined]);
|
||||||
});
|
});
|
||||||
|
});
|
||||||
QUnit.test('should only pass in `arity` number of arguments', function(assert) {
|
|
||||||
assert.expect(1);
|
|
||||||
|
|
||||||
var actual = fp.curryN(1, function(a, b) { return [a, b]; })('a', 'b');
|
|
||||||
assert.deepEqual(actual, ['a', undefined]);
|
|
||||||
});
|
|
||||||
}());
|
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
QUnit.module('fp.curryRight');
|
|
||||||
|
|
||||||
(function() {
|
|
||||||
QUnit.test('should accept only a `func` param', function(assert) {
|
|
||||||
assert.expect(1);
|
|
||||||
|
|
||||||
assert.raises(function() { fp.curryRight(1, _.noop); }, TypeError);
|
|
||||||
});
|
|
||||||
}());
|
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
QUnit.module('fp.curryRightN');
|
|
||||||
|
|
||||||
(function() {
|
|
||||||
QUnit.test('should accept an `arity` param', function(assert) {
|
|
||||||
assert.expect(1);
|
|
||||||
|
|
||||||
var actual = fp.curryRightN(1, function(a, b) { return [a, b]; })('a');
|
|
||||||
assert.deepEqual(actual, ['a', undefined]);
|
|
||||||
});
|
|
||||||
|
|
||||||
QUnit.test('should only pass in `arity` number of arguments', function(assert) {
|
|
||||||
assert.expect(1);
|
|
||||||
|
|
||||||
var actual = fp.curryRightN(1, function(a, b) { return [a, b]; })('a', 'b');
|
|
||||||
assert.deepEqual(actual, ['a', undefined]);
|
|
||||||
});
|
|
||||||
}());
|
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user