Async
aPipeFn

Returns a function that performs functions composition from left to right asynchronously.

💡

The pipe function is equivalent to c(b(a(val))).

Related

Syntax

import { aPipeFn } from '@opentf/std';
 
aPipeFn(
  ...fns: Function[]
): (...args: unknown[]) => unknown

Examples

const transform = aPipeFn(
  (s) => capitalize(s),
  (x) => Promise.resolve(`Welcome ${x}`),
  (x) => Promise.resolve(`${x}...`)
);
await transform("guest"); //=> 'Welcome Guest...'

Try

Learn

Why we need function composition?

  • The deep nesting of functions is hard to read.
  • It eliminates temporary variables.
  • Method chaining is limited, for Eg: await, yeild, etc.

Resources