New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@slime/stopwatch

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@slime/stopwatch

a class for handling and printing elapsed time in ms, under the hood is just comparing timestamps with Date.now().

1.2.1
npm
Version published
Weekly downloads
71
-55.62%
Maintainers
1
Weekly downloads
 
Created
Source

StopWatch

simple class utility for tracking amount of time elapsed in milliseconds (ms).

version 1.1.0: added typescript type definitions for StopWatch class

how to use StopWatch class via NPM/node.js

installation from terminal/CMD line

npm i @slime/stopwatch

usage: first instantiate a new StopWatch object instance from the StopWatch class

const StopWatch = require("@slime/stopwatch"); 
let stopWatch = new StopWatch(); 

API to start, stop, resume, reset with:

stopWatch.startTimer(); 
stopWatch.stopTimer();
stopWatch.startTimer();
stopWatch.reset();

getters API to query number of ms elapsed and display time elapsed as minutes/seconds/ms string:

stopWatch.getTimeElapsedInMs; // returns number of time elapsed in ms
stopWatch.getTimeElapsedInStopWatchFormatString; // returns mins/secs/ms in 00:00:00 format

demo usage

start timer and show time elapsed after 1.5 seconds

const StopWatch = require("@slime/stopwatch"); 
let stopWatch = new StopWatch(); 
console.log(stopWatch.getTimeElapsedInMs);
console.log(stopWatch.getTimeElapsedInStopWatchFormatString); 
stopWatch.startTimer();
setTimeout(()=>{
    stopWatch.stopTimer();
    console.log(stopWatch.getTimeElapsedInMs);
    console.log(stopWatch.getTimeElapsedInStopWatchFormatString); 
}, 1500); 

Keywords

utility

FAQs

Package last updated on 31 Jul 2023

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