UNPKG

@naturalcycles/js-lib

Version:

Standard library for universal (browser + Node.js) javascript

32 lines (31 loc) 729 B
import type { AnyFunction } from '../types.js'; export interface Cancelable { cancel: () => void; flush: () => void; } export interface ThrottleOptions { /** * @default true */ leading?: boolean; /** * @default true */ trailing?: boolean; } export interface DebounceOptions { /** * @default false */ leading?: boolean; /** * @default true */ trailing?: boolean; /** * */ maxWait?: number; } export declare function _debounce<T extends AnyFunction>(func: T, wait: number, opt?: DebounceOptions): T & Cancelable; export declare function _throttle<T extends AnyFunction>(func: T, wait: number, opt?: ThrottleOptions): T & Cancelable;