You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

18 lines
517 B

4 years ago
  1. var baseSlice = require('./_baseSlice');
  2. /**
  3. * Casts `array` to a slice if it's needed.
  4. *
  5. * @private
  6. * @param {Array} array The array to inspect.
  7. * @param {number} start The start position.
  8. * @param {number} [end=array.length] The end position.
  9. * @returns {Array} Returns the cast slice.
  10. */
  11. function castSlice(array, start, end) {
  12. var length = array.length;
  13. end = end === undefined ? length : end;
  14. return (!start && end >= length) ? array : baseSlice(array, start, end);
  15. }
  16. module.exports = castSlice;