-
Notifications
You must be signed in to change notification settings - Fork 0
compose
Subhajit Sahu edited this page Aug 7, 2022
·
1 revision
Compose functions together, in applicative order.
Alternatives: compose, composeRight.
function compose(...xs)
// xs: functions (f, g)
const xasyncfn = require('extra-async-function');
var fn = xasyncfn.compose(Math.sqrt, async x => Math.abs(x));
await fn(-64); // Math.sqrt(Math.abs(-64))
// → 8
var fn = xasyncfn.compose(Math.sqrt, Math.min);
await fn(22, 9); // Math.sqrt(Math.min(22, 9))
// → 3