npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@slime/stopwatch

v1.3.2

Published

a stopwatch class utility for starting, pausing, resetting and getting elapsed time in milliseconds (ms), under the hood is just comparing timestamps with Date.now().

Downloads

978

Readme

StopWatch

Static Badge Static Badge

simple class utility for tracking amount of time elapsed in milliseconds (ms), by comparing time stamps

  • version 1.1.0: added typescript type definitions for StopWatch class
  • version 1.2.1: fixed bug where when stop, and resume again, the logic to calculate new time elapsed (while taking into account previous time elapsed) was wrong
  • version 1.3.0: fixed bug where when initially calling .stopTimer() before subsequent calls to .startTimer() when the StopWatch object is first instantiated, it would cause the incorrect time elapsed to be returned

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);