No Description

last.js 372B

123456789
  1. import rest from './rest.js';
  2. // Get the last element of an array. Passing **n** will return the last N
  3. // values in the array.
  4. export default function last(array, n, guard) {
  5. if (array == null || array.length < 1) return n == null || guard ? void 0 : [];
  6. if (n == null || guard) return array[array.length - 1];
  7. return rest(array, Math.max(0, array.length - n));
  8. }