UNPKG

pragmatic-fp-ts

Version:

Opinionated functional programming library with easy use in mind

18 lines (17 loc) 565 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.dropRightWhile = void 0; const main_1 = require("./main"); function dropRightWhile(pred, coll) { if (arguments.length === 1) { return (theColl) => dropRightWhile(pred, theColl); } const theColl = (0, main_1.getValueOr)([], coll); for (let i = theColl.length - 1, j = 0; i >= 0; --i, ++j) { if (!pred(theColl[i])) { return (0, main_1.dropRight)(j, theColl); } } return theColl; } exports.dropRightWhile = dropRightWhile;