Socket
Socket
Sign inDemoInstall

realtime-countdown

Package Overview
Dependencies
0
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    realtime-countdown

Realtime countdown timer JavaScript Library


Version published
Weekly downloads
10
increased by400%
Maintainers
1
Install size
10.5 kB
Created
Weekly downloads
 

Readme

Source

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
      onInitialize: function(eventObject) {},
      onCount: function(eventObject) {},
      onCountEnd: function(eventObject) {},
      onDestroy: function(eventObject) {},
    }

Methods

  • destroy ()

How to use

    import RealtimeCountdown from 'realtime-countdown'
    
    const timeStamp = Date.now() + 24 * 60 * 60 * 1000
    const onInitialize = (timeLeft) => console.log(timeLeft)
    const onCount = (timeLeft) => console.log(timeLeft)
    const onCountEnd = (timeLeft) => console.log(timeLeft)
    
    const Timer = new RealtimeCountdown({ 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.destroy()

Tests
npm test
Coverage
npm run coverage

Keywords

FAQs

Last updated on 07 Aug 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc