index.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /**
  2. * lodash (Custom Build) <https://lodash.com/>
  3. * Build: `lodash modularize exports="npm" -o ./`
  4. * Copyright jQuery Foundation and other contributors <https://jquery.org/>
  5. * Released under MIT license <https://lodash.com/license>
  6. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  7. * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  8. */
  9. /**
  10. * The base implementation of `_.slice` without an iteratee call guard.
  11. *
  12. * @private
  13. * @param {Array} array The array to slice.
  14. * @param {number} [start=0] The start position.
  15. * @param {number} [end=array.length] The end position.
  16. * @returns {Array} Returns the slice of `array`.
  17. */
  18. function baseSlice(array, start, end) {
  19. var index = -1,
  20. length = array.length;
  21. if (start < 0) {
  22. start = -start > length ? 0 : (length + start);
  23. }
  24. end = end > length ? length : end;
  25. if (end < 0) {
  26. end += length;
  27. }
  28. length = start > end ? 0 : ((end - start) >>> 0);
  29. start >>>= 0;
  30. var result = Array(length);
  31. while (++index < length) {
  32. result[index] = array[index + start];
  33. }
  34. return result;
  35. }
  36. /**
  37. * Gets all but the first element of `array`.
  38. *
  39. * @static
  40. * @memberOf _
  41. * @since 4.0.0
  42. * @category Array
  43. * @param {Array} array The array to query.
  44. * @returns {Array} Returns the slice of `array`.
  45. * @example
  46. *
  47. * _.tail([1, 2, 3]);
  48. * // => [2, 3]
  49. */
  50. function tail(array) {
  51. var length = array ? array.length : 0;
  52. return length ? baseSlice(array, 1, length) : [];
  53. }
  54. module.exports = tail;