What Color Is Your Function

Functions that must be called or handled in a particular way can be thought of as having different colors. The programmer needs to understand the color of functions and this adds complexity (and bugs).

This is particularly bad with callback based control flow (either functions return values or nothing). Promises improves things and async / await is significantly better, but you still can’t call an asynchronous function in a synchronous one, forcing you to structure your program around it.

Read the essay