Throttle and debounce functions.

文档:

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 })

CDN

<!-- 引入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>