xgqfrms™, xgqfrms® : xgqfrms's offical website of cnblogs! xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!

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, 禁止转载 🈲️,侵权必究⚠️!


posted @ 2021-06-24 10:40  xgqfrms  阅读(39)  评论(2编辑  收藏  举报