range.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. var createRange = require('./_createRange');
  2. /**
  3. * Creates an array of numbers (positive and/or negative) progressing from
  4. * `start` up to, but not including, `end`. A step of `-1` is used if a negative
  5. * `start` is specified without an `end` or `step`. If `end` is not specified,
  6. * it's set to `start` with `start` then set to `0`.
  7. *
  8. * **Note:** JavaScript follows the IEEE-754 standard for resolving
  9. * floating-point values which can produce unexpected results.
  10. *
  11. * @static
  12. * @since 0.1.0
  13. * @memberOf _
  14. * @category Util
  15. * @param {number} [start=0] The start of the range.
  16. * @param {number} end The end of the range.
  17. * @param {number} [step=1] The value to increment or decrement by.
  18. * @returns {Array} Returns the range of numbers.
  19. * @see _.inRange, _.rangeRight
  20. * @example
  21. *
  22. * _.range(4);
  23. * // => [0, 1, 2, 3]
  24. *
  25. * _.range(-4);
  26. * // => [0, -1, -2, -3]
  27. *
  28. * _.range(1, 5);
  29. * // => [1, 2, 3, 4]
  30. *
  31. * _.range(0, 20, 5);
  32. * // => [0, 5, 10, 15]
  33. *
  34. * _.range(0, -4, -1);
  35. * // => [0, -1, -2, -3]
  36. *
  37. * _.range(1, 4, 0);
  38. * // => [1, 1, 1]
  39. *
  40. * _.range(0);
  41. * // => []
  42. */
  43. var range = createRange();
  44. module.exports = range;