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 🙏

© 2026 – Pkg Stats / Ryan Hefner

downtimer

v0.3.0

Published

Timeouts, but a little more relaxing

Readme

Downtimer

Timeouts, but a little more relaxing.

Downtimer is a simple management system for timers created using setTimeout, making them less stressful to work with. It works by implementing the following features:

  • Graceful handling of exceptions thrown during timers. Errors are logged with helpful debugging information.
  • Warnings are logged for pending timers when the application exits.
  • If debugging timer-related bugs is still difficult, you can configure logging for many other events.
  • Provides a simple interface for clearing all registered timers.
  • Timer IDs can be passed through JSON.stringify (since they're just strings).

Pitfalls

  • NodeJS Timers aren't millisecond-precise. You may need to add additional buffer time when testing or a slightly-delayed timer may cause your test suite to fail. 20ms is a sensible buffer time for most computers, but slower machines (especially machines running Windows) may need a little more than that.
  • If you need times more precise than that, then downtimer probably isn't the right library for your needs (and JavaScript probably isn't the right language for your needs).
  • Different downtimer manager objects their timers independently. You can't access or cancel timers from one downtimer manager by calling timers.clearAll on another downtimer manager object.
  • Remember that downtimer.schedule schedules code to run in the future. It returns immediately, and the rest of your function continues to execute. As such, you probably don't want to use it in your test cases, as your scheduled callback may execute after your test case finishes, causing very confusing bugs. Instead, in your test cases, you may want to pause code execution using a library such as slync (short for "sleep sync").

Installation

npm i downtimer

Usage

import { downtimer } from 'downtimer';

// Create a timer manager
let timers = downtimer();

// Schedule a timer (like `setTimeout`)
const timerId = timers.schedule(() => {
  console.log('12 seconds later');
}, 12_000);

// Cancel the scheduled timer, by using the timer ID returned by
// `timers.schedule`
timers.clear(timerId);

// Or cancel all scheduled timers managed by this downtimer manager.
timers.clearAll();

// You can also customise the logging if you're really struggling to debug
// timer-related issues
// For example, if you're trying to debug a scheduled timer which isn't being
// cancelled for some reason, you could use the following configuration.
timers = downtimer({
  logConfig: {
    // Log when a timer is scheduled
    schedule: 'minimal',
    // And give full details when a timer is cancelled but not found
    clear: {
      notFound: 'full',
    },
  },
});