您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

_createRange.js 864B

123456789101112131415161718192021222324252627282930
  1. var baseRange = require('./_baseRange'),
  2. isIterateeCall = require('./_isIterateeCall'),
  3. toFinite = require('./toFinite');
  4. /**
  5. * Creates a `_.range` or `_.rangeRight` function.
  6. *
  7. * @private
  8. * @param {boolean} [fromRight] Specify iterating from right to left.
  9. * @returns {Function} Returns the new range function.
  10. */
  11. function createRange(fromRight) {
  12. return function(start, end, step) {
  13. if (step && typeof step != 'number' && isIterateeCall(start, end, step)) {
  14. end = step = undefined;
  15. }
  16. // Ensure the sign of `-0` is preserved.
  17. start = toFinite(start);
  18. if (end === undefined) {
  19. end = start;
  20. start = 0;
  21. } else {
  22. end = toFinite(end);
  23. }
  24. step = step === undefined ? (start < end ? 1 : -1) : toFinite(step);
  25. return baseRange(start, end, step, fromRight);
  26. };
  27. }
  28. module.exports = createRange;