Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

_baseFill.js 843B

1234567891011121314151617181920212223242526272829303132
  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;