(method: T, target: any, name: string)
| 54 | |
| 55 | export const profilerWrap = |
| 56 | <T extends AnyFn>(method: T, target: any, name: string) => |
| 57 | (...args: Parameters<T>): ReturnType<T> => { |
| 58 | const start = performance.now(); |
| 59 | const res = method(...args); |
| 60 | if (isPromise(res)) { |
| 61 | res.then( |
| 62 | (_: any) => { |
| 63 | printCost(start, performance.now(), target, name); |
| 64 | return _; |
| 65 | }, |
| 66 | (err: any) => { |
| 67 | printCost(start, performance.now(), target, name); |
| 68 | throw err; |
| 69 | } |
| 70 | ); |
| 71 | } else { |
| 72 | printCost(start, performance.now(), target, name); |
| 73 | } |
| 74 | return res; |
| 75 | }; |
no test coverage detected