Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

use-elapsed-time

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

use-elapsed-time - npm Package Compare versions

Comparing version 2.1.1 to 2.1.2

2

lib/index.js

@@ -1,1 +0,1 @@

module.exports=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(e,t){e.exports=require("react")},function(e,t,r){"use strict";r.r(t),r.d(t,"useElapsedTime",(function(){return c}));var n=r(0);function u(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var r=[],n=!0,u=!1,o=void 0;try{for(var c,i=e[Symbol.iterator]();!(n=(c=i.next()).done)&&(r.push(c.value),!t||r.length!==t);n=!0);}catch(e){u=!0,o=e}finally{try{n||null==i.return||i.return()}finally{if(u)throw o}}return r}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return o(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return o(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var c=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.duration,o=t.onComplete,c=t.startAt,i=void 0===c?0:c,a=t.autoResetKey,f=Object(n.useState)(i),l=u(f,2),s=l[0],b=l[1],y=Object(n.useRef)(-1e3*i),d=Object(n.useRef)(null),m=Object(n.useRef)(null),p=Object(n.useRef)(null),v=Object(n.useRef)(!0),j=Object(n.useRef)(!1),O=Object(n.useRef)(0),g=Object(n.useCallback)((function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:i;O.current+=1,b(e)}),[]),A=function e(t){var n=t/1e3;if(null===m.current)return m.current=n,void(d.current=requestAnimationFrame(e));b((function(t){var u=t+(n-m.current);if("number"!=typeof r||u<r)return m.current=n,d.current=requestAnimationFrame(e),u;if(j.current=!0,"function"==typeof o){y.current+=1e3*r;var c=y.current/1e3,i=o(c)||{},a=i.shouldRepeat,f=void 0!==a&&a,l=i.delay,s=void 0===l?0:l,b=i.newStartAt;f&&(p.current=setTimeout((function(){g(b)}),1e3*s))}return r}))},h=function(){cancelAnimationFrame(d.current),clearTimeout(p.current),m.current=null};return Object(n.useLayoutEffect)((function(){return e&&(d.current=requestAnimationFrame(A)),h}),[e]),Object(n.useLayoutEffect)((function(){e&&!v.current&&(h(),d.current=requestAnimationFrame(A))}),[r]),Object(n.useLayoutEffect)((function(){v.current||g()}),[a]),Object(n.useLayoutEffect)((function(){e&&j.current&&(j.current=!1,h(),d.current=requestAnimationFrame(A))}),[O.current]),Object(n.useLayoutEffect)((function(){v.current=!1}),[]),{elapsedTime:s,reset:g}}}]);
module.exports=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(e,t){e.exports=require("react")},function(e,t,r){"use strict";r.r(t),r.d(t,"useElapsedTime",(function(){return c}));var n=r(0);function u(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var r=[],n=!0,u=!1,o=void 0;try{for(var c,i=e[Symbol.iterator]();!(n=(c=i.next()).done)&&(r.push(c.value),!t||r.length!==t);n=!0);}catch(e){u=!0,o=e}finally{try{n||null==i.return||i.return()}finally{if(u)throw o}}return r}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return o(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return o(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var c=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.duration,o=t.onComplete,c=t.startAt,i=void 0===c?0:c,a=t.autoResetKey,f=Object(n.useState)(i),l=u(f,2),s=l[0],b=l[1],y=Object(n.useRef)(-1e3*i),d=Object(n.useRef)(null),m=Object(n.useRef)(null),p=Object(n.useRef)(null),v=Object(n.useRef)(!0),j=Object(n.useRef)(!1),O=Object(n.useRef)(0),A=Object(n.useCallback)((function(e){O.current+=1,b("number"==typeof e?e:i)}),[]),g=function e(t){var n=t/1e3;if(null===m.current)return m.current=n,void(d.current=requestAnimationFrame(e));b((function(t){var u=t+(n-m.current);if("number"!=typeof r||u<r)return m.current=n,d.current=requestAnimationFrame(e),u;if(j.current=!0,"function"==typeof o){y.current+=1e3*r;var c=y.current/1e3,i=o(c)||{},a=i.shouldRepeat,f=void 0!==a&&a,l=i.delay,s=void 0===l?0:l,b=i.newStartAt;f&&(p.current=setTimeout((function(){A(b)}),1e3*s))}return r}))},S=function(){cancelAnimationFrame(d.current),clearTimeout(p.current),m.current=null};return Object(n.useLayoutEffect)((function(){return e&&(d.current=requestAnimationFrame(g)),S}),[e]),Object(n.useLayoutEffect)((function(){e&&!v.current&&(S(),d.current=requestAnimationFrame(g))}),[r]),Object(n.useLayoutEffect)((function(){v.current||A()}),[a]),Object(n.useLayoutEffect)((function(){e&&j.current&&(j.current=!1,S(),d.current=requestAnimationFrame(g))}),[O.current]),Object(n.useLayoutEffect)((function(){v.current=!1}),[]),{elapsedTime:s,reset:A}}}]);
{
"name": "use-elapsed-time",
"version": "2.1.1",
"version": "2.1.2",
"description": "React hook to measure elapsed time using requestAnimationFrame",

@@ -5,0 +5,0 @@ "main": "./lib/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc