export declare type DeepPartial = { [P in keyof T]?: DeepPartial; }; export declare type PlainObject = Record; export declare function setValue(obj: O, prop: keyof O, val: O[keyof O]): void; /** * 深拷贝 * @param target 要深拷贝的任意数据(对象字面量、嵌套对象、复杂原生对象等) * @returns 深拷贝之后的数据 */ export declare const cloneDeep: (target: T) => T; /** * 以target为基准compose到origin对象上 * @param {Object} origin 需要被compose的初始对象 * @param {Object} target 目标对象 与origin结构类似的target(会从最上层开始匹配属性) * @returns {void} */ export declare const composeDeep: (origin: PlainObject, target?: PlainObject) => void; /** * @description: 浅度compose,把value属性赋值给state * @param {S} state 被修改对象 * @param {Partial} value 目标数据 * @return {void} */ export declare function composeState(state: S, value: Partial): void; export declare type IsObject = O extends object ? true : false; export declare const isObject: (obj: T) => IsObject; export declare type Procedure = (...args: any[]) => any; export declare type DebounceSettings = { leading?: boolean; trailing?: boolean; maxWait?: number; }; export declare type ThrottleSettings = Omit; export interface DebouncedFunction { (this: ThisParameterType, ...args: Parameters): Promise>; cancel: (reason?: any) => void; } /** * 防抖 * @refer lodash.debounce * @description {@link https://github.com/lodash/lodash/blob/master/debounce.js} * @param {Procedure} func 需要debounce的function * @param {number} wait 延迟执行的时间(ms) * @param {ThrottleSettings} options * @param {boolean | undefined} options.leading * @param {boolean | undefined} options.trailing * @param {number | undefined} options.maxWait 最长等待时间.如果定义了此项,func会在maxWait之后执行 e.g. wait=100,maxWait=200,debouncedfunc每50ms执行一次,则func每200ms执行一次 * @returns {DebouncedFunction} debouncedFunction, 可以使用debouncedFunc.cancel()取消当前的debounce状态 */ export declare function debounce(func: F, wait: number, options?: DebounceSettings): { (this: ThisParameterType, ...args: any[]): any; cancel: () => void; }; /** * 节流 * @param {Procedure} func 需要debounce的function * @param {number} wait 延迟执行的时间(ms) * @param {Options} options * @param {boolean | undefined} options.leading * @param {boolean | undefined} options.trailing * @returns {DebouncedFunction} */ export declare const throttle: (func: F, wait?: number, options?: ThrottleSettings) => { (this: ThisParameterType, ...args: any[]): any; cancel: () => void; };