import { ref, Ref, watch } from 'vue'; import { useThrottleFn } from './useThrottleFn'; export function useThrottle(value: Ref, delay: number = 200): Readonly> { if (delay <= 0) { return value; } const throttled: Ref = ref(value.value as T) as Ref; const updater = useThrottleFn(() => { throttled.value = value.value; }, delay); watch(value, () => updater()); return throttled; }