mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-09 18:37:50 +00:00
Add _.rangeRight docs. [ci skip]
This commit is contained in:
58
lodash.js
58
lodash.js
@@ -1517,10 +1517,10 @@
|
|||||||
* `methodOf`, `mixin`, `modArgs`, `modArgsSet', `negate`, `nthArg`, `omit`,
|
* `methodOf`, `mixin`, `modArgs`, `modArgsSet', `negate`, `nthArg`, `omit`,
|
||||||
* `omitBy`, `once`, `over`, `overEvery`, `overSome`, `partial`, `partialRight`,
|
* `omitBy`, `once`, `over`, `overEvery`, `overSome`, `partial`, `partialRight`,
|
||||||
* `partition`, `pick`, `pickBy`, `plant`, `property`, `propertyOf`, `pull`,
|
* `partition`, `pick`, `pickBy`, `plant`, `property`, `propertyOf`, `pull`,
|
||||||
* `pullAll`, `pullAllBy`, `pullAt`, `push`, `range`, `rearg`, `reject`,
|
* `pullAll`, `pullAllBy`, `pullAt`, `push`, `range`, `rangeRight`, `rearg`,
|
||||||
* `remove`, `rest`, `reverse`, `sampleSize`, `set`, `setWith`, `shuffle`,
|
* `reject`, `remove`, `rest`, `reverse`, `sampleSize`, `set`, `setWith`,
|
||||||
* `slice`, `sort`, `sortBy`, `sortByOrder`, `splice`, `spread`, `tail`,
|
* `shuffle`, `slice`, `sort`, `sortBy`, `sortByOrder`, `splice`, `spread`,
|
||||||
* `take`, `takeRight`, `takeRightWhile`, `takeWhile`, `tap`, `throttle`,
|
* `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, `tap`, `throttle`,
|
||||||
* `thru`, `toArray`, `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`,
|
* `thru`, `toArray`, `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`,
|
||||||
* `transform`, `unary`, `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`,
|
* `transform`, `unary`, `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`,
|
||||||
* `uniqWith`, `unset`, `unshift`, `unzip`, `unzipWith`, `values`, `valuesIn`,
|
* `uniqWith`, `unset`, `unshift`, `unzip`, `unzipWith`, `values`, `valuesIn`,
|
||||||
@@ -3247,6 +3247,16 @@
|
|||||||
return min + nativeFloor(nativeRandom() * (max - min + 1));
|
return min + nativeFloor(nativeRandom() * (max - min + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The base implementation of `_.range` and `_.rangeRight`.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {number} [start=0] The start of the range.
|
||||||
|
* @param {number} end The end of the range.
|
||||||
|
* @param {number} [step=1] The value to increment or decrement by.
|
||||||
|
* @param {boolean} [fromRight] Specify iterating from right to left.
|
||||||
|
* @returns {Array} Returns the new array of numbers.
|
||||||
|
*/
|
||||||
function baseRange(start, end, step, fromRight) {
|
function baseRange(start, end, step, fromRight) {
|
||||||
start = toNumber(start);
|
start = toNumber(start);
|
||||||
start = start === start ? start : 0;
|
start = start === start ? start : 0;
|
||||||
@@ -3268,7 +3278,7 @@
|
|||||||
result[index] = (end -= step);
|
result[index] = (end -= step);
|
||||||
} else {
|
} else {
|
||||||
result[index] = start;
|
result[index] = start;
|
||||||
start+= step;
|
start += step;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@@ -7599,8 +7609,8 @@
|
|||||||
*
|
*
|
||||||
* The guarded methods are:
|
* The guarded methods are:
|
||||||
* `ary`, `curry`, `curryRight`, `drop`, `dropRight`, `every`, `fill`,
|
* `ary`, `curry`, `curryRight`, `drop`, `dropRight`, `every`, `fill`,
|
||||||
* `invert`, `parseInt`, `random`, `range`, `slice`, `some`, `sortBy`,
|
* `invert`, `parseInt`, `random`, `range`, `rangeRight`, `slice`, `some`,
|
||||||
* `take`, `takeRight`, `template`, `trim`, `trimEnd`, `trimStart`,
|
* `sortBy`, `take`, `takeRight`, `template`, `trim`, `trimEnd`, `trimStart`,
|
||||||
* and `words`
|
* and `words`
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
@@ -13309,6 +13319,40 @@
|
|||||||
return baseRange(start, end, step);
|
return baseRange(start, end, step);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method is like `_.range` except that it populates values in
|
||||||
|
* descending order.
|
||||||
|
*
|
||||||
|
* @static
|
||||||
|
* @memberOf _
|
||||||
|
* @category Utility
|
||||||
|
* @param {number} [start=0] The start of the range.
|
||||||
|
* @param {number} end The end of the range.
|
||||||
|
* @param {number} [step=1] The value to increment or decrement by.
|
||||||
|
* @returns {Array} Returns the new array of numbers.
|
||||||
|
* @example
|
||||||
|
*
|
||||||
|
* _.rangeRight(4);
|
||||||
|
* // => [3, 2, 1, 0]
|
||||||
|
*
|
||||||
|
* _.rangeRight(-4);
|
||||||
|
* // => [-3, -2, -1, 0]
|
||||||
|
*
|
||||||
|
* _.rangeRight(1, 5);
|
||||||
|
* // => [4, 3, 2, 1]
|
||||||
|
*
|
||||||
|
* _.rangeRight(0, 20, 5);
|
||||||
|
* // => [15, 10, 5, 0]
|
||||||
|
*
|
||||||
|
* _.rangeRight(0, -4, -1);
|
||||||
|
* // => [-3, -2, -1, 0]
|
||||||
|
*
|
||||||
|
* _.rangeRight(1, 4, 0);
|
||||||
|
* // => [4, 4, 4]
|
||||||
|
*
|
||||||
|
* _.rangeRight(0);
|
||||||
|
* // => []
|
||||||
|
*/
|
||||||
function rangeRight(start, end, step) {
|
function rangeRight(start, end, step) {
|
||||||
if (step && isIterateeCall(start, end, step)) {
|
if (step && isIterateeCall(start, end, step)) {
|
||||||
end = step = undefined;
|
end = step = undefined;
|
||||||
|
|||||||
Reference in New Issue
Block a user