decoratorfunction

noun
UK /ˈdɛkəreɪtə ˈfʌŋkʃən/
US /ˈdɛkəreɪtər ˈfʌŋkʃən/

A decorator function is a helper that wraps another function to add something extra to it.

The programmer used a decorator function to make the code log every time the main function ran.


OTHER MEANINGS

2. A function that changes how another function behaves without editing its code.

She added a decorator function to check permissions before the request handler ran.

3. In Python, a callable that takes a function and returns a new function.

The @timer decorator function measured how long the task took.

4. A tool that adds features like caching or logging around an existing routine.

They wrote a decorator function to cache results and speed up the app.