UNPKG

vue-matchup

Version:

A rollup + vue component development template

25 lines (22 loc) 514 B
export const debounce = function (fn, wait) { let timer; return function () { const context = this const args = arguments timer && clearTimeout(timer) timer = setTimeout(() => { fn.apply(context, args) }, wait) } } export const throttle = function (fn, wait) { let timer; return function () { const context = this const args = arguments !timer && fn.apply(context, args) timer = setTimeout(() => { timer = null }, wait) } }