UNPKG

rambda

Version:

Lightweight and faster alternative to Ramda with included TS definitions

21 lines (17 loc) 354 B
export function takeLastWhile(predicate) { return input => { if (input.length === 0) { return input } const toReturn = [] let counter = input.length while (counter) { const item = input[--counter] if (!predicate(item)) { break } toReturn.push(item) } return toReturn.reverse() } }