Throttle and debounce functions.
npm install zwlcommonutils --save
import { debouncingA, debouncingB, throttleA, throttleB } from 'zwlutils';
const throttleFunc1 = debouncingA( // or (debouncingB, throttleA, throttleB)
(num) => {
console.log('num:', num);
},
1000);
throttleFunc1()
// ================================================================
function fn(e){
console.log(e)
}
const throttleFunc2 = debouncingA(fn,1000) // or (debouncingB, throttleA, throttleB)
throttleFunc2()
// debouncingA 防抖 立即执行
// debouncingB 防抖 非立即执行
// throttleA 节流 立即执行
// throttleB 节流 非立即执行
Returns: Function
debouncingA, debouncingB, throttleA, throttleB 都按此顺序传参
Type: Function
A function to be executed after delay milliseconds. The this
context and all
arguments are passed through. (this上下文和参数都已绑定callback)
Type: Number
延迟的毫秒数