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

use-count-up

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

use-count-up - npm Package Compare versions

Comparing version 3.0.0 to 3.0.1

8

CHANGELOG.md
# Change Log
## 3.0.0 ( ---- , 2021)
## 3.0.1 (September 5th, 2021)
**Fix:**
- upgraded `use-elapsed-time` to 3.0.2, which fixes an issue where reset method was taking any kind of value as newStartAt value. Not it checks if the value provided is a number
## 3.0.0 ( September 5th , 2021)
**Breaking Changes:**

@@ -6,0 +12,0 @@

2

lib/index.js

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

var Q=Object.create;var F=Object.defineProperty;var W=Object.getOwnPropertyDescriptor;var X=Object.getOwnPropertyNames,I=Object.getOwnPropertySymbols,Y=Object.getPrototypeOf,S=Object.prototype.hasOwnProperty,Z=Object.prototype.propertyIsEnumerable;var h=e=>F(e,"__esModule",{value:!0});var q=(e,r)=>{var t={};for(var n in e)S.call(e,n)&&r.indexOf(n)<0&&(t[n]=e[n]);if(e!=null&&I)for(var n of I(e))r.indexOf(n)<0&&Z.call(e,n)&&(t[n]=e[n]);return t};var _=(e,r)=>{h(e);for(var t in r)F(e,t,{get:r[t],enumerable:!0})},ee=(e,r,t)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of X(r))!S.call(e,n)&&n!=="default"&&F(e,n,{get:()=>r[n],enumerable:!(t=W(r,n))||t.enumerable});return e},V=e=>ee(h(F(e!=null?Q(Y(e)):{},"default",e&&e.__esModule&&"default"in e?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e);_(exports,{CountUp:()=>T,useCountUp:()=>x});var s=V(require("react")),O=V(require("react")),re=Object.defineProperty,te=Object.defineProperties,ne=Object.getOwnPropertyDescriptors,L=Object.getOwnPropertySymbols,ue=Object.prototype.hasOwnProperty,oe=Object.prototype.propertyIsEnumerable,$=(e,r,t)=>r in e?re(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t,w=(e,r)=>{for(var t in r||(r={}))ue.call(r,t)&&$(e,t,r[t]);if(L)for(var t of L(r))oe.call(r,t)&&$(e,t,r[t]);return e},D=(e,r)=>te(e,ne(r)),k=typeof window=="undefined"?O.useEffect:O.useLayoutEffect,B=({isPlaying:e,duration:r,startAt:t=0,updateInterval:n=0,onComplete:p,onUpdate:y})=>{let[m,g]=(0,s.useState)(t),R=(0,s.useRef)(t*-1e3),i=(0,s.useRef)(null),c=(0,s.useRef)(null),b=(0,s.useRef)(null),u=(0,s.useRef)({elapsedTimeRef:0,startAtRef:t,durationRef:r,updateIntervalRef:n});u.current=D(w({},u.current),{durationRef:r,updateIntervalRef:n});let l=o=>{let a=o/1e3;if(c.current===null){c.current=a,i.current=requestAnimationFrame(l);return}let{durationRef:f,elapsedTimeRef:A,updateIntervalRef:C,startAtRef:d}=u.current,U=a-c.current,E=A+U;c.current=a,u.current=D(w({},u.current),{elapsedTimeRef:E});let H=d+(C===0?E:(E/C|0)*C),K=d+E,j=typeof f=="number"&&K>=f;g(j?f:H),j||(i.current=requestAnimationFrame(l))},P=()=>{i.current&&cancelAnimationFrame(i.current),b.current&&clearTimeout(b.current),c.current=null},v=(0,s.useCallback)((o=t)=>{P(),u.current=D(w({},u.current),{elapsedTimeRef:0,startAtRef:o}),g(o),e&&(i.current=requestAnimationFrame(l))},[e,t]);return k(()=>{if(y==null||y(m),r&&m>=r){R.current+=r*1e3;let{shouldRepeat:o=!1,delay:a=0,newStartAt:f}=(p==null?void 0:p(R.current/1e3))||{};o&&(b.current=setTimeout(()=>v(f),a*1e3))}},[m,r]),k(()=>(e&&(i.current=requestAnimationFrame(l)),P),[e]),{elapsedTime:m,reset:v}};var M={easeInCubic:(e,r,t,n)=>(e/=n,t*e*e*e+r),easeOutCubic:(e,r,t,n)=>(e/=n,e--,t*(e*e*e+1)+r),linear:(e,r,t,n)=>t*e/n+r},N=M.easeOutCubic,z=e=>typeof e=="function"?e:M[e];var ae=(e,r)=>{if(typeof e=="number")return typeof r=="number"?r:2},G=(e,r)=>e.replace(/\B(?=(\d{3})+(?!\d))/g,r),J=e=>(e.toString().split(".")[1]||"").length,se=(e,r)=>{let t=J(e),n=J(r||1);return t>=n?t:n},x=({isCounting:e=!1,start:r=0,end:t,duration:n,decimalPlaces:p=se(r,t),decimalSeparator:y=".",thousandsSeparator:m="",onComplete:g,easing:R=N,formatter:i,updateInterval:c,onUpdate:b})=>{let u=ae(t,n),l=o=>{let a;if(u===0&&typeof t=="number")a=t;else if(typeof t=="number"&&typeof u=="number"){let d=z(R),U=o<u?o:u;a=d(U,r,t-r,u)}else a=r+o;if(typeof i=="function")return i(a);if(p===0){let d=Math.round(a).toString();return G(d,m)}let[f,A]=a.toFixed(p).split(".");return`${G(f,m)}${y}${A}`},{elapsedTime:P,reset:v}=B({isPlaying:e,duration:u,onComplete:g,updateInterval:c,onUpdate:typeof b=="function"?o=>b(l(o)):void 0});return{value:l(P),reset:v}};var T=t=>{var n=t,{children:e}=n,r=q(n,["children"]);let p=x(r);return typeof e=="function"?e(p):p.value};T.displayName="CountUp";
var Q=Object.create;var F=Object.defineProperty;var W=Object.getOwnPropertyDescriptor;var X=Object.getOwnPropertyNames,I=Object.getOwnPropertySymbols,Y=Object.getPrototypeOf,S=Object.prototype.hasOwnProperty,Z=Object.prototype.propertyIsEnumerable;var h=e=>F(e,"__esModule",{value:!0});var q=(e,t)=>{var r={};for(var n in e)S.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&I)for(var n of I(e))t.indexOf(n)<0&&Z.call(e,n)&&(r[n]=e[n]);return r};var _=(e,t)=>{h(e);for(var r in t)F(e,r,{get:t[r],enumerable:!0})},ee=(e,t,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of X(t))!S.call(e,n)&&n!=="default"&&F(e,n,{get:()=>t[n],enumerable:!(r=W(t,n))||r.enumerable});return e},V=e=>ee(h(F(e!=null?Q(Y(e)):{},"default",e&&e.__esModule&&"default"in e?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e);_(exports,{CountUp:()=>T,useCountUp:()=>x});var s=V(require("react")),O=V(require("react")),te=Object.defineProperty,re=Object.defineProperties,ne=Object.getOwnPropertyDescriptors,L=Object.getOwnPropertySymbols,ue=Object.prototype.hasOwnProperty,oe=Object.prototype.propertyIsEnumerable,$=(e,t,r)=>t in e?te(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,A=(e,t)=>{for(var r in t||(t={}))ue.call(t,r)&&$(e,r,t[r]);if(L)for(var r of L(t))oe.call(t,r)&&$(e,r,t[r]);return e},D=(e,t)=>re(e,ne(t)),k=typeof window=="undefined"?O.useEffect:O.useLayoutEffect,B=({isPlaying:e,duration:t,startAt:r=0,updateInterval:n=0,onComplete:p,onUpdate:y})=>{let[m,g]=(0,s.useState)(r),v=(0,s.useRef)(r*-1e3),i=(0,s.useRef)(null),c=(0,s.useRef)(null),b=(0,s.useRef)(null),o=(0,s.useRef)({elapsedTimeRef:0,startAtRef:r,durationRef:t,updateIntervalRef:n});o.current=D(A({},o.current),{durationRef:t,updateIntervalRef:n});let l=a=>{let u=a/1e3;if(c.current===null){c.current=u,i.current=requestAnimationFrame(l);return}let{durationRef:f,elapsedTimeRef:U,updateIntervalRef:C,startAtRef:d}=o.current,w=u-c.current,E=U+w;c.current=u,o.current=D(A({},o.current),{elapsedTimeRef:E});let H=d+(C===0?E:(E/C|0)*C),K=d+E,j=typeof f=="number"&&K>=f;g(j?f:H),j||(i.current=requestAnimationFrame(l))},R=()=>{i.current&&cancelAnimationFrame(i.current),b.current&&clearTimeout(b.current),c.current=null},P=(0,s.useCallback)(a=>{let u=typeof a=="number"?a:r;R(),o.current=D(A({},o.current),{elapsedTimeRef:0,startAtRef:u}),g(u),e&&(i.current=requestAnimationFrame(l))},[e,r]);return k(()=>{if(y==null||y(m),t&&m>=t){v.current+=t*1e3;let{shouldRepeat:a=!1,delay:u=0,newStartAt:f}=(p==null?void 0:p(v.current/1e3))||{};a&&(b.current=setTimeout(()=>P(f),u*1e3))}},[m,t]),k(()=>(e&&(i.current=requestAnimationFrame(l)),R),[e]),{elapsedTime:m,reset:P}};var M={easeInCubic:(e,t,r,n)=>(e/=n,r*e*e*e+t),easeOutCubic:(e,t,r,n)=>(e/=n,e--,r*(e*e*e+1)+t),linear:(e,t,r,n)=>r*e/n+t},N=M.easeOutCubic,z=e=>typeof e=="function"?e:M[e];var ae=(e,t)=>{if(typeof e=="number")return typeof t=="number"?t:2},G=(e,t)=>e.replace(/\B(?=(\d{3})+(?!\d))/g,t),J=e=>(e.toString().split(".")[1]||"").length,se=(e,t)=>{let r=J(e),n=J(t||1);return r>=n?r:n},x=({isCounting:e=!1,start:t=0,end:r,duration:n,decimalPlaces:p=se(t,r),decimalSeparator:y=".",thousandsSeparator:m="",onComplete:g,easing:v=N,formatter:i,updateInterval:c,onUpdate:b})=>{let o=ae(r,n),l=a=>{let u;if(o===0&&typeof r=="number")u=r;else if(typeof r=="number"&&typeof o=="number"){let d=z(v),w=a<o?a:o;u=d(w,t,r-t,o)}else u=t+a;if(typeof i=="function")return i(u);if(p===0){let d=Math.round(u).toString();return G(d,m)}let[f,U]=u.toFixed(p).split(".");return`${G(f,m)}${y}${U}`},{elapsedTime:R,reset:P}=B({isPlaying:e,duration:o,onComplete:g,updateInterval:c,onUpdate:typeof b=="function"?a=>b(l(a)):void 0});return{value:l(R),reset:P}};var T=r=>{var n=r,{children:e}=n,t=q(n,["children"]);let p=x(t);return typeof e=="function"?e(p):p.value};T.displayName="CountUp";

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

var D=Object.getOwnPropertySymbols;var z=Object.prototype.hasOwnProperty,G=Object.prototype.propertyIsEnumerable;var T=(e,r)=>{var t={};for(var n in e)z.call(e,n)&&r.indexOf(n)<0&&(t[n]=e[n]);if(e!=null&&D)for(var n of D(e))r.indexOf(n)<0&&G.call(e,n)&&(t[n]=e[n]);return t};import{useState as X,useRef as d,useCallback as Y}from"react";import{useEffect as Z,useLayoutEffect as _}from"react";var J=Object.defineProperty,H=Object.defineProperties,K=Object.getOwnPropertyDescriptors,j=Object.getOwnPropertySymbols,Q=Object.prototype.hasOwnProperty,W=Object.prototype.propertyIsEnumerable,I=(e,r,t)=>r in e?J(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t,x=(e,r)=>{for(var t in r||(r={}))Q.call(r,t)&&I(e,t,r[t]);if(j)for(var t of j(r))W.call(r,t)&&I(e,t,r[t]);return e},A=(e,r)=>H(e,K(r)),S=typeof window=="undefined"?Z:_,h=({isPlaying:e,duration:r,startAt:t=0,updateInterval:n=0,onComplete:i,onUpdate:y})=>{let[p,g]=X(t),R=d(t*-1e3),s=d(null),m=d(null),f=d(null),u=d({elapsedTimeRef:0,startAtRef:t,durationRef:r,updateIntervalRef:n});u.current=A(x({},u.current),{durationRef:r,updateIntervalRef:n});let c=o=>{let a=o/1e3;if(m.current===null){m.current=a,s.current=requestAnimationFrame(c);return}let{durationRef:l,elapsedTimeRef:F,updateIntervalRef:C,startAtRef:b}=u.current,O=a-m.current,E=F+O;m.current=a,u.current=A(x({},u.current),{elapsedTimeRef:E});let M=b+(C===0?E:(E/C|0)*C),N=b+E,w=typeof l=="number"&&N>=l;g(w?l:M),w||(s.current=requestAnimationFrame(c))},P=()=>{s.current&&cancelAnimationFrame(s.current),f.current&&clearTimeout(f.current),m.current=null},v=Y((o=t)=>{P(),u.current=A(x({},u.current),{elapsedTimeRef:0,startAtRef:o}),g(o),e&&(s.current=requestAnimationFrame(c))},[e,t]);return S(()=>{if(y==null||y(p),r&&p>=r){R.current+=r*1e3;let{shouldRepeat:o=!1,delay:a=0,newStartAt:l}=(i==null?void 0:i(R.current/1e3))||{};o&&(f.current=setTimeout(()=>v(l),a*1e3))}},[p,r]),S(()=>(e&&(s.current=requestAnimationFrame(c)),P),[e]),{elapsedTime:p,reset:v}};var q={easeInCubic:(e,r,t,n)=>(e/=n,t*e*e*e+r),easeOutCubic:(e,r,t,n)=>(e/=n,e--,t*(e*e*e+1)+r),linear:(e,r,t,n)=>t*e/n+r},V=q.easeOutCubic,L=e=>typeof e=="function"?e:q[e];var ee=(e,r)=>{if(typeof e=="number")return typeof r=="number"?r:2},$=(e,r)=>e.replace(/\B(?=(\d{3})+(?!\d))/g,r),k=e=>(e.toString().split(".")[1]||"").length,re=(e,r)=>{let t=k(e),n=k(r||1);return t>=n?t:n},U=({isCounting:e=!1,start:r=0,end:t,duration:n,decimalPlaces:i=re(r,t),decimalSeparator:y=".",thousandsSeparator:p="",onComplete:g,easing:R=V,formatter:s,updateInterval:m,onUpdate:f})=>{let u=ee(t,n),c=o=>{let a;if(u===0&&typeof t=="number")a=t;else if(typeof t=="number"&&typeof u=="number"){let b=L(R),O=o<u?o:u;a=b(O,r,t-r,u)}else a=r+o;if(typeof s=="function")return s(a);if(i===0){let b=Math.round(a).toString();return $(b,p)}let[l,F]=a.toFixed(i).split(".");return`${$(l,p)}${y}${F}`},{elapsedTime:P,reset:v}=h({isPlaying:e,duration:u,onComplete:g,updateInterval:m,onUpdate:typeof f=="function"?o=>f(c(o)):void 0});return{value:c(P),reset:v}};var B=t=>{var n=t,{children:e}=n,r=T(n,["children"]);let i=U(r);return typeof e=="function"?e(i):i.value};B.displayName="CountUp";export{B as CountUp,U as useCountUp};
var D=Object.getOwnPropertySymbols;var z=Object.prototype.hasOwnProperty,G=Object.prototype.propertyIsEnumerable;var T=(e,t)=>{var r={};for(var n in e)z.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&D)for(var n of D(e))t.indexOf(n)<0&&G.call(e,n)&&(r[n]=e[n]);return r};import{useState as X,useRef as d,useCallback as Y}from"react";import{useEffect as Z,useLayoutEffect as _}from"react";var J=Object.defineProperty,H=Object.defineProperties,K=Object.getOwnPropertyDescriptors,j=Object.getOwnPropertySymbols,Q=Object.prototype.hasOwnProperty,W=Object.prototype.propertyIsEnumerable,I=(e,t,r)=>t in e?J(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,x=(e,t)=>{for(var r in t||(t={}))Q.call(t,r)&&I(e,r,t[r]);if(j)for(var r of j(t))W.call(t,r)&&I(e,r,t[r]);return e},U=(e,t)=>H(e,K(t)),S=typeof window=="undefined"?Z:_,h=({isPlaying:e,duration:t,startAt:r=0,updateInterval:n=0,onComplete:i,onUpdate:y})=>{let[p,g]=X(r),v=d(r*-1e3),s=d(null),m=d(null),f=d(null),o=d({elapsedTimeRef:0,startAtRef:r,durationRef:t,updateIntervalRef:n});o.current=U(x({},o.current),{durationRef:t,updateIntervalRef:n});let c=a=>{let u=a/1e3;if(m.current===null){m.current=u,s.current=requestAnimationFrame(c);return}let{durationRef:l,elapsedTimeRef:F,updateIntervalRef:C,startAtRef:b}=o.current,O=u-m.current,E=F+O;m.current=u,o.current=U(x({},o.current),{elapsedTimeRef:E});let M=b+(C===0?E:(E/C|0)*C),N=b+E,A=typeof l=="number"&&N>=l;g(A?l:M),A||(s.current=requestAnimationFrame(c))},R=()=>{s.current&&cancelAnimationFrame(s.current),f.current&&clearTimeout(f.current),m.current=null},P=Y(a=>{let u=typeof a=="number"?a:r;R(),o.current=U(x({},o.current),{elapsedTimeRef:0,startAtRef:u}),g(u),e&&(s.current=requestAnimationFrame(c))},[e,r]);return S(()=>{if(y==null||y(p),t&&p>=t){v.current+=t*1e3;let{shouldRepeat:a=!1,delay:u=0,newStartAt:l}=(i==null?void 0:i(v.current/1e3))||{};a&&(f.current=setTimeout(()=>P(l),u*1e3))}},[p,t]),S(()=>(e&&(s.current=requestAnimationFrame(c)),R),[e]),{elapsedTime:p,reset:P}};var q={easeInCubic:(e,t,r,n)=>(e/=n,r*e*e*e+t),easeOutCubic:(e,t,r,n)=>(e/=n,e--,r*(e*e*e+1)+t),linear:(e,t,r,n)=>r*e/n+t},V=q.easeOutCubic,L=e=>typeof e=="function"?e:q[e];var ee=(e,t)=>{if(typeof e=="number")return typeof t=="number"?t:2},$=(e,t)=>e.replace(/\B(?=(\d{3})+(?!\d))/g,t),k=e=>(e.toString().split(".")[1]||"").length,te=(e,t)=>{let r=k(e),n=k(t||1);return r>=n?r:n},w=({isCounting:e=!1,start:t=0,end:r,duration:n,decimalPlaces:i=te(t,r),decimalSeparator:y=".",thousandsSeparator:p="",onComplete:g,easing:v=V,formatter:s,updateInterval:m,onUpdate:f})=>{let o=ee(r,n),c=a=>{let u;if(o===0&&typeof r=="number")u=r;else if(typeof r=="number"&&typeof o=="number"){let b=L(v),O=a<o?a:o;u=b(O,t,r-t,o)}else u=t+a;if(typeof s=="function")return s(u);if(i===0){let b=Math.round(u).toString();return $(b,p)}let[l,F]=u.toFixed(i).split(".");return`${$(l,p)}${y}${F}`},{elapsedTime:R,reset:P}=h({isPlaying:e,duration:o,onComplete:g,updateInterval:m,onUpdate:typeof f=="function"?a=>f(c(a)):void 0});return{value:c(R),reset:P}};var B=r=>{var n=r,{children:e}=n,t=T(n,["children"]);let i=w(t);return typeof e=="function"?e(i):i.value};B.displayName="CountUp";export{B as CountUp,w as useCountUp};
/// <reference types="react" />
import { ReturnValue as ETReturnValue, Props as ETProps } from 'use-elapsed-time';
import { Props as ETProps } from 'use-elapsed-time';
export declare type ReturnValue = number | string | React.ReactNode;

@@ -10,3 +10,3 @@ export declare type EasingFn = (currentTime: number, startValue: number, changeInValue: number, duration: number) => number;

/** Method to start over the animation*/
reset: ETReturnValue['reset'];
reset: () => void;
}

@@ -35,5 +35,5 @@ export interface Props {

/** Update interval in seconds. Determines how often the animated value will change. When set to 0 the value will update on each key frame. Default: 0 */
updateInterval?: ETProps['updateInterval'];
updateInterval?: number;
/** On value update event handler. It receives the current value */
onUpdate?: (value: ReturnValue) => void;
}
{
"name": "use-count-up",
"version": "3.0.0",
"version": "3.0.1",
"description": "React/React Native component and hook to animate counting up or down to a number",

@@ -54,3 +54,3 @@ "main": "./lib/index.js",

"dependencies": {
"use-elapsed-time": "3.0.1"
"use-elapsed-time": "3.0.2"
},

@@ -57,0 +57,0 @@ "peerDependencies": {

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