initial.js 361 B

12345678
  1. import { slice } from './_setup.js';
  2. // Returns everything but the last entry of the array. Especially useful on
  3. // the arguments object. Passing **n** will return all the values in
  4. // the array, excluding the last N.
  5. export default function initial(array, n, guard) {
  6. return slice.call(array, 0, Math.max(0, array.length - (n == null || guard ? 1 : n)));
  7. }