compose function

Compose multiple functions together.

Example

const process = compose(
  (s: string) => s.toUpperCase(),
  (s: string) => s.trim()
);
process("  hello  ") // "HELLO"

Signature

compose(...fns: (x: any) => any[]): (x: any) => any

Parameters

fns

Functions to compose (right-to-left)

Returns

Composed function