Throttle and debounce functions.
文档:
https://github.com/niksy/throttle-debounce
https://www.npmjs.com/package/throttle-debounce
https://www.jsdelivr.com/package/npm/throttle-debounce
Node.js
安装
npm install throttle-debounce --save
示例
import { throttle, debounce } from 'throttle-debounce'; // delay 100 or 250 throttle(delay, callback, { noLeading=false, noTrailing=false, debounceMode }) debounce(delay, callback, { atBegin=false })
<!-- 引入throttle-debounce --> <script src="https://cdn.jsdelivr.net/npm/throttle-debounce@5.0.0/umd/index.min.js"></script> <script> const throttleFunc = throttleDebounce.throttle(1000, ()=>{}); const debounceFunc = throttleDebounce.debounce(1000, ()=>{}); </script>