Start sharing components as a team!Share components as a team!Join Bit to build your applications faster.Get Started Free

drop-last-while

v0.26.1arrow_drop_down
v0.26.1
STATUS
Passing
DOWNLOADS
22
LICENSE
MIT
VISIBILITY
Public
PUBLISHED
7 months ago
SIZE
2 KB
subject
Returns a new list excluding all the tailing elements of a given list which satisfy the supplied predicate function.
1 contributor
Use drop-last-while in your project ?
Copied
npm i @bit/ramda.ramda.drop-last-while
Set Bit as a scoped registryLearn more
npm config set '@bit:registry' https://node.bit.dev
Component Example
React
React
Vue
Angular
Add dependency... help_outline
Just
import
any of the 1 million components
and packages in Bit or NPM to the example.
import Button from '@bit/grommet.grommet.button';
import Lodash from 'lodash';
revert changes
reload
toggle layout
maximize
dropLastWhile(lteThree, [
  1,
  2,
  3,
  4,
  3,
  2,
  1
]);
modifieddraft
chevron_left
chevron_right
dropLastWhile (
predicate:Function,
xs:Array
) : Array

Returns a new list excluding all the tailing elements of a given list which satisfy the supplied predicate function. It passes each value from the right to the supplied predicate function, skipping elements until the predicate function returns a falsy value. The predicate function is applied to one argument: (value).

Acts as a transducer if a transformer is given in list position.

Example
const lteThree = x => x <= 3;

     R.dropLastWhile(lteThree, [1, 2, 3, 4, 3, 2, 1]); //=> [1, 2, 3, 4]

     R.dropLastWhile(x => x !== 'd' , 'Ramda'); //=> 'Ramd'
Arguments
predicate: Function

The function to be called on each element

xs: Array

The collection to iterate over.

Returns
Array

A new array without any trailing elements that return `falsy` values from the `predicate`.