No Description

first.js 436B

12345678910111213
  1. define(['./initial'], function (initial) {
  2. // Get the first element of an array. Passing **n** will return the first N
  3. // values in the array. The **guard** check allows it to work with `_.map`.
  4. function first(array, n, guard) {
  5. if (array == null || array.length < 1) return n == null || guard ? void 0 : [];
  6. if (n == null || guard) return array[0];
  7. return initial(array, array.length - n);
  8. }
  9. return first;
  10. });