MCPcopy
hub / github.com/lodash/lodash / createRange

Function createRange

lodash.js:5422–5438  ·  view source on GitHub ↗

* Creates a `_.range` or `_.rangeRight` function. * * @private * @param {boolean} [fromRight] Specify iterating from right to left. * @returns {Function} Returns the new range function.

(fromRight)

Source from the content-addressed store, hash-verified

5420 * @returns {Function} Returns the new range function.
5421 */
5422 function createRange(fromRight) {
5423 return function(start, end, step) {
5424 if (step && typeof step != 'number' && isIterateeCall(start, end, step)) {
5425 end = step = undefined;
5426 }
5427 // Ensure the sign of `-0` is preserved.
5428 start = toFinite(start);
5429 if (end === undefined) {
5430 end = start;
5431 start = 0;
5432 } else {
5433 end = toFinite(end);
5434 }
5435 step = step === undefined ? (start < end ? 1 : -1) : toFinite(step);
5436 return baseRange(start, end, step, fromRight);
5437 };
5438 }
5439
5440 /**
5441 * Creates a function that performs a relational operation on two values.

Callers 1

lodash.jsFile · 0.85

Calls 3

isIterateeCallFunction · 0.85
toFiniteFunction · 0.85
baseRangeFunction · 0.85

Tested by

no test coverage detected