_castSlice.js 517B

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