Skip to main content
Module

x/ramda/composeWith.js

:ram: Practical functional Javascript
Very Popular
Go to Latest
File
import _curry2 from './internal/_curry2';import pipeWith from './pipeWith';import reverse from './reverse';

/** * Performs right-to-left function composition using transforming function. The last argument may have * any arity; the remaining arguments must be unary. * * **Note:** The result of compose is not automatically curried. Transforming function is not used on the * last argument. * * @func * @memberOf R * @category Function * @sig ((* -> *), [(y -> z), (x -> y), ..., (o -> p), ((a, b, ..., n) -> o)]) -> ((a, b, ..., n) -> z) * @param {...Function} ...functions The functions to compose * @return {Function} * @see R.compose, R.pipeWith * @example * * const composeWhileNotNil = R.composeWith((f, res) => R.isNil(res) ? res : f(res)); * * composeWhileNotNil([R.inc, R.prop('age')])({age: 1}) //=> 2 * composeWhileNotNil([R.inc, R.prop('age')])({}) //=> undefined * * @symb R.composeWith(f)([g, h, i])(...args) = f(g, f(h, i(...args))) */var composeWith = _curry2(function composeWith(xf, list) { return pipeWith.apply(this, [xf, reverse(list)]);});export default composeWith;