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

timer-stopwatch-dev

v1.1.0

Published

A stopwatch and countdown timer for node, maintained.

Downloads

16

Readme

timer-stopwatch

dependencies Status devDependencies Status

A stopwatch and countdown clock module for node.js, maintained.

Install

npm install timer-stopwatch

How to

The Gist

new Stopwatch([countDownMS], [options]);

Basic timers

var Stopwatch = require("timer-stopwatch");

var timer = new Stopwatch(60000); // A new countdown timer with 60 seconds
var stopwatch = new Stopwatch(); // A new count up stopwatch. Starts at 0.

Event Methods

// Fires every 50ms by default. Change setting the 'refreshRateMS' options
timer.onTime(function(time) {
	console.log(time.ms); // number of milliseconds past (or remaining);
	console.log(time.seconds); // number of seconds past (or remaining);
});

// Fires when the timer is done
timer.onDone(function() {
	console.log("Timer is complete");
});

// Fires when the timer is almost complete - default is 10 seconds remaining. Change with 'almostDoneMS' option
timer.onAlmostDone(function() {
	console.log("Timer is almost complete");
});

//These methods are chainable
timer
	.onTime(cb)
	.onAlmostDone(cb)
	.onDone(cb);

Timer Methods

timer.start();
timer.stop();
timer.startstop(); // Toggles the running state
timer.reset(countDownMS); // optional countDownMS to reset countdown to that many milliseconds
timer.getState() // Return 0, 1 or 2 if the timer is respectively stopped, running or complete
timer.isStopped()
timer.isRunning()
timer.isComplete()

Properties

timer.ms; // Number of milliseconds on the clock
timer.seconds; // Number of seconds on the clock

Options

var options = {
	refreshRateMS: 10, // How often the clock should be updated
	almostDoneMS: 10000 // When counting down - this event will fire with this many milliseconds remaining on the clock
};

var timer = new Stopwatch(60000, options);

Testing

Unit and Integration tests (requires dev dependencies)

npm test

Thanks to

@MickCrozier - The maintainer of the original package.

Other contributors:

  • @danhere
  • @connorjburton
  • @RafaelKaczmarczyk
  • @nitzo

License

MIT License