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

32 行
843 B

4 年前
  1. var toInteger = require('./toInteger'),
  2. toLength = require('./toLength');
  3. /**
  4. * The base implementation of `_.fill` without an iteratee call guard.
  5. *
  6. * @private
  7. * @param {Array} array The array to fill.
  8. * @param {*} value The value to fill `array` with.
  9. * @param {number} [start=0] The start position.
  10. * @param {number} [end=array.length] The end position.
  11. * @returns {Array} Returns `array`.
  12. */
  13. function baseFill(array, value, start, end) {
  14. var length = array.length;
  15. start = toInteger(start);
  16. if (start < 0) {
  17. start = -start > length ? 0 : (length + start);
  18. }
  19. end = (end === undefined || end > length) ? length : toInteger(end);
  20. if (end < 0) {
  21. end += length;
  22. }
  23. end = start > end ? 0 : toLength(end);
  24. while (start < end) {
  25. array[start++] = value;
  26. }
  27. return array;
  28. }
  29. module.exports = baseFill;