Functional
pipe

⛓ Performs left-to-right function composition.

Syntax

import { pipe } from '@opentf/std';
 
pipe(...funcs: Function[]): (val: any) => any;

Parameters

  • ...funcs: The functions to pipe.

Returns

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

Examples

const add2 = (n) => n + 2;
const times3 = (n) => n * 3;
 
const times3ThenAdd2 = pipe(times3, add2);
times3ThenAdd2(5); //=> 17 ( (5 * 3) + 2 )

Related

Try