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

tmr

v0.0.1

Published

a very simple countdown clock

Downloads

5

Readme

tmr

tmr is a very simple countdown clock. all values are in ms.

new tmr([init])

create a new timer with an optonal initial value for countdown. if now initial value is passed or the initial value is zero, the clock will alway count up.

tmr.time()

get the elapsed time.

tmr.get()

get the offset from the initial value or, if no initial value is set, the elapsed time.

tmr.start()

start or restart the clock.

tmr.stop()

stop the clock.

tmr.reset([init])

reset the clock, optionally set a new initial value.

tmr.change(offset)

change the elapsed time by offset.

tmr.set(elapsed)

set the elapsed time.

tmr.check([val])

check if the elapsed time is lower than the initial value or val

tmr.format(fmt, up)

get a formatted string of the clock offset or elapsed time. setting up true, will always give the elapsed time.

formatting

  • d full days 0-999
  • dd full days with padding 00-999
  • ddd full days with padding 000-999
  • h full hours of the day 0-23
  • hh full hours of the day with padding 00-23
  • hhh full hours total 0-999
  • m full minutes of the hour 0-59
  • mm full minutes of the hour with padding 00-59
  • mmm full minutes total 0-999
  • s full seconds of the minute 0-59
  • ss full seconds of the minute with padding 00-59
  • sss full seconds total 0-999
  • z tenths of a second 0-9
  • zz hundredths of a second 00-99
  • zzz milliseconds 000-999

example


var tmr = require("tmr");

var timer = new timer(60); // 60 seconds countdown

timer.start();

setInterval(function(){

	if (!timer.check()) throw new Error("detonation");
	
	if (blue_cable_cut) timer.set(5000);
	if (red_cable_cut) timer.stop();

	console.log("%s till detonation", timer.format("d:hh:mm:ss.zzz"));
	console.log("counting down since %s seconds", timer.format("sss", true));

},1000);