UNPKG

@zstings/utils

Version:

javascript、typescript 工具函数库 文档地址 [utils 文档](https://zstings.github.io/utils/)

30 lines (29 loc) 790 B
/** * 节流 * @param func 函数 * @param wait 延迟时间 默认 500毫秒 * @param immediate 是否立即执行 * @throws wait不是number wait存在但不是数字时触发 * @throws immediate不是boolean immediate存在但不是boolean时触发 * @category 函数Function * @example * ```ts * throttle(function () { ... }) * ``` * @example * 自定义时间 * ```ts * throttle(function () { ... }, 300) * ``` * @example * 函数触发时立即执行一次 * ```ts * throttle(function () { ... }, 500, immediate: true) * ``` * @example * 在vue2中使用 * ```ts * getlist: throttle(function () { ... }) * ``` */ export default function throttle(func: (...params: any[]) => any, wait?: number, immediate?: boolean): (this: unknown, ...args: any[]) => void;