Socket
Book a DemoInstallSign in
Socket

timermodule

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

timermodule

Import it as

latest
npmnpm
Version
0.0.6
Version published
Weekly downloads
1
-66.67%
Maintainers
1
Weekly downloads
 
Created
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

timer

FAQs

Package last updated on 23 Jun 2020

Did you know?

Socket

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