UNPKG

@extra-array/take-while-right

Version:

Keeps values from right, while a test passes.

12 lines (11 loc) 270 B
'use strict'; function scanWhileRight(x, ft) { for (var i = x.length - 1; i >= 0; i--) if (!ft(x[i], i, x)) break; return i + 1; } function takeWhileRight(x, ft) { return x.slice(scanWhileRight(x, ft)); } module.exports = takeWhileRight;