Ohm-Management - Projektarbeit B-ME
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.

slice.js 1.0KB

12345678910111213141516171819202122232425262728293031323334353637
  1. var baseSlice = require('./_baseSlice'),
  2. isIterateeCall = require('./_isIterateeCall'),
  3. toInteger = require('./toInteger');
  4. /**
  5. * Creates a slice of `array` from `start` up to, but not including, `end`.
  6. *
  7. * **Note:** This method is used instead of
  8. * [`Array#slice`](https://mdn.io/Array/slice) to ensure dense arrays are
  9. * returned.
  10. *
  11. * @static
  12. * @memberOf _
  13. * @since 3.0.0
  14. * @category Array
  15. * @param {Array} array The array to slice.
  16. * @param {number} [start=0] The start position.
  17. * @param {number} [end=array.length] The end position.
  18. * @returns {Array} Returns the slice of `array`.
  19. */
  20. function slice(array, start, end) {
  21. var length = array == null ? 0 : array.length;
  22. if (!length) {
  23. return [];
  24. }
  25. if (end && typeof end != 'number' && isIterateeCall(array, start, end)) {
  26. start = 0;
  27. end = length;
  28. }
  29. else {
  30. start = start == null ? 0 : toInteger(start);
  31. end = end === undefined ? length : toInteger(end);
  32. }
  33. return baseSlice(array, start, end);
  34. }
  35. module.exports = slice;