export function before any>( before: (this: ThisParameterType, ...args: Parameters) => void, target: F ): F { return function (this: ThisParameterType, ...args: Parameters): ReturnType { before.call(this, ...args); return target.apply(this, args); } as F; } export function around any>( target: F, around: (target: F, ...args: Parameters) => ReturnType ): F { return function (this: ThisParameterType, ...args: Parameters): ReturnType { return around.call(this, target, ...args); } as F; } export function after any>( target: F, after: (this: ThisParameterType, ...args: Parameters) => void ): F { return function (this: ThisParameterType, ...args: Parameters): ReturnType { let result = target.apply(this, args); after.call(this, ...args); return result; } as F; } export function setMinTimeout(beginTime: number | Date, callback: () => void, minTimeout: number = 1500): void { if (beginTime instanceof Date) { beginTime = beginTime.getTime() as any; } const dTime = new Date().getTime() - (beginTime as any); if (dTime > minTimeout) { callback(); } else { setTimeout(callback, minTimeout - dTime); } }