UNPKG

ramda-extension

Version:

Helpful functions built on top of the mighty Ramda

40 lines (35 loc) 1.15 kB
"use strict"; 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 first 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_uniqTakeWhile(x => x !== 4, [1, 2, 2, 1, 3, 4, 3, 2, 1]); // [1, 2, 3] * * * @sig (a -> Boolean) -> [a] -> [a] */ var uniqTakeWhile = (0, _composeC.default)(_ramda.uniq, _ramda.takeWhile); var _default = uniqTakeWhile; exports.default = _default;