UNPKG

@deepkit/core

Version:

Deepkit core library

31 lines (30 loc) 976 B
export declare const nextTick: (cb: () => void) => any; export declare const clearTick: (id: any) => any; /** * Wraps a function and calls it only `cps` times per frame. * * This is handy to throttle all kind of rapid calls, like mouse move events or other kind of events. * * @example * ```typescript * function expensiveFunction() { * //... * } * * const throttled = throttleTime(expensiveFunction, 5); //5 calls per second max * * throttled(); * throttled(); * throttled(); * //throttled will here only be called once * ``` */ export declare function throttleTime(call: Function, cps?: number): (...args: any[]) => void; /** * This functions returns a stack that is filled as long as the gate is not activated. * Once activated all recorded calls go to given callback and subsequent calls go directly to given callback. */ export declare function bufferedGate<T>(callback: (arg: T) => any): { activate: () => void; call: (i: T) => void; };