Viewing File: /home/ubuntu/route-and-root-frontend-base/node_modules/use-debounce/dist/index.modern.js

import{useRef as r,useEffect as n,useMemo as t,useCallback as e,useState as u}from"react";function c(e,u,c){const i=r(null),o=r(0),a=r(null),l=r([]),f=r(),s=r(),m=r(e),p=r(!0);n(()=>{m.current=e},[e]);const d=!u&&0!==u&&"undefined"!=typeof window;if("function"!=typeof e)throw new TypeError("Expected a function");u=+u||0;const g=!!(c=c||{}).leading,w=!("trailing"in c)||!!c.trailing,x="maxWait"in c,y=x?Math.max(+c.maxWait||0,u):null;n(()=>(p.current=!0,()=>{p.current=!1}),[]);const h=t(()=>{const r=r=>{const n=l.current,t=f.current;return l.current=f.current=null,o.current=r,s.current=m.current.apply(t,n)},n=(r,n)=>{d&&cancelAnimationFrame(a.current),a.current=d?requestAnimationFrame(r):setTimeout(r,n)},t=r=>{if(!p.current)return!1;const n=r-i.current;return!i.current||n>=u||n<0||x&&r-o.current>=y},e=n=>(a.current=null,w&&l.current?r(n):(l.current=f.current=null,s.current)),c=()=>{const r=Date.now();if(t(r))return e(r);if(!p.current)return;const a=u-(r-i.current),l=x?Math.min(a,y-(r-o.current)):a;n(c,l)},h=(...e)=>{const m=Date.now(),d=t(m);if(l.current=e,f.current=this,i.current=m,d){if(!a.current&&p.current)return o.current=i.current,n(c,u),g?r(i.current):s.current;if(x)return n(c,u),r(i.current)}return a.current||n(c,u),s.current};return h.cancel=()=>{a.current&&(d?cancelAnimationFrame(a.current):clearTimeout(a.current)),o.current=0,l.current=i.current=f.current=a.current=null},h.isPending=()=>!!a.current,h.flush=()=>a.current?e(Date.now()):s.current,h},[g,x,u,y,w,d]);return h}function i(r,n){return r===n}function o(r){return"function"==typeof r?()=>r:r}function a(n,t,a){const l=a&&a.equalityFn||i,[f,s]=function(r){const[n,t]=u(o(r));return[n,e(r=>t(o(r)),[])]}(n),m=c(e(r=>s(r),[s]),t,a),p=r(n);return l(p.current,n)||(m(n),p.current=n),[f,m]}function l(r,n,{leading:t=!0,trailing:e=!0}={}){return c(r,n,{maxWait:n,leading:t,trailing:e})}export{a as useDebounce,c as useDebouncedCallback,l as useThrottledCallback};
//# sourceMappingURL=index.modern.js.map
Back to Directory File Manager