|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 11 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
421 bytes
|
| Line | |
|---|
| 1 | var initial = require('./initial.js');
|
|---|
| 2 |
|
|---|
| 3 | // Get the first element of an array. Passing **n** will return the first N
|
|---|
| 4 | // values in the array. The **guard** check allows it to work with `_.map`.
|
|---|
| 5 | function first(array, n, guard) {
|
|---|
| 6 | if (array == null || array.length < 1) return n == null || guard ? void 0 : [];
|
|---|
| 7 | if (n == null || guard) return array[0];
|
|---|
| 8 | return initial(array, array.length - n);
|
|---|
| 9 | }
|
|---|
| 10 |
|
|---|
| 11 | module.exports = first;
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.