Async
aPipe

Performs functions composition from left to right asynchronously.

💡

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

Related

Syntax

import { aPipe } from '@opentf/std';
 
aPipe(
  val: unknown,
  ...fns: Function[]
): Promise<unknown>

Examples

await aPipe(
  "guest",
  (s) => capitalize(s),
  (x) => Promise.resolve(`Welcome ${x}`)
); //=> '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