compose - nodef/extra-function GitHub Wiki

Compose functions together, in applicative order.

Alternatives: compose, composeRight.

function compose(...xs)
// xs: functions (f, g)
const xfunction = require('extra-function');


var fn = xfunction.compose(Math.sqrt, Math.abs);
fn(-64);  // Math.sqrt(Math.abs(-64))
// → 8

var fn = xfunction.compose(Math.sqrt, Math.min);
fn(22, 9);  // Math.sqrt(Math.min(22, 9))
// → 3

References