concept composition in category angular

appears as: composition
Getting MEAN with Mongo, Express, Angular, and Node.js 2ED

This is an excerpt from Manning's book Getting MEAN with Mongo, Express, Angular, and Node.js 2ED.

Some libraries provide a function called compose that allows you to handle composition in a more elegant way, although this function isn’t difficult to build by hand. The basic principle is the simple application of the mathematical formula g(f(x)).

Listing D.62. compose function
const compose = (g, f) => x => g(f(x));     #1

const composedCompute = compose(            #2
  multiplyBy10,
  add(2)
);

const result = composedCompute(5);          #3

Beyond these small examples, composition is a tool that can make your code cleaner and easier to understand.