mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-09 10:27:49 +00:00
Add fp.rangeStep and fp.rangeStepRight. [closes #2584]
This commit is contained in:
@@ -108,9 +108,10 @@ exports.aryMethod = {
|
|||||||
'includesFrom', 'indexOfFrom', 'inRange', 'intersectionBy', 'intersectionWith',
|
'includesFrom', 'indexOfFrom', 'inRange', 'intersectionBy', 'intersectionWith',
|
||||||
'invokeArgs', 'invokeArgsMap', 'isEqualWith', 'isMatchWith', 'flatMapDepth',
|
'invokeArgs', 'invokeArgsMap', 'isEqualWith', 'isMatchWith', 'flatMapDepth',
|
||||||
'lastIndexOfFrom', 'mergeWith', 'orderBy', 'padChars', 'padCharsEnd',
|
'lastIndexOfFrom', 'mergeWith', 'orderBy', 'padChars', 'padCharsEnd',
|
||||||
'padCharsStart', 'pullAllBy', 'pullAllWith', 'reduce', 'reduceRight', 'replace',
|
'padCharsStart', 'pullAllBy', 'pullAllWith', 'rangeStep', 'rangeStepRight',
|
||||||
'set', 'slice', 'sortedIndexBy', 'sortedLastIndexBy', 'transform', 'unionBy',
|
'reduce', 'reduceRight', 'replace', 'set', 'slice', 'sortedIndexBy',
|
||||||
'unionWith', 'update', 'xorBy', 'xorWith', 'zipWith'
|
'sortedLastIndexBy', 'transform', 'unionBy', 'unionWith', 'update', 'xorBy',
|
||||||
|
'xorWith', 'zipWith'
|
||||||
],
|
],
|
||||||
'4': [
|
'4': [
|
||||||
'fill', 'setWith', 'updateWith'
|
'fill', 'setWith', 'updateWith'
|
||||||
@@ -189,6 +190,8 @@ exports.methodRearg = {
|
|||||||
'padCharsStart': [2, 1, 0],
|
'padCharsStart': [2, 1, 0],
|
||||||
'pullAllBy': [2, 1, 0],
|
'pullAllBy': [2, 1, 0],
|
||||||
'pullAllWith': [2, 1, 0],
|
'pullAllWith': [2, 1, 0],
|
||||||
|
'rangeStep': [1, 2, 0],
|
||||||
|
'rangeStepRight': [1, 2, 0],
|
||||||
'setWith': [3, 1, 2, 0],
|
'setWith': [3, 1, 2, 0],
|
||||||
'sortedIndexBy': [2, 1, 0],
|
'sortedIndexBy': [2, 1, 0],
|
||||||
'sortedLastIndexBy': [2, 1, 0],
|
'sortedLastIndexBy': [2, 1, 0],
|
||||||
@@ -310,6 +313,8 @@ exports.remap = {
|
|||||||
'padCharsEnd': 'padEnd',
|
'padCharsEnd': 'padEnd',
|
||||||
'padCharsStart': 'padStart',
|
'padCharsStart': 'padStart',
|
||||||
'propertyOf': 'get',
|
'propertyOf': 'get',
|
||||||
|
'rangeStep': 'range',
|
||||||
|
'rangeStepRight': 'rangeRight',
|
||||||
'restFrom': 'rest',
|
'restFrom': 'rest',
|
||||||
'spreadFrom': 'spread',
|
'spreadFrom': 'spread',
|
||||||
'trimChars': 'trim',
|
'trimChars': 'trim',
|
||||||
|
|||||||
@@ -1783,15 +1783,33 @@
|
|||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------------*/
|
||||||
|
|
||||||
QUnit.module('fp.range');
|
QUnit.module('range methods');
|
||||||
|
|
||||||
(function() {
|
_.each(['range', 'rangeRight'], function(methodName) {
|
||||||
QUnit.test('should have an argument order of `start` then `end`', function(assert) {
|
var func = fp[methodName],
|
||||||
|
isRange = methodName == 'range';
|
||||||
|
|
||||||
|
QUnit.test('`_.' + methodName + '` should have an argument order of `start` then `end`', function(assert) {
|
||||||
assert.expect(1);
|
assert.expect(1);
|
||||||
|
|
||||||
assert.deepEqual(fp.range(1)(4), [1, 2, 3]);
|
assert.deepEqual(func(1)(4), isRange ? [1, 2, 3] : [3, 2, 1]);
|
||||||
});
|
});
|
||||||
}());
|
});
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
QUnit.module('rangeStep methods');
|
||||||
|
|
||||||
|
_.each(['rangeStep', 'rangeStepRight'], function(methodName) {
|
||||||
|
var func = fp[methodName],
|
||||||
|
isRange = methodName == 'rangeStep';
|
||||||
|
|
||||||
|
QUnit.test('`_.' + methodName + '` should have an argument order of `step`, `start`, then `end`', function(assert) {
|
||||||
|
assert.expect(1);
|
||||||
|
|
||||||
|
assert.deepEqual(func(2)(1)(4), isRange ? [1, 3] : [3, 1]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user