# Decorators the Modern Way: Wrapping a Function

When the hub needs the same cache in front of tomorrow's forecast as in front of today's weather, a decorator class per method multiplies again; a function that takes a function and returns a better one adds the feature to any call, and Python's @ and TypeScript's decorators are language shortcuts for that same move, applied where a function or class is defined.

![Cheat sheet: Decorators the Modern Way: Wrapping a Function](https://fsdtrainingmedia.blob.core.windows.net/public/images/2026/11/cb9b51dcba644d4a8e387ed031df5ad2.webp)

- Category: Data Structures
- Level: Journeyman
- Tags: Decorator, Decorator Pattern, Decorators in TypeScript, Higher-Order Function, OOP
- Author: Gregor Dzierzon
- Updated: November 17, 2026

Source: https://www.ask-codey.com/cheat-sheets/dp-decorator-modern-cheat-sheet
