ramda-extension
Version:
Helpful functions built on top of the mighty Ramda
40 lines (35 loc) • 1.16 kB
JavaScript
;
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _ramda = require("ramda");
var _composeC = _interopRequireDefault(require("./composeC"));
/**
* Returns a new list containing the unique last n elements of a given list,
* passing each value to the supplied predicate function,
* and terminating when the predicate function returns false.
* Excludes the element that caused the predicate function to fail.
* The predicate function is passed one argument: (value).
*
* Acts as a transducer if a transformer is given in list position.
*
* @func
* @category List
*
* @param {function} fn The function called per iteration.
* @param {array} xs The collection to iterate over.
*
* @return {array} New array
*
* @example
*
* R_.uniqTakeLastWhile(x => x !== 4, [1, 2, 3, 4, 3, 2, 1, 1]); // [3, 2, 1]
*
*
* @sig (a -> Boolean) -> [a] -> [a]
*/
var uniqTakeLastWhile = (0, _composeC.default)(_ramda.uniq, _ramda.takeLastWhile);
var _default = uniqTakeLastWhile;
exports.default = _default;