|
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:
933 bytes
|
| Line | |
|---|
| 1 | var baseSlice = require('./_baseSlice');
|
|---|
| 2 |
|
|---|
| 3 | /**
|
|---|
| 4 | * The base implementation of methods like `_.dropWhile` and `_.takeWhile`
|
|---|
| 5 | * without support for iteratee shorthands.
|
|---|
| 6 | *
|
|---|
| 7 | * @private
|
|---|
| 8 | * @param {Array} array The array to query.
|
|---|
| 9 | * @param {Function} predicate The function invoked per iteration.
|
|---|
| 10 | * @param {boolean} [isDrop] Specify dropping elements instead of taking them.
|
|---|
| 11 | * @param {boolean} [fromRight] Specify iterating from right to left.
|
|---|
| 12 | * @returns {Array} Returns the slice of `array`.
|
|---|
| 13 | */
|
|---|
| 14 | function baseWhile(array, predicate, isDrop, fromRight) {
|
|---|
| 15 | var length = array.length,
|
|---|
| 16 | index = fromRight ? length : -1;
|
|---|
| 17 |
|
|---|
| 18 | while ((fromRight ? index-- : ++index < length) &&
|
|---|
| 19 | predicate(array[index], index, array)) {}
|
|---|
| 20 |
|
|---|
| 21 | return isDrop
|
|---|
| 22 | ? baseSlice(array, (fromRight ? 0 : index), (fromRight ? index + 1 : length))
|
|---|
| 23 | : baseSlice(array, (fromRight ? index + 1 : 0), (fromRight ? length : index));
|
|---|
| 24 | }
|
|---|
| 25 |
|
|---|
| 26 | module.exports = baseWhile;
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.