⛓ Performs left-to-right function composition.

Syntax

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

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

Parameters

  • ...funcs: The functions to pipe.

Returns

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

Examples

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

const times3ThenAdd2 = pipe(times3, add2);
times3ThenAdd2(5); //=> 17 ( (5 * 3) + 2 )
Last updated on
Edit this page