Async
aComposeFn

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

💡

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

Related

Syntax

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

Examples

const transform = aComposeFn((x) => Promise.resolve(Math.ceil(x)), Math.pow);
await transform(1.5, 2.5); //=> 3

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