You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

20 lines
555 B

4 months ago
/**
*
*/
export function timer(label?: string) {
const debug = localStorage.getItem('__debug__');
return (target: any, propertyKey: string, descriptor: PropertyDescriptor) => {
const timerLabel = `[${propertyKey}] ${label}`;
const func = descriptor.value;
if (typeof func === 'function') {
// eslint-disable-next-line
descriptor.value = function (...args: any[]) {
debug && console.time(timerLabel);
func.apply(this, args);
debug && console.timeEnd(timerLabel);
};
}
};
}