const calculateTimeBetweenStartAndEnd = ( startTime , dateNumNextSearch ) : number => { return Math . max ( dateNumNextSearch - startTime , 0 ) ; } ; const calculateProgress = ( timeLeft , total ) : number => { if ( total === 0 || timeLeft <= 0 ) { return 1 ; } return 1 - timeLeft / total ; } ; param startTime param now param endTime export const calculateSpinnerProgress = ( startTime , now , endTime ) => calculateProgress ( endTime - now , calculateTimeBetweenStartAndEnd ( startTime , endTime ) ) ;