'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var _baseRange = require('./_baseRange.js');
var _isIterateeCall = require('./_isIterateeCall.js');
var toFinite = require('./toFinite.js');

/**
 * Creates a `_.range` or `_.rangeRight` function.
 *
 * @private
 * @param {boolean} [fromRight] Specify iterating from right to left.
 * @returns {Function} Returns the new range function.
 */
function createRange(fromRight) {
  return function(start, end, step) {
    if (step && typeof step != 'number' && _isIterateeCall.default(start, end, step)) {
      end = step = undefined;
    }
    // Ensure the sign of `-0` is preserved.
    start = toFinite.default(start);
    if (end === undefined) {
      end = start;
      start = 0;
    } else {
      end = toFinite.default(end);
    }
    step = step === undefined ? (start < end ? 1 : -1) : toFinite.default(step);
    return _baseRange.default(start, end, step);
  };
}

exports.default = createRange;
