react-timer-hook
Advanced tools
Comparing version
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react")):"function"==typeof define&&define.amd?define(["react"],t):"object"==typeof exports?exports["react-timer-hook"]=t(require("react")):e["react-timer-hook"]=t(e.react)}(window,function(e){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var u=t[n]={i:n,l:!1,exports:{}};return e[n].call(u.exports,u,u.exports,r),u.l=!0,u.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var u in e)r.d(n,u,function(t){return e[t]}.bind(null,u));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=1)}([function(t,r){t.exports=e},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.useTime=t.useStopwatch=t.useTimer=void 0;var n=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e};t.default=function(e){if((0,u.useEffect)(function(){console.warn("react-timer-hook: default export useTimer is deprecated, use named exports { useTimer, useStopwatch, useTime } instead")},[]),e.expiryTimestamp){var t=(0,o.default)(e);return n({},t,{startTimer:t.start,stopTimer:t.pause,resetTimer:function(){}})}var r=(0,a.default)(e);return n({},r,{startTimer:r.start,stopTimer:r.pause,resetTimer:r.reset})};var u=r(0),o=c(r(2)),a=c(r(3)),i=c(r(4));function c(e){return e&&e.__esModule?e:{default:e}}t.useTimer=o.default,t.useStopwatch=a.default,t.useTime=i.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){return function(e,t){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return function(e,t){var r=[],n=!0,u=!1,o=void 0;try{for(var a,i=e[Symbol.iterator]();!(n=(a=i.next()).done)&&(r.push(a.value),!t||r.length!==t);n=!0);}catch(e){u=!0,o=e}finally{try{!n&&i.return&&i.return()}finally{if(u)throw o}}return r}(e,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();t.default=function(e){var t=e||{},r=t.expiryTimestamp,o=t.onExpire,a=(0,u.useState)(r),i=n(a,2),c=i[0],f=i[1],s=(0,u.useState)(0),l=n(s,2),d=l[0],v=l[1];function p(){v(function(e){return 0===e?(b(function(e){return 0===e?(x(function(e){return 0===e?(_(function(e){return e>0?e-1:(P(),A(o)&&o(),0)}),23):e>0?e-1:0}),59):e>0?e-1:0}),59):e>0?e-1:0})}var m=(0,u.useState)(0),y=n(m,2),h=y[0],b=y[1];var S=(0,u.useState)(0),T=n(S,2),w=T[0],x=T[1];var j=(0,u.useState)(0),g=n(j,2),O=g[0],_=g[1];var I=(0,u.useRef)();function M(){E(c)&&!I.current&&(!function(){var e=(new Date).getTime(),t=c-e,r=Math.floor(t/864e5),n=Math.floor(t%864e5/36e5),u=Math.floor(t%36e5/6e4),a=Math.floor(t%6e4/1e3);a<0?(P(),A(o)&&o()):(v(a),b(u),x(n),_(r))}(),I.current=setInterval(function(){return p()},1e3))}function P(){I.current&&(clearInterval(I.current),I.current=void 0),v(0),b(0),x(0),_(0)}function E(e){var t=new Date(e).getTime()>0;return t||console.warn("react-timer-hook: { useTimer } Invalid expiryTimestamp settings",e),t}function A(e){var t=e&&"function"==typeof e;return e&&!t&&console.warn("react-timer-hook: { useTimer } Invalid onExpire settings function",e),t}return(0,u.useEffect)(function(){return M(),P},[c]),{seconds:d,minutes:h,hours:w,days:O,start:M,pause:function(){I.current&&(clearInterval(I.current),I.current=void 0)},resume:function(){E(c)&&!I.current&&(I.current=setInterval(function(){return p()},1e3))},restart:function(e){P(),f(e)}}};var u=r(0)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){return function(e,t){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return function(e,t){var r=[],n=!0,u=!1,o=void 0;try{for(var a,i=e[Symbol.iterator]();!(n=(a=i.next()).done)&&(r.push(a.value),!t||r.length!==t);n=!0);}catch(e){u=!0,o=e}finally{try{!n&&i.return&&i.return()}finally{if(u)throw o}}return r}(e,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();t.default=function(e){var t=(e||{}).autoStart,r=(0,u.useState)(0),o=n(r,2),a=o[0],i=o[1];function c(){i(function(e){return 59===e?(d(function(e){return 59===e?(y(function(e){return 23===e?(T(function(e){return e+1}),0):e+1}),0):e+1}),0):e+1})}var f=(0,u.useState)(0),s=n(f,2),l=s[0],d=s[1];var v=(0,u.useState)(0),p=n(v,2),m=p[0],y=p[1];var h=(0,u.useState)(0),b=n(h,2),S=b[0],T=b[1];var w=(0,u.useRef)();function x(){w.current||(w.current=setInterval(function(){return c()},1e3))}function j(){w.current&&(clearInterval(w.current),w.current=void 0),i(0),d(0),y(0),T(0)}return(0,u.useEffect)(function(){return t&&x(),j},[]),{seconds:a,minutes:l,hours:m,days:S,start:x,pause:function(){w.current&&(clearInterval(w.current),w.current=void 0)},reset:j}};var u=r(0)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){return function(e,t){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return function(e,t){var r=[],n=!0,u=!1,o=void 0;try{for(var a,i=e[Symbol.iterator]();!(n=(a=i.next()).done)&&(r.push(a.value),!t||r.length!==t);n=!0);}catch(e){u=!0,o=e}finally{try{!n&&i.return&&i.return()}finally{if(u)throw o}}return r}(e,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();t.default=function(e){var t=(e||{}).format,r=(0,u.useState)(0),o=n(r,2),a=o[0],i=o[1],c=(0,u.useState)(0),f=n(c,2),s=f[0],l=f[1],d=(0,u.useState)(0),v=n(d,2),p=v[0],m=v[1],y=(0,u.useState)(""),h=n(y,2),b=h[0],S=h[1],T=(0,u.useRef)();function w(){T.current&&(clearInterval(T.current),T.current=void 0),i(0),l(0),m(0),S("")}function x(){var e=new Date,r=e.getSeconds(),n=e.getMinutes(),u=function(e){if("12-hour"===t){var r=e>=12?"pm":"am",n=e%12;return{hours:n=n||12,ampm:r}}return{hours:e,ampm:""}}(e.getHours()),o=u.hours,a=u.ampm;i(r),l(n),m(o),S(a)}return(0,u.useEffect)(function(){return T.current||(x(),T.current=setInterval(function(){return x()},1e3)),w},[]),{seconds:a,minutes:s,hours:p,ampm:b}};var u=r(0)}])}); | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react")):"function"==typeof define&&define.amd?define(["react"],t):"object"==typeof exports?exports["react-timer-hook"]=t(require("react")):e["react-timer-hook"]=t(e.react)}(window,function(e){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var u=t[n]={i:n,l:!1,exports:{}};return e[n].call(u.exports,u,u.exports,r),u.l=!0,u.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var u in e)r.d(n,u,function(t){return e[t]}.bind(null,u));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=1)}([function(t,r){t.exports=e},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.useTime=t.useStopwatch=t.useTimer=void 0;var n=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e};t.default=function(e){if((0,u.useEffect)(function(){console.warn("react-timer-hook: default export useTimer is deprecated, use named exports { useTimer, useStopwatch, useTime } instead")},[]),e.expiryTimestamp){var t=(0,o.default)(e);return n({},t,{startTimer:t.start,stopTimer:t.pause,resetTimer:function(){}})}var r=(0,a.default)(e);return n({},r,{startTimer:r.start,stopTimer:r.pause,resetTimer:r.reset})};var u=r(0),o=c(r(2)),a=c(r(3)),i=c(r(4));function c(e){return e&&e.__esModule?e:{default:e}}t.useTimer=o.default,t.useStopwatch=a.default,t.useTime=i.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){return function(e,t){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return function(e,t){var r=[],n=!0,u=!1,o=void 0;try{for(var a,i=e[Symbol.iterator]();!(n=(a=i.next()).done)&&(r.push(a.value),!t||r.length!==t);n=!0);}catch(e){u=!0,o=e}finally{try{!n&&i.return&&i.return()}finally{if(u)throw o}}return r}(e,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();t.default=function(e){var t=e||{},r=t.expiryTimestamp,o=t.onExpire,a=(0,u.useState)(r),i=n(a,2),c=i[0],f=i[1],s=(0,u.useState)(0),l=n(s,2),d=l[0],v=l[1];var p=(0,u.useState)(0),m=n(p,2),y=m[0],h=m[1];var b=(0,u.useState)(0),S=n(b,2),T=S[0],w=S[1];var x=(0,u.useState)(0),j=n(x,2),g=j[0],O=j[1];var _=(0,u.useRef)();function I(){E(c)&&!_.current&&(P(),_.current=setInterval(function(){return P()},1e3))}function M(){_.current&&(clearInterval(_.current),_.current=void 0),v(0),h(0),w(0),O(0)}function P(){var e=(new Date).getTime(),t=c-e,r=Math.floor(t/864e5),n=Math.floor(t%864e5/36e5),u=Math.floor(t%36e5/6e4),a=Math.floor(t%6e4/1e3);a<0?(M(),A(o)&&o()):(v(a),h(u),w(n),O(r))}function E(e){var t=new Date(e).getTime()>0;return t||console.warn("react-timer-hook: { useTimer } Invalid expiryTimestamp settings",e),t}function A(e){var t=e&&"function"==typeof e;return e&&!t&&console.warn("react-timer-hook: { useTimer } Invalid onExpire settings function",e),t}return(0,u.useEffect)(function(){return I(),M},[c]),{seconds:d,minutes:y,hours:T,days:g,start:I,pause:function(){_.current&&(clearInterval(_.current),_.current=void 0)},resume:function(){E(c)&&!_.current&&(_.current=setInterval(function(){v(function(e){return 0===e?(h(function(e){return 0===e?(w(function(e){return 0===e?(O(function(e){return e>0?e-1:(M(),A(o)&&o(),0)}),23):e>0?e-1:0}),59):e>0?e-1:0}),59):e>0?e-1:0})},1e3))},restart:function(e){M(),f(e)}}};var u=r(0)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){return function(e,t){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return function(e,t){var r=[],n=!0,u=!1,o=void 0;try{for(var a,i=e[Symbol.iterator]();!(n=(a=i.next()).done)&&(r.push(a.value),!t||r.length!==t);n=!0);}catch(e){u=!0,o=e}finally{try{!n&&i.return&&i.return()}finally{if(u)throw o}}return r}(e,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();t.default=function(e){var t=(e||{}).autoStart,r=(0,u.useState)(0),o=n(r,2),a=o[0],i=o[1];function c(){i(function(e){return 59===e?(d(function(e){return 59===e?(y(function(e){return 23===e?(T(function(e){return e+1}),0):e+1}),0):e+1}),0):e+1})}var f=(0,u.useState)(0),s=n(f,2),l=s[0],d=s[1];var v=(0,u.useState)(0),p=n(v,2),m=p[0],y=p[1];var h=(0,u.useState)(0),b=n(h,2),S=b[0],T=b[1];var w=(0,u.useRef)();function x(){w.current||(w.current=setInterval(function(){return c()},1e3))}function j(){w.current&&(clearInterval(w.current),w.current=void 0),i(0),d(0),y(0),T(0)}return(0,u.useEffect)(function(){return t&&x(),j},[]),{seconds:a,minutes:l,hours:m,days:S,start:x,pause:function(){w.current&&(clearInterval(w.current),w.current=void 0)},reset:j}};var u=r(0)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){return function(e,t){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return function(e,t){var r=[],n=!0,u=!1,o=void 0;try{for(var a,i=e[Symbol.iterator]();!(n=(a=i.next()).done)&&(r.push(a.value),!t||r.length!==t);n=!0);}catch(e){u=!0,o=e}finally{try{!n&&i.return&&i.return()}finally{if(u)throw o}}return r}(e,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();t.default=function(e){var t=(e||{}).format,r=(0,u.useState)(0),o=n(r,2),a=o[0],i=o[1],c=(0,u.useState)(0),f=n(c,2),s=f[0],l=f[1],d=(0,u.useState)(0),v=n(d,2),p=v[0],m=v[1],y=(0,u.useState)(""),h=n(y,2),b=h[0],S=h[1],T=(0,u.useRef)();function w(){T.current&&(clearInterval(T.current),T.current=void 0),i(0),l(0),m(0),S("")}function x(){var e=new Date,r=e.getSeconds(),n=e.getMinutes(),u=function(e){if("12-hour"===t){var r=e>=12?"pm":"am",n=e%12;return{hours:n=n||12,ampm:r}}return{hours:e,ampm:""}}(e.getHours()),o=u.hours,a=u.ampm;i(r),l(n),m(o),S(a)}return(0,u.useEffect)(function(){return T.current||(x(),T.current=setInterval(function(){return x()},1e3)),w},[]),{seconds:a,minutes:s,hours:p,ampm:b}};var u=r(0)}])}); |
{ | ||
"name": "react-timer-hook", | ||
"version": "1.1.7", | ||
"version": "1.1.8", | ||
"description": "React timer hook is a custom react hook built to handle timers(countdown), stopwatch and time logic/state in your react component.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
224874
0.48%