# throttle-debounce **Repository Path**: singcl/throttle-debounce ## Basic Information - **Project Name**: throttle-debounce - **Description**: 🌰 throttle and debounce. - **Primary Language**: JavaScript - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2022-01-11 - **Last Updated**: 2022-01-11 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README  # throttle-debounce [](https://www.travis-ci.org/singcl/throttle-debounce) [](https://coveralls.io/github/singcl/throttle-debounce) [](https://github.com/singcl/throttle-debounce) Throttle/debounce your functions. ## 基本用法 - 使用方法一:UMD方式。lib 目录下是用webpack4.x打包的UMD模块,参照UMD模块的使用方法。 - 使用方法二:作为项目的依赖配合打包工具使用。 ```sh npm i @singcl/throttle-debounce --save ``` ```js // 基本用法示例 var throttle = require('@singcl/throttle-debounce/throttle') var debounce = require('@singcl/throttle-debounce/debounce') var throttled = throttle(500, function() { // 该函数为需要节流的目标函数 }) var debounced = debounce(500, function() { // 该函数为需要去抖的目标函数 }) // throttled 和 debounced 就是我们最终需要的函数。 ``` ## API ### throttle #### throttle(delay, callback) | 参数 | 数据类型 | 参数描述 | |:-----:|:-------:|:--------| | delay| Number |节流时间。也就是频率,表示多久触发一次| | callback| Function |目标函数。也就是我们需要节流的函数| **Retrun**: 返回一个已经节流的函数. **Example:** ```html