Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

_baseWhile.js 933B

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