> For the complete documentation index, see [llms.txt](https://zer0-2.gitbook.io/type-chef-di/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://zer0-2.gitbook.io/type-chef-di/fundamentals/decorators/methodwrapper-key-string.md).

# @MethodWrapper(key: string | Type\<IMethodWrapper>)

```typescript

export class MeasureWrapper implements IMethodWrapper {
    constructor() { // DI will resolve dependencies (type & key injection)
    }

    async run(next: Function, params: any[]) {
        // run code before
        const start = new Date().getTime();
        
        // call original fn
        const res = await next() // (params automatically added)
        
        //run code after
        const end = new Date().getTime();
        const time = end - start;
        console.log(`Execution time: ${time} ms`)
        
        // return fn result
        return res;
    }

}

```

```typescript
 class Test {

    @MeasureWrapper(MyMethodWrapper) // or use registerd string key
    methodWrapper(p1:string, p2: string){
        console.log("original fn: ", p1, p2)
        // ...
    }       
} 

    
```
