b1b6ef008f48ce72b1c092924e88509be3cba9b2f172db83c85f03f8d915c2a879cac90a242d84ffccaa6bbb2821a3f58d8e9d8a135e15358d39f7e426119f 481 B

1234567891011121314151617181920
  1. import isIndex from './_isIndex.js';
  2. /**
  3. * The base implementation of `_.nth` which doesn't coerce arguments.
  4. *
  5. * @private
  6. * @param {Array} array The array to query.
  7. * @param {number} n The index of the element to return.
  8. * @returns {*} Returns the nth element of `array`.
  9. */
  10. function baseNth(array, n) {
  11. var length = array.length;
  12. if (!length) {
  13. return;
  14. }
  15. n += n < 0 ? length : 0;
  16. return isIndex(n, length) ? array[n] : undefined;
  17. }
  18. export default baseNth;