lodash & _.debounce & _.throttle All In One
lodash & _.debounce & _.throttle All In One
with arguments
// _.throttle(func, [wait=0], [options={}])
const func = (name = '') => console.log(name ?? '❓');
const newFunc = _.throttle(func, 1000])
// with arguments
const newFunc = _.throttle(() {
func(name);
}, 1000])
// _.debounce(func, [wait=0], [options={}])
const func = (name = '') => console.log(name ?? '❓');
const newFunc = _.debounce(func, 1000])
// with arguments
const newFunc = _.debounce(() {
func(name);
}, 1000])
demo
_lodash playground
https://codepen.io/xgqfrms/pen/XWMLqoG
https://codepen.io/xgqfrms/pen/wvJLjQq
refs
https://lodash.com/docs/4.17.15#throttle
https://lodash.com/docs/4.17.15#debounce
©xgqfrms 2012-2020
www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!
原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!
本文首发于博客园,作者:xgqfrms,原文链接:https://www.cnblogs.com/xgqfrms/p/14925854.html
未经授权禁止转载,违者必究!