Search⌘ K

Combining Currying and Composition

Explore how currying and composition work together to combine functions with varying parameters. Understand how to transform multi-argument functions into composable units in TypeScript to write cleaner functional code.

Function with one parameter value

Composing is easy when we have a scenario like this:

  • Function ONE accepts a parameter of type A and returns a value of type B.
  • Function TWO accepts a parameter of type B and returns a value of type C.
  • Function THREE accepts a parameter of type C and returns a value of type D.

Note how function TWO needs a value that function ONE can provide, while function THREE needs a value produced by function TWO. This means that these functions can be ...