wrapper function
A function that calls another function, adding behaviour before or after it, such as timing, retries or logging.
In more detail
withMetrics(fn) returns a new function with the same parameters and return type as fn, which Parameters and ReturnType express. Decorators are a class-based form of the same idea.
Related terms
- higher-order function — A function that takes a function as an argument or returns one, such as map, filter or a wrapper that adds retries.
- Parameters<T> — The utility type that gives a function type's parameter list as a tuple, such as [orderId: string, priority: boolean].
- ReturnType<T> — The utility type that gives the return type of a function type T.
- decorator — A line starting with @ placed above a function or class that wraps it to add behaviour or information.
Taught in
- void, undefined And null: Exact Optional Property Types — Production TypeScript
- Function Utilities: ReturnType, Parameters And Constructor — Production TypeScript