Module 649852

926 characters · in 33012.87e39a5a39ba7c99.js
Dependencies
Source Raw
function(e,t,n){var r=n(980320),o=n(403819),i=n(867167),a=Math.max,u=Math.min;e.exports=function(e,t,n){var s,l,c,f,d,h,p=0,m=!1,v=!1,y=!0;if("function"!=typeof e)throw TypeError("Expected a function");function g(t){var n=s,r=l;return s=l=void 0,p=t,f=e.apply(r,n)}function b(e){var n=e-h,r=e-p;return void 0===h||n>=t||n<0||v&&r>=c}function w(){var e,n,r,i=o();if(b(i))return _(i);d=setTimeout(w,(e=i-h,n=i-p,r=t-e,v?u(r,c-n):r))}function _(e){return(d=void 0,y&&s)?g(e):(s=l=void 0,f)}function D(){var e,n=o(),r=b(n);if(s=arguments,l=this,h=n,r){if(void 0===d)return p=e=h,d=setTimeout(w,t),m?g(e):f;if(v)return clearTimeout(d),d=setTimeout(w,t),g(h)}return void 0===d&&(d=setTimeout(w,t)),f}return t=i(t)||0,r(n)&&(m=!!n.leading,c=(v="maxWait"in n)?a(i(n.maxWait)||0,t):c,y="trailing"in n?!!n.trailing:y),D.cancel=function(){void 0!==d&&clearTimeout(d),p=0,s=h=l=d=void 0},D.flush=function(){return void 0===d?f:_(o())},D}}