1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
define(function () { return function (func, limit) { var timeout; var inThrottle; return function () { var context = this, args = arguments; if (!inThrottle) { func.apply(context, args); inThrottle = true; } setTimeout(() => inThrottle = false, limit); }; }; });