How to use the takeLastWhile function from ramda

Find comprehensive JavaScript ramda.takeLastWhile code examples handpicked from public code repositorys.

4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
 * @see R.dropLastWhile, R.addIndex
 * @example
 *
 *      var isNotOne = x => x !== 1;
 *
 *      R.takeLastWhile(isNotOne, [1, 2, 3, 4]); //=> [2, 3, 4]
 */
var takeLastWhile = _curry2(function takeLastWhile(fn, list) {
    var idx = list.length - 1;
    while (idx >= 0 && fn(list[idx])) {
fork icon0
star icon0
watch icon0

+ 17 other calls in file

13314
13315
13316
13317
13318
13319
13320
13321
13322
13323
13324
13325
 *
 *      const isNotOne = x => x !== 1;
 *
 *      R.takeLastWhile(isNotOne, [1, 2, 3, 4]); //=> [2, 3, 4]
 *
 *      R.takeLastWhile(x => x !== 'R' , 'Ramda'); //=> 'amda'
 */




var takeLastWhile =
fork icon0
star icon0
watch icon2

+ 7 other calls in file

14
15
16
17
18
19
20
21
22
23
24
25
const isValidBy = (rate, log) => {
  const { limit, interval } = rate


  const winFor = (acc, next) => {
    const isIncluded = R.lte(next - interval)
    const list = R.takeLastWhile(isIncluded, acc)


    return R.append(next, list)
  }

fork icon0
star icon0
watch icon0

22
23
24
25
26
27
28
29
30
31
32
33
34


const checkCapacity = (opts, history) => {
  const { limit, interval } = opts


  const t0 = Date.now() - interval
  const tail = R.takeLastWhile(time => time > t0, history)


  return tail.length < limit
}

fork icon0
star icon0
watch icon0

Other functions in ramda

Sorted by popularity

function icon

ramda.clone is the most popular function in ramda (30311 examples)