Realtime Countdown
Lightweight realtime countdown timer JavaScript Library
Features
- Pure JavaScript
- Simple use
- Flexible parametrization
Install
npm install realtime-countdown
Default Options
timeStamp: 0 // value in milliseconds countStep: 1000 // value in milliseconds leadingZero: false // adds leading zero before the value if it's a single digit {} {} {} {}
Methods
destroy ()
How to use
const timeStamp = Date + 24 * 60 * 60 * 1000 const onInitialize = console const onCount = console const onCountEnd = console const Timer = timeStamp onInitialize onCount onCountEnd // output on onInitialize const onInitializeTimeLeft = days: 1 hours: 0 minutes: 0 seconds: 0 // output on every tick, will be reduced by a `countStep` const onCountTimeLeft = days: 0 hours: 23 minutes: 59 seconds: 59 // output on count end (not called when destroy) const onCountEndTimeLeft = days: 0 hours: 0 minutes: 0 seconds: 0 // destroy timer Timer
Tests
npm test
Coverage
npm run coverage