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 🙏

© 2025 – Pkg Stats / Ryan Hefner

timerider

v0.1.0

Published

Accurate timers with drift correction, pause/resume, and long delay support.

Downloads

306

Readme

timerider

A robust timer library for Deno that solves common issues with standard setTimeout and setInterval.

Features

Timerider improves upon standard timers in three key ways:

  1. Time Drift Correction: Automatically corrects time drift within 250ms for both setInterval and setTimeout, ensuring more accurate timing over long periods.
  2. Long Delay Support: Handles delays longer than the 32-bit integer limit (2^31 - 1 ms), which standard timers cannot process correctly.
  3. Pause & Resume: Adds the ability to pause a timer and resume it later, perfect for games or interactive applications.

Installation

Deno

deno add jsr:@denostack/timerider

Node.js & Browser

npm install timerider

Usage

Timeout

createTimeout works like setTimeout but returns a Timer object with additional control.

import { createTimeout } from "@denostack/timerider";

// Basic usage
createTimeout(() => {
  console.log("Hello after 1 second");
}, 1000);

// Pause and Resume
const timer = createTimeout(() => {
  console.log("This will run eventually...");
}, 5000);

// Pause the timer
timer.pause();

// Resume after some time
setTimeout(() => {
  timer.resume(); // Will resume waiting for the remaining time
}, 2000);

Interval

createInterval works like setInterval but with built-in drift correction.

import { createInterval } from "@denostack/timerider";

createInterval(() => {
  console.log("Tick every 1 second");
}, 1000);

Long Delays

Standard timers fail with delays larger than ~24.8 days (2^31 - 1 milliseconds). Timerider handles this seamlessly.

import { createTimeout } from "@denostack/timerider";

// Wait for 30 days
const thirtyDays = 1000 * 60 * 60 * 24 * 30;

createTimeout(() => {
  console.log("See you next month!");
}, thirtyDays);

API Reference

createTimeout(callback, delay)

Creates a timer that executes the callback after the specified delay.

  • callback: Function to execute.
  • delay: Number (ms) or Date object.
  • Returns: Timer

createInterval(callback, interval, delay?)

Creates a timer that repeatedly executes the callback at the specified interval.

  • callback: Function to execute.
  • interval: Number (ms) for the repetition interval.
  • delay: (Optional) Number (ms) or Date object for the initial start delay.
  • Returns: Timer

Timer Interface

The object returned by createTimeout and createInterval.

interface Timer {
  /**
   * Returns the current state of the timer.
   * "waiting": Timer is running and waiting for the next execution.
   * "paused": Timer is paused.
   * "completed": Timer has finished (for timeouts) or paused permanently.
   */
  state(): "waiting" | "paused" | "completed";

  /**
   * Pauses the timer. The remaining time is preserved.
   */
  pause(): Timer;

  /**
   * Resumes the timer from where it left off.
   */
  resume(): Timer;

  /**
   * Permanently pauses the timer. Similar to clearTimeout/clearInterval.
   */
  clear(): void;
}