dropLastWhile.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import _curry2 from "./internal/_curry2.js";
  2. import _dispatchable from "./internal/_dispatchable.js";
  3. import _dropLastWhile from "./internal/_dropLastWhile.js";
  4. import _xdropLastWhile from "./internal/_xdropLastWhile.js";
  5. /**
  6. * Returns a new list excluding all the tailing elements of a given list which
  7. * satisfy the supplied predicate function. It passes each value from the right
  8. * to the supplied predicate function, skipping elements until the predicate
  9. * function returns a `falsy` value. The predicate function is applied to one argument:
  10. * *(value)*.
  11. *
  12. * Acts as a transducer if a transformer is given in list position.
  13. *
  14. * @func
  15. * @memberOf R
  16. * @since v0.16.0
  17. * @category List
  18. * @sig (a -> Boolean) -> [a] -> [a]
  19. * @sig (a -> Boolean) -> String -> String
  20. * @param {Function} predicate The function to be called on each element
  21. * @param {Array} xs The collection to iterate over.
  22. * @return {Array} A new array without any trailing elements that return `falsy` values from the `predicate`.
  23. * @see R.takeLastWhile, R.addIndex, R.drop, R.dropWhile
  24. * @example
  25. *
  26. * const lteThree = x => x <= 3;
  27. *
  28. * R.dropLastWhile(lteThree, [1, 2, 3, 4, 3, 2, 1]); //=> [1, 2, 3, 4]
  29. *
  30. * R.dropLastWhile(x => x !== 'd' , 'Ramda'); //=> 'Ramd'
  31. */
  32. var dropLastWhile =
  33. /*#__PURE__*/
  34. _curry2(
  35. /*#__PURE__*/
  36. _dispatchable([], _xdropLastWhile, _dropLastWhile));
  37. export default dropLastWhile;