🧩 Performs right-to-left function composition.

Syntax

TypeScript
import { compose } from '@opentf/std';

compose(...funcs): (...args) => result;

Parameters

  • ...funcs: The functions to compose.

Returns

A new function that represents the composition of the input functions.

Examples

TypeScript
const add2 = (n) => n + 2;
const times3 = (n) => n * 3;

const add2ThenTimes3 = compose(times3, add2);
add2ThenTimes3(5); //=> 21 ( (5 + 2) * 3 )
Last updated on
Edit this page