1 import type { Callback } from '@proton/pass/types';
3 type WithPerformanceOptions = {
5 onMaxTime: (ms: number) => void;
8 export const withMaxExecutionTime = <F extends Callback>(fn: F, options: WithPerformanceOptions): F =>
10 const start = performance.now();
11 const result = fn(...args);
12 const end = performance.now();
14 const ms = end - start;
15 if (ms >= options.maxTime) options.onMaxTime(ms);