Socket
Socket
Sign inDemoInstall

timermodule

Package Overview
Dependencies
0
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    timermodule

Import it as


Version published
Weekly downloads
5
increased by400%
Maintainers
1
Install size
5.44 kB
Created
Weekly downloads
 

Readme

Source

USAGE

Import it as

import Timer from "timermodule";

Create an instance for it and initialize it (using init method) before using the methods of the instance.

let timerObj = new Timer(); 
timerObj.init(initializationData);

The above initialization data object is of the pattern:

 "data" : {
   "mytimer(yourtimername)" : {
            time : {
               hh : "00",
               mm : "00",
               ss : "00
           },
           status : "INIT"
         }
  },
  "notifier" : "notifierFunction"

If many timers are required, give each timer a unique key and add the data in the above format.

The notifier function will be called each time for a change in timer object. The notifier function will get an arguement in the format : (key, value). The value will be in the format as below :

        "time"(keyword) : {
            hh(keyword) : "<values>",
            mm(keyword) : "<values>",
            ss(keyword) : "<values>"
        },
        "status"(keyword) : "INIT (OR) RUNNING (OR) PAUSED"

**Once you are done with creating an instance and initializing it, you can proceed calling the methods available on the timer instance **

The main action methods available in timer object instance are as follows :

start, pause, resume, reset.

You have call the above functions with the name of your timer as arguement. Eg : start("mytimer").

To update the timer abruptly, you can use updateTimerState method.

Eg : updateTimerState(<nameoftimer>, <actionname>, <durationinhh,mm,ssobformat));

i.e nameoftimer - In the above example - "mytimer". actionname - supported values are : START, RESUME, PAUSE, RESET durationinhh,mm,ssobformat - time object in the format { hh , mm, ss}

Examples available in : CodeSandbox example link

Keywords

FAQs

Last updated on 23 Jun 2020

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